Vulnerabilities in pkg:npm/cookie

PACKAGE
Advisory Identifier: GHSA-pxg6-pf52-xh8x
Advisory Summary

CVE-2024-47764 is a LOW cookie accepts cookie name, path, vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Cookie libraries in the npm ecosystem. The issue involves cookie accepts cookie name, path, and domain with out of bounds characters. Remediation is available by upgrading affected packages to version 0.7.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/cookie

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/cookie. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-pxg6-pf52-xh8x CVE-2024-47764 LOW cookie accepts cookie name, path, and domain with out of bounds characters

CVE-2024-47764 at a Glance

CVE Identifier CVE-2024-47764
GHSA Identifier GHSA-pxg6-pf52-xh8x
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Cookie
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2024-47764

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

cookie fixed: 0.7.0
npm install cookie@0.7.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 cookie

How to Check if You Are Affected

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

npm ls cookie

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

Note: The npm ls cookie 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In Cookie, 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 The cookie name could be used to set other fields of the cookie, resulting in an unexpected cookie value. For example, `serialize("userName=<script>alert('XSS3')</script>; Max-Age=2592000; a", value)` would result in `"userName=<script>alert('XSS3')</script>; Max-Age=2592000; a=test"`, setting `userName` cookie to `<script>` and ignoring `value`. A similar escape can be used for `path` and `domain`, which could be abused to alter other fields of the cookie. ### Patches Upgrade to 0.7.0, which updates the validation for `name`, `path`, and `domain`. ### Workarounds Avoid passing untrusted or arbitrary values for these fields, ensure they are set by the application instead of user input. ### References * https://github.com/jshttp/cookie/pull/167

CVE-2024-47764 Affected Cookie Versions

1 component(s)
Fixed Versions:
0.7.0
Product / Package Ecosystem Affected Versions Fixed Version
cookie
npm
< 0.7.0
0.7.0

References

Frequently Asked Questions

What is CVE-2024-47764?
CVE-2024-47764 is a security vulnerability in Cookie involving cookie accepts cookie name, path, and domain with out of bounds characters under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Cookie versions are affected?
Affected versions include releases prior to 0.7.0 across affected packages: cookie.
What version fixes CVE-2024-47764?
Upgrading to 0.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cookie affected?
Yes, cookie is affected in releases prior to 0.7.0. Upgrade your dependency to 0.7.0 or later.
What CWE is associated with CVE-2024-47764?
CVE-2024-47764 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check npm dependencies for CVE-2024-47764?
Run the dependency tree command: 'npm ls cookie'. 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-pxg6-pf52-xh8x",
  "modified" : "2024-10-04T20:31:00Z",
  "published" : "2024-10-04T20:31:00Z",
  "aliases" : [ "CVE-2024-47764" ],
  "summary" : "cookie accepts cookie name, path, and domain with out of bounds characters",
  "details" : "### Impact\n\nThe cookie name could be used to set other fields of the cookie, resulting in an unexpected cookie value. For example, `serialize(\"userName=<script>alert('XSS3')</script>; Max-Age=2592000; a\", value)` would result in `\"userName=<script>alert('XSS3')</script>; Max-Age=2592000; a=test\"`, setting `userName` cookie to `<script>` and ignoring `value`.\n\nA similar escape can be used for `path` and `domain`, which could be abused to alter other fields of the cookie.\n\n### Patches\n\nUpgrade to 0.7.0, which updates the validation for `name`, `path`, and `domain`.\n\n### Workarounds\n\nAvoid passing untrusted or arbitrary values for these fields, ensure they are set by the application instead of user input.\n\n### References\n\n* https://github.com/jshttp/cookie/pull/167",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "cookie"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.7.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jshttp/cookie/security/advisories/GHSA-pxg6-pf52-xh8x"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jshttp/cookie/pull/167"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jshttp/cookie/commit/e10042845354fea83bd8f34af72475eed1dadf5c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jshttp/cookie"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-04T20:31:00Z",
    "nvd_published_at" : null
  }
}