CVE-2024-35220: @fastify/session @fastify/session Reuses Destroyed Session Cookie Vulnerability

HIGH
Advisory Identifier: GHSA-pj27-2xvp-4qxg
CVSS 7.4
CWE-613
Published
Advisory Summary

CVE-2024-35220 is a HIGH (CVSS 7.4) @fastify/session reuses destroyed session cookie vulnerability (CWE-613: Insufficient Session Expiration) affecting @fastify/session libraries in the npm ecosystem. The issue involves @fastify/session reuses destroyed session cookie. Remediation is available by upgrading affected packages to version 10.9.0.

CVE-2024-35220 at a Glance

CVE Identifier CVE-2024-35220
GHSA Identifier GHSA-pj27-2xvp-4qxg
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-613: Insufficient Session Expiration
Affected Product @fastify/session
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-35220

To remediate this vulnerability, upgrade all affected @fastify/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.

@fastify/session fixed: 10.9.0
npm install @fastify/session@10.9.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @fastify/session

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-35220, inspect your project dependencies using npm:

npm ls @fastify/session

Analyze the terminal output to locate any version of @fastify/session in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 10.9.0), your application is affected.

Note: The npm ls @fastify/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/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

### Impact When restoring the cookie from the session store, the `expires` field is overriden if the `maxAge` field was set. This means a cookie is never correctly detected as expired and thus expired sessions are not destroyed. ### Patches Updating to v10.9.0 will solve this. ### Workarounds None ### References Publicly reported at: https://github.com/fastify/session/issues/251

CVE-2024-35220 Affected @fastify/session Versions

1 component(s)
Fixed Versions:
10.9.0
Product / Package Ecosystem Affected Versions Fixed Version
@fastify/session
npm
< 10.9.0
10.9.0

References

Frequently Asked Questions

What is CVE-2024-35220?
CVE-2024-35220 is a security vulnerability in @fastify/session involving @fastify/session reuses destroyed session cookie under CWE-613: Insufficient Session Expiration.
Which @fastify/session versions are affected?
Affected versions include releases prior to 10.9.0 across affected packages: @fastify/session.
What version fixes CVE-2024-35220?
Upgrading to 10.9.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @fastify/session affected?
Yes, @fastify/session is affected in releases prior to 10.9.0. Upgrade your dependency to 10.9.0 or later.
What is the CVSS score of CVE-2024-35220?
CVE-2024-35220 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2024-35220?
CVE-2024-35220 is classified under CWE-613: Insufficient Session Expiration (According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.").
How can I check npm dependencies for CVE-2024-35220?
Run the dependency tree command: 'npm ls @fastify/session'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-pj27-2xvp-4qxg",
  "modified" : "2024-05-22T13:26:11Z",
  "published" : "2024-05-21T18:09:57Z",
  "aliases" : [ "CVE-2024-35220" ],
  "summary" : "@fastify/session reuses destroyed session cookie",
  "details" : "### Impact\n\nWhen restoring the cookie from the session store, the `expires` field is overriden if the `maxAge` field was set.\nThis means a cookie is never correctly detected as expired and thus expired sessions are not destroyed.\n\n### Patches\n\nUpdating to v10.9.0 will solve this.\n\n### Workarounds\n\nNone\n\n### References\n\nPublicly reported at: https://github.com/fastify/session/issues/251",
  "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/session"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "10.9.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fastify/session/security/advisories/GHSA-pj27-2xvp-4qxg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35220"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/session/issues/251"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/session/commit/0495ce5b534c4550f25228821db8098293439f2f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fastify/session"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-613" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-21T18:09:57Z",
    "nvd_published_at" : "2024-05-21T21:15:08Z"
  }
}