Vulnerabilities in pkg:npm/js-cookie
PACKAGECVE-2026-46625 is a HIGH (CVSS 7.5) per-instance prototype hijack vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting JavaScript Cookie libraries in the npm ecosystem. The issue involves per-instance prototype hijack in assign() enables cookie-attribute injection. Remediation is available by upgrading affected packages to version 3.0.7.
pkg:npm/js-cookie
Vulnerability advisories affecting package pkg:npm/js-cookie. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-qjx8-664m-686j | CVE-2026-46625 | HIGH | JavaScript Cookie: Per-instance prototype hijack in assign() enables cookie-attribute injection |
CVE-2026-46625 at a Glance
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:H/A:N).
How to Fix CVE-2026-46625
To remediate this vulnerability, upgrade all affected JavaScript 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.
npm install js-cookie@3.0.7
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls js-cookie
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-46625, inspect your project dependencies using npm:
npm ls js-cookie
Analyze the terminal output to locate any version of JavaScript Cookie in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.7), your application is affected.
Note: The npm ls js-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-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In JavaScript 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
CVE-2026-46625 Affected JavaScript Cookie Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
js-cookie
|
npm |
< 3.0.7
|
3.0.7
|
References
Frequently Asked Questions
What is CVE-2026-46625?
Which JavaScript Cookie versions are affected?
What version fixes CVE-2026-46625?
Is js-cookie affected?
What is the CVSS score of CVE-2026-46625?
What CWE is associated with CVE-2026-46625?
How can I check npm dependencies for CVE-2026-46625?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-qjx8-664m-686j",
"modified" : "2026-06-11T14:05:06Z",
"published" : "2026-05-21T21:20:31Z",
"aliases" : [ "CVE-2026-46625" ],
"summary" : "JavaScript Cookie: Per-instance prototype hijack in assign() enables cookie-attribute injection",
"details" : "## Summary\n\n`js-cookie`'s internal `assign()` helper copies properties with `for...in` + plain assignment. When the source object is produced by `JSON.parse`, the JSON object's `\"__proto__\"` member is an *own enumerable* property, so the `for…in` enumerates it and the `target[key] = source[key]` write triggers the **`Object.prototype.__proto__` setter** on the fresh `target` (`{}`). The result is a per-instance prototype hijack: `Object.prototype` itself is untouched, but the merged `attributes` object now inherits attacker-controlled keys.\n\nBecause the consuming `set()` function then enumerates the merged object with another `for...in`, every key the attacker placed on the polluted prototype lands in the resulting `Set-Cookie` string as an attribute pair. The attacker can set `domain=`, `secure=`, `samesite=`, `expires=`, and `path=` on cookies whose attributes the developer thought were locked down.\n\n## Impact\n\nAny application that forwards a JSON-derived object as the `attributes` argument to `Cookies.set`, `Cookies.remove`, `Cookies.withAttributes`, or `Cookies.withConverter` is vulnerable. This is the standard pattern when cookie configuration comes from a backend:\n\n```js\nconst cfg = await fetch('/config').then(r => r.json());\nCookies.set('session', token, cfg.cookieAttrs); // cfg.cookieAttrs influenced by attacker\n```\n\nA payload of `{\"__proto__\":{\"domain\":\"evil.example\",\"secure\":\"false\",\"samesite\":\"None\"}}` causes js-cookie to emit:\n\n```\nSet-Cookie: session=TOKEN; path=/; domain=evil.example; secure=false; samesite=None\n```\n\n## Affected code\n\n```js\n// src/assign.mjs — full file\nexport default function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i]\n for (var key in source) { // includes own enumerable '__proto__'\n target[key] = source[key] // [[Set]] form - fires __proto__ setter\n }\n }\n return target\n}\n```\n## Proof of concept\n\nNode 22.11.0, no third-party deps:\n\n### Environment setup\n```bash\nmkdir -p /tmp/jscookie-poc && cd /tmp/jscookie-poc\nnpm init -y\nnpm i js-cookie\n```\n\n### PoC\n```js\nubuntu@kuber:/tmp/jscookie-poc$ cat poc.mjs\nlet lastSetCookie = '';\nglobalThis.document = {\n get cookie() { return ''; },\n set cookie(v) { lastSetCookie = v; }\n};\n\nconst { default: Cookies } = await import('js-cookie');\n\nconst attackerAttrs = JSON.parse(\n '{\"__proto__\":{\"secure\":\"false\",\"domain\":\"evil.com\",\"samesite\":\"None\",\"expires\":-1}}'\n);\n\nCookies.set('session', 'TOKEN', attackerAttrs);\n\nconsole.log('Set-Cookie that js-cookie wrote to document.cookie:');\nconsole.log(lastSetCookie);\n```\n\nExecution:\n<img width=\"2614\" height=\"1174\" alt=\"cls-2026-05-14-01 44 39\" src=\"https://github.com/user-attachments/assets/120df1fe-7e97-4ca3-904e-ab80d71ecf62\" />\n\n## Suggested patch\n\n```diff\n--- a/src/assign.mjs\n+++ b/src/assign.mjs\n@@\n export default function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i]\n- for (var key in source) {\n- target[key] = source[key]\n- }\n+ for (var key in source) {\n+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue\n+ Object.defineProperty(target, key, {\n+ value: source[key],\n+ writable: true,\n+ enumerable: true,\n+ configurable: true,\n+ })\n+ }\n }\n return target\n }\n```\n\nEquivalent one-liner alternative - iterate own names only and filter:\n\n```js\nfor (const key of Object.getOwnPropertyNames(source)) {\n if (key === '__proto__') continue\n target[key] = source[key]\n}\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "js-cookie"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.0.7"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.0.5"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/js-cookie/js-cookie/security/advisories/GHSA-qjx8-664m-686j"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-46625"
}, {
"type" : "WEB",
"url" : "https://github.com/js-cookie/js-cookie/commit/eb3c40e89731e99b8970faaf35ddad249c6c0020"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/js-cookie/js-cookie"
}, {
"type" : "WEB",
"url" : "https://github.com/js-cookie/js-cookie/releases/tag/v3.0.7"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1321" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-05-21T21:20:31Z",
"nvd_published_at" : "2026-06-10T22:16:59Z"
}
}