CVE-2022-25901: Cookiejar Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-h452-7996-h45h
CVSS 5.3
CWE-1333
Published
Advisory Summary

CVE-2022-25901 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Cookiejar libraries in the npm ecosystem. The issue involves cookiejar regular expression denial of service via cookie.parse function. Remediation is available by upgrading affected packages to version 2.1.4.

CVE-2022-25901 at a Glance

CVE Identifier CVE-2022-25901
GHSA Identifier GHSA-h452-7996-h45h
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Cookiejar
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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

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 Low (A:L)

How to Fix CVE-2022-25901

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

cookiejar fixed: 2.1.4
npm install cookiejar@2.1.4
org.webjars.npm:cookiejar fixed: Latest secure release
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>cookiejar</artifactId>
    <version>Latest secure release</version>
</dependency>
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 cookiejar

How to Check if You Are Affected

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

npm ls cookiejar

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

Note: The npm ls cookiejar 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-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Cookiejar, 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

Versions of the package cookiejar before 2.1.4 are vulnerable to Regular Expression Denial of Service (ReDoS) via the `Cookie.parse` function and other aspects of the API, which use an insecure regular expression for parsing cookie values. Applications could be stalled for extended periods of time if untrusted input is passed to cookie values or attempted to parse from request headers. Proof of concept: ``` ts\nconst { CookieJar } = require("cookiejar"); const jar = new CookieJar(); const start = performance.now(); const attack = "a" + "t".repeat(50_000); jar.setCookie(attack); console.log(`CookieJar.setCookie(): ${performance.now() - start}ms`); ``` ``` CookieJar.setCookie(): 2963.214399999939ms ```

CVE-2022-25901 Affected Cookiejar Versions

2 component(s)
Fixed Versions:
2.1.4
Product / Package Ecosystem Affected Versions Fixed Version
cookiejar
npm
< 2.1.4
2.1.4
org.webjars.npm:cookiejar
Maven
≤ 2.1.3

References

Frequently Asked Questions

What is CVE-2022-25901?
CVE-2022-25901 is a security vulnerability in Cookiejar involving cookiejar Regular Expression Denial of Service via Cookie.parse function under CWE-1333: Inefficient Regular Expression Complexity.
Which Cookiejar versions are affected?
Affected versions include releases prior to 2.1.4 across affected packages: cookiejar, org.webjars.npm:cookiejar.
What version fixes CVE-2022-25901?
Upgrading to 2.1.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cookiejar affected?
Yes, cookiejar is affected in releases prior to 2.1.4, Latest secure release. Upgrade your dependency to 2.1.4, Latest secure release or later.
What is the CVSS score of CVE-2022-25901?
CVE-2022-25901 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2022-25901?
CVE-2022-25901 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check npm dependencies for CVE-2022-25901?
Run the dependency tree command: 'npm ls cookiejar'. 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-h452-7996-h45h",
  "modified" : "2025-02-13T18:36:34Z",
  "published" : "2023-01-18T06:31:03Z",
  "aliases" : [ "CVE-2022-25901" ],
  "summary" : "cookiejar Regular Expression Denial of Service via Cookie.parse function",
  "details" : "Versions of the package cookiejar before 2.1.4 are vulnerable to Regular Expression Denial of Service (ReDoS) via the `Cookie.parse` function and other aspects of the API, which use an insecure regular expression for parsing cookie values. Applications could be stalled for extended periods of time if untrusted input is passed to cookie values or attempted to parse from request headers.\n\nProof of concept:\n\n```\nts\\nconst { CookieJar } = require(\"cookiejar\");\n\nconst jar = new CookieJar();\n\nconst start = performance.now();\n\nconst attack = \"a\" + \"t\".repeat(50_000);\njar.setCookie(attack);\n\nconsole.log(`CookieJar.setCookie(): ${performance.now() - start}ms`);\n\n```\n\n```\nCookieJar.setCookie(): 2963.214399999939ms\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "cookiejar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.1.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.webjars.npm:cookiejar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.1.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-25901"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bmeck/node-cookiejar/pull/39"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bmeck/node-cookiejar/pull/39/commits/eaa00021caf6ae09449dde826108153b578348e5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/bmeck/node-cookiejar"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bmeck/node-cookiejar/blob/master/cookiejar.js#23L73"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/bmeck/node-cookiejar/blob/master/cookiejar.js%23L73"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/09/msg00008.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-3176681"
  }, {
    "type" : "WEB",
    "url" : "https://security.snyk.io/vuln/SNYK-JS-COOKIEJAR-3149984"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-01-23T16:59:52Z",
    "nvd_published_at" : "2023-01-18T05:15:00Z"
  }
}