CVE-2024-31999: @fastify/secure-session Reuse Of Destroyed Secure Session Vulnerability
HIGHCVE-2024-31999 is a HIGH (CVSS 7.4) reuse of destroyed secure session vulnerability (CWE-613: Insufficient Session Expiration) affecting @fastify/secure-session libraries in the npm ecosystem. The issue involves reuse of destroyed secure session cookie. Remediation is available by upgrading affected packages to version 7.3.0.
CVE-2024-31999 at a Glance
Security Impact
CVSS: 7.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N).
How to Fix CVE-2024-31999
To remediate this vulnerability, upgrade all affected @fastify/secure-session dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @fastify/secure-session@7.3.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @fastify/secure-session
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-31999, inspect your project dependencies using npm:
npm ls @fastify/secure-session
Analyze the terminal output to locate any version of @fastify/secure-session in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.3.0), your application is affected.
Note: The npm ls @fastify/secure-session command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-613: Insufficient Session Expiration, where according to wasc, "insufficient session expiration is when a web site permits an attacker to reuse old session credentials or session ids for authorization.". In @fastify/secure-session, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-31999 Affected @fastify/secure-session Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@fastify/secure-session
|
npm |
< 7.3.0
|
7.3.0
|
References
Frequently Asked Questions
What is CVE-2024-31999?
Which @fastify/secure-session versions are affected?
What version fixes CVE-2024-31999?
Is @fastify/secure-session affected?
What is the CVSS score of CVE-2024-31999?
What CWE is associated with CVE-2024-31999?
How can I check npm dependencies for CVE-2024-31999?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-9wwp-q7wq-jx35",
"modified" : "2024-04-11T14:31:13Z",
"published" : "2024-04-10T17:15:50Z",
"aliases" : [ "CVE-2024-31999" ],
"summary" : "@fastify/secure-session: Reuse of destroyed secure session cookie",
"details" : "### Impact\n\nAt 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).\n\nThe 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.\n\n### Patches\n\nFixed in 56d66642ecc633cff0606927601e81cdac361370.\nUpdate to v7.3.0.\n\n### Workarounds\n\nInclude a \"last update\" field in the session, and treat \"old sessions\" as expired. \nMake sure to configure your cookie as \"http only\".\n\n### References\n\n* https://hackerone.com/reports/2374253\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/secure-session"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "7.3.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-secure-session/security/advisories/GHSA-9wwp-q7wq-jx35"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-31999"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-secure-session/commit/56d66642ecc633cff0606927601e81cdac361370"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify-secure-session"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-613" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-04-10T17:15:50Z",
"nvd_published_at" : "2024-04-10T22:15:07Z"
}
}