Skip to content
Heist/ feed
Back to feed
High

@fastify/secure-session: Reuse of destroyed secure session cookie

Type: advisorySources: OSV

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

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2024-31999
Confirmed fixed CVEs
Not specified
Updated in this feed
7 Nov 2026, 05:15 UTC · Revision 1

Source evidence

@fastify/secure-session: Reuse of destroyed secure session cookie

core-osv · Original source

Published 10 Apr 2024, 21:59 UTC

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

osv:CVE-2024-31999
Complete source record
{
  "id": "a9f029a1b2783b7ab32f787bb302bb4711a906597f00b304f2781902a18ae477",
  "url": "https://osv.dev/vulnerability/CVE-2024-31999",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "@fastify/secure-session: Reuse of destroyed secure session cookie",
    "summary": "@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.",
    "evidence": "osv:CVE-2024-31999",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2024-31999",
      "aliases": [
        "CVE-2024-31999",
        "GHSA-9wwp-q7wq-jx35"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/fastify/fastify-secure-session",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "9d6713c376fabb0716a223eca520722eaafe9dcf"
                },
                {
                  "fixed": "56d66642ecc633cff0606927601e81cdac361370"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "7.3.0"
                      }
                    ],
                    "source": "AFFECTED_FIELD",
                    "strategy": "StringRangeExpression"
                  },
                  {
                    "range": [
                      {
                        "fixed": "56d66642ecc633cff0606927601e81cdac361370"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v7.2.0",
            "v7.1.0",
            "v7.0.0",
            "v6.2.0",
            "v6.1.0",
            "v6.0.0",
            "v5.3.0",
            "v5.2.0",
            "v5.1.1",
            "v5.1.0",
            "v5.0.0",
            "v4.1.1",
            "v4.1.0",
            "v4.0.0",
            "v3.1.0",
            "v3.0.0",
            "v2.3.1"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-31999.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:50.173169441Z",
      "provider": "osv",
      "references": [
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/31xxx/CVE-2024-31999.json",
        "https://github.com/fastify/fastify-secure-session/security/advisories/GHSA-9wwp-q7wq-jx35",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-31999",
        "https://github.com/fastify/fastify-secure-session/commit/56d66642ecc633cff0606927601e81cdac361370"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-613"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/31xxx/CVE-2024-31999.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-31999",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 518348,
  "published_at": "2024-04-10T21:59:54.176+00:00"
}