CVE-2022-25901: Cookiejar Denial of Service Vulnerability
MODERATECVE-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
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).
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.
npm install cookiejar@2.1.4
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>cookiejar</artifactId>
<version>Latest secure release</version>
</dependency>
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
CVE-2022-25901 Affected Cookiejar Versions
2 component(s)| 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?
Which Cookiejar versions are affected?
What version fixes CVE-2022-25901?
Is cookiejar affected?
What is the CVSS score of CVE-2022-25901?
What CWE is associated with CVE-2022-25901?
How can I check npm dependencies for CVE-2022-25901?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}