CVE-2024-23641: @sveltejs/kit Sending A GET Or HEAD Vulnerability

HIGH
Advisory Identifier: GHSA-g5m6-hxpp-fc49
CVSS 7.5
CWE-20
Published
Advisory Summary

CVE-2024-23641 is a HIGH (CVSS 7.5) sending a get or head vulnerability (CWE-20: Improper Input Validation) affecting @sveltejs/kit libraries in the npm ecosystem. The issue involves sending a get or head request with a body crashes sveltekit. Remediation is available by upgrading affected packages to version 2.4.3, 2.1.2, 3.0.3, 4.0.1.

CVE-2024-23641 at a Glance

CVE Identifier CVE-2024-23641
GHSA Identifier GHSA-g5m6-hxpp-fc49
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-20: Improper Input Validation
Affected Product @sveltejs/kit
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/S:U/C:N/I:N/A:H).

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

How to Fix CVE-2024-23641

To remediate this vulnerability, upgrade all affected @sveltejs/kit dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@sveltejs/kit fixed: 2.4.3
npm install @sveltejs/kit@2.4.3
@sveltejs/adapter-node fixed: 2.1.2
npm install @sveltejs/adapter-node@2.1.2
@sveltejs/adapter-node fixed: 3.0.3
npm install @sveltejs/adapter-node@3.0.3
@sveltejs/adapter-node fixed: 4.0.1
npm install @sveltejs/adapter-node@4.0.1
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 @sveltejs/kit

How to Check if You Are Affected

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

npm ls @sveltejs/kit

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

Note: The npm ls @sveltejs/kit 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In @sveltejs/kit, 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

### Summary In SvelteKit 2 sending a GET request with a body eg `{}` to a SvelteKit app in preview or with `adapter-node` throws `Request with GET/HEAD method cannot have body.` and crashes the app. ``` node:internal/deps/undici/undici:6066 throw new TypeError("Request with GET/HEAD method cannot have body."); ^ TypeError: Request with GET/HEAD method cannot have body. at new Request (node:internal/deps/undici/undici:6066:17) at getRequest (file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/node/index.js:107:9) at file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:181:26 at call (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44795:7) at next (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44739:5) at file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:172:6 at call (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44795:7) at next (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44739:5) at file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:211:27 at call (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44795:7) Node.js v20.11.0 ``` `TRACE` requests will also cause the app to crash. Prerendered pages and SvelteKit 1 apps are not affected. <!-- ### Details _Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer._ --> ### PoC <!-- _Complete instructions, including specific configuration details, to reproduce the vulnerability._ --> First do a fresh install of SvelteKit 2 with the example app. Typescript. 1. `npm run build` 2. `npm run preview` 3. Go to http://localhost:4173 (works) 4. curl -X GET -d "{}" http://localhost:4173/bye 5. Application crashes and http://localhost:4173 is down ### Impact <!-- _What kind of vulnerability is it? Who is impacted?_ --> Denial of Service for apps using `adapter-node`

CVE-2024-23641 Affected @sveltejs/kit Versions

4 component(s)
Fixed Versions:
2.4.32.1.23.0.34.0.1
Product / Package Ecosystem Affected Versions Fixed Version
@sveltejs/kit
npm
≥ 2.0.0
< 2.4.3
2.4.3
@sveltejs/adapter-node
npm
≥ 2.0.0
< 2.1.2
2.1.2
@sveltejs/adapter-node
npm
≥ 3.0.0
< 3.0.3
3.0.3
@sveltejs/adapter-node
npm
≥ 4.0.0
< 4.0.1
All 1 versions
4.0.0
4.0.1

References

Frequently Asked Questions

What is CVE-2024-23641?
CVE-2024-23641 is a security vulnerability in @sveltejs/kit involving Sending a GET or HEAD request with a body crashes SvelteKit under CWE-20: Improper Input Validation.
Which @sveltejs/kit versions are affected?
Affected versions include releases prior to 2.4.3, 2.1.2, 3.0.3, 4.0.1 across affected packages: @sveltejs/kit, @sveltejs/adapter-node.
What version fixes CVE-2024-23641?
Upgrading to 2.4.3, 2.1.2, 3.0.3, 4.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @sveltejs/kit affected?
Yes, @sveltejs/kit is affected in releases prior to 2.4.3. Upgrade your dependency to 2.4.3 or later.
Is @sveltejs/adapter-node affected?
Yes, @sveltejs/adapter-node is affected in releases prior to 2.1.2, 3.0.3, 4.0.1. Upgrade your dependency to 2.1.2, 3.0.3, 4.0.1 or later.
What is the CVSS score of CVE-2024-23641?
CVE-2024-23641 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2024-23641?
CVE-2024-23641 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check npm dependencies for CVE-2024-23641?
Run the dependency tree command: 'npm ls @sveltejs/kit'. 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-g5m6-hxpp-fc49",
  "modified" : "2024-01-24T19:13:36Z",
  "published" : "2024-01-24T14:22:22Z",
  "aliases" : [ "CVE-2024-23641" ],
  "summary" : "Sending a GET or HEAD request with a body crashes SvelteKit",
  "details" : "### Summary\nIn SvelteKit 2 sending a GET request with a body eg `{}` to a SvelteKit app in preview or with `adapter-node` throws `Request with GET/HEAD method cannot have body.` and crashes the app.\n\n```\nnode:internal/deps/undici/undici:6066\n          throw new TypeError(\"Request with GET/HEAD method cannot have body.\");\n                ^\n\nTypeError: Request with GET/HEAD method cannot have body.\n    at new Request (node:internal/deps/undici/undici:6066:17)\n    at getRequest (file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/node/index.js:107:9)\n    at file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:181:26\n    at call (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44795:7)\n    at next (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44739:5)\n    at file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:172:6\n    at call (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44795:7)\n    at next (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44739:5)\n    at file:///C:/Users/admin/Desktop/reproduction/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:211:27\n    at call (file:///C:/Users/admin/Desktop/reproduction/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:44795:7)\n\nNode.js v20.11.0\n```\n\n`TRACE` requests will also cause the app to crash. Prerendered pages and SvelteKit 1 apps are not affected.\n\n<!--\n### Details\n_Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer._\n-->\n### PoC\n<!-- _Complete instructions, including specific configuration details, to reproduce the vulnerability._ -->\nFirst do a fresh install of SvelteKit 2 with the example app. Typescript.\n\n1. `npm run build`\n2. `npm run preview`\n3. Go to http://localhost:4173 (works)\n4. curl -X GET -d \"{}\" http://localhost:4173/bye\n5. Application crashes and http://localhost:4173 is down\n\n### Impact\n<!-- _What kind of vulnerability is it? Who is impacted?_ -->\nDenial of Service for apps using `adapter-node`",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@sveltejs/kit"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.4.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@sveltejs/adapter-node"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.1.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@sveltejs/adapter-node"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@sveltejs/adapter-node"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.1"
      } ]
    } ],
    "versions" : [ "4.0.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sveltejs/kit/security/advisories/GHSA-g5m6-hxpp-fc49"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-23641"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sveltejs/kit/commit/af34142631c876a7eb62ff81f71e8a3f90dafee9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sveltejs/kit"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-24T14:22:22Z",
    "nvd_published_at" : "2024-01-24T17:15:08Z"
  }
}