CVE-2024-31999 @fastify/secure-session: Reuse of destroyed secure session cookie

High 7.4 Published Updated

Attackers can reuse destroyed secure session cookies indefinitely, bypassing session expiration and potentially maintaining unauthorized access.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2024-31999?

CVE-2024-31999 is a high-severity vulnerability in fastify-secure-session, published on 10 Apr 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

@festify/secure-session creates a secure stateless cookie session for Fastify. At the end of the request handling, it will encrypt all data in the session with a secret key and attach the ciphertext as a cookie value with the defined cookie name. After that, the session on the server side is destroyed. When an encrypted cookie with matching session name is provided with subsequent requests, it will decrypt the ciphertext to get the data. The plugin then creates a new session with the data in the ciphertext. Thus theoretically the web instance is still accessing the data from a server-side session, but technically that session is generated solely from a user provided cookie (which is assumed to be non-craftable because it is encrypted with a secret key not known to the user). The issue exists in the session removal process. In the delete function of the code, when the session is deleted, it is marked for deletion. However, if an attacker could gain access to the cookie, they could keep using it forever. Version 7.3.0 contains a patch for the issue. As a workaround, one may include a "last update" field in the session, and treat "old sessions" as expired.

Weakness: CWE-613

Which versions are affected by CVE-2024-31999?

2 open source packages ship an affected version, including @fastify/secure-session.

PackageAffectedFixed in
@fastify/secure-session npmAll versions7.3.0
@fastify/secure-session npmAll versions7.3.0

How do I fix CVE-2024-31999?

Upgrade @fastify/secure-session to 7.3.0 or later.

Is CVE-2024-31999 being exploited?

There is no known exploitation of CVE-2024-31999 in the wild and no public exploit code.

Sources

Also known as GHSA-9wwp-q7wq-jx35.

Is CVE-2024-31999 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free