HIGH 7.5

CVE-2026-46625: js-cookie Prototype Pollution Allows Cookie Attribute Hijacking

js-cookie is a popular JavaScript library that manages browser cookies. Versions before 3.0.7 contain a prototype pollution vulnerability where an attacker can manipulate cookie security attributes. By crafting a malicious JSON object with a specially-formed __proto__ property, an attacker can inject unauthorized cookie attributes like domain, secure, samesite, expires, and path. This allows them to broaden cookie scope, remove security restrictions, or extend cookie lifetime—potentially enabling session hijacking, cross-site request forgery, or credential theft depending on how the application uses cookies.

Source data · NVD / CISA · public domain

CVSS
3.1 · 7.5 HIGH · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
Weaknesses (CWE)
CWE-1321, CWE-915
Affected products
0 configuration(s)
Published / Modified
2026-06-10 / 2026-07-15

NVD description (verbatim)

JavaScript Cookie is a JavaScript API for handling cookies, client-side. Prior to version 3.0.7, 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. Because 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. This issue has been patched in version 3.0.7.

9 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability stems from js-cookie's assign() helper function, which uses for…in loops combined with direct property assignment to merge objects. When processing a JSON.parse() output containing a __proto__ key as an own enumerable property, the assignment target[key] = source[key] triggers the Object.prototype.__proto__ setter. This pollutes the target object's prototype chain without modifying Object.prototype itself. The polluted prototype is then enumerated again during cookie serialization, injecting attacker-controlled attributes into the Set-Cookie header. The attack succeeds because modern JavaScript allows __proto__ as a regular property key in JSON, and the library does not defensively filter or use Object.create(null) to prevent prototype chain pollution.

Business impact

Applications relying on js-cookie to enforce strict cookie policies face degraded security posture. An attacker could bypass intended domain restrictions, remove the Secure flag to enable unencrypted transmission over HTTP, weaken SameSite protections against CSRF, or extend cookie lifetime. In authentication-heavy applications, this directly undermines session management and could facilitate account takeover or privilege escalation. Third-party integrations and single-page applications that delegate cookie handling to js-cookie are particularly at risk if the library version is not current.

Affected systems

Any application using js-cookie versions prior to 3.0.7 is potentially affected. This includes client-side JavaScript applications, browser extensions, Electron applications, and server-side Node.js applications that handle cookies via this library. The vulnerability is triggered only when the set() method receives a JSON-parsed object as input, making applications that directly parse untrusted JSON and pass it to js-cookie most vulnerable. Server-side usage is less common but possible in Node.js environments.

Exploitability

Exploitability is high. The attack requires only network access and the ability to influence input passed to js-cookie's set() method—no user interaction, authentication, or complex setup needed. If the application accepts JSON from an untrusted source (user input, third-party API, message queue) and forwards it to js-cookie, exploitation is straightforward. Proof-of-concept is trivial: JSON.parse('{"__proto__":{"domain":".attacker.com"}}') followed by a call to set(). This is not yet tracked in CISA's Known Exploited Vulnerabilities list, but the low barrier to exploitation makes defensive patching urgent.

Remediation

Upgrade js-cookie to version 3.0.7 or later immediately. Verify the update in package.json or lock file and test cookie behavior in staging before production rollout. For applications unable to upgrade immediately, implement input validation: sanitize or reject JSON objects containing __proto__ keys before passing to js-cookie, or use a library fork that defensively filters such keys. As a temporary mitigation, avoid calling js-cookie's set() with untrusted JSON; instead, construct cookie option objects explicitly in application code.

Patch guidance

Version 3.0.7 contains the fix and should be deployed as a priority patch. If using npm, run npm install js-cookie@latest or npm update js-cookie, then verify the installed version with npm list js-cookie. For yarn users, run yarn upgrade js-cookie. Regenerate package-lock.json or yarn.lock and commit to version control. In production, test cookie behavior (domain, secure flag, samesite) immediately after patching to ensure no application logic depends on the buggy behavior. If using a monorepo or private registry, coordinate updates across all dependent services.

Detection guidance

Monitor for unusual Set-Cookie headers that contain unexpected attribute values (domain, secure=false, samesite=none) injected after js-cookie calls. In browser DevTools or proxy logs, examine Set-Cookie responses for suspicious domain= values pointing to attacker-controlled domains. On the server side, log and alert on Set-Cookie headers where attributes deviate from configured defaults. Correlate timing: if Set-Cookie attributes change immediately after a POST/API request containing JSON payloads, investigate whether json-cookie's set() is being called unsafely. WAF rules can detect patterns like {"__proto__": in request bodies when followed by anomalous Set-Cookie responses.

Why prioritize this

This vulnerability merits immediate patching due to the combination of high CVSS score (7.5), direct impact on authentication and session security, trivial exploitability, and broad applicability to web and Node.js applications. Prototype pollution is a well-understood attack class with ample tooling and researcher familiarity. The fix is low-risk and backward-compatible. Organizations should treat this as a P1 security patch, especially for customer-facing authentication flows.

Risk score, explained

The CVSS 3.1 score of 7.5 (HIGH) reflects network-accessible exploitation with no user interaction required and high integrity impact on cookie attributes. The score does not award severity for confidentiality or availability impact because the vulnerability is confined to cookie attribute injection, not data exfiltration or denial of service. However, in real-world deployments, the integrity impact (hijacking session scope, weakening protections) often cascades into authentication bypass and unauthorized access, warranting urgent remediation despite the base score not being Critical.

Frequently asked questions

Does this affect server-side cookie handling in Node.js?

Yes, if a Node.js application uses js-cookie to manage cookies and passes untrusted JSON objects to set(), the vulnerability applies. However, server-side cookie handling is less common; most Node.js apps use native modules like 'cookie' or 'http'. Verify your dependency tree to confirm js-cookie usage.

Can I safely use js-cookie if I never call set() with JSON-parsed input?

The risk is significantly lower if set() always receives hand-constructed option objects. However, upgrading to 3.0.7 eliminates the risk entirely and is recommended as a belt-and-suspenders approach. Refactoring to avoid JSON parsing is fragile and relies on developer discipline.

What should I do if I can't upgrade immediately?

Implement a pre-flight filter: before passing any object to js-cookie's set(), check for __proto__ and delete it, or use Object.fromEntries(Object.entries(untrustedObject)) to rebuild the object without prototype pollution. Additionally, review where untrusted JSON is being parsed and consider eliminating that pathway.

Is there a way to detect if my application has been exploited?

Check browser storage and Network tab for Set-Cookie headers with unexpected domain=, secure, or samesite values. Server-side, audit cookie logs for attributes that differ from your configuration. If compromised, clear affected sessions and rotate relevant credentials.

This analysis is provided for informational purposes and represents SEC.co's assessment based on publicly available information as of the publication date. CVSS scores and CWE classifications are sourced from the CVE record and may be refined by vendors or researchers over time. Organizations should verify patch availability and compatibility in their specific environment before deployment. This vulnerability has not been added to CISA's Known Exploited Vulnerabilities catalog as of the analysis date, but exploitation likelihood is high. For the most current vendor advisories and patch information, consult the maintainer's security documentation. Source: NVD (public-domain), retrieved 2026-07-20. Analysis generated by SEC.co (claude-haiku-4-5).