CVE-2021-23436: Immer prototype pollution via type confusion in applyPatches

CVE-2021-23436 · Severity: low · CVSS 3.1 · Published 2021-09-02

Immer is a popular JavaScript library used by developers to manage application state. A security flaw in the library allows an attacker to inject malicious properties into the base objects of a JavaScript application. This could lead to application crashes, unauthorized data access, or potentially full control over the affected system.

Technologies: immer (npm). Vendors: npm.

Quick answers

Is CVE-2021-23436 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2021-23436 being exploited in the wild.
How severe is CVE-2021-23436?
Low severity, with a CVSS score of 3.1, published 2 September 2021.
Which products and versions are affected?
immer (npm) SEMVER:introduced=7.0.0,fixed=9.0.6.
Is there a fix for CVE-2021-23436?
Yes. immer (npm): upgrade to 9.0.6 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2021-23436 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2021-23436?
Check whether you run immer (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • immer (npm): upgrade to 9.0.6 or later
    npm install immer@9.0.6

Technical details

A prototype pollution vulnerability exists in Immer versions 7.0.0 through 9.0.5 due to a type confusion flaw in the 'applyPatches' function. The library's security check for reserved keys like '__proto__' and 'constructor' uses strict equality (===), which can be bypassed if the user-provided path keys are wrapped in an array (e.g., [['__proto__']]). An attacker who can control the path parameter of a patch operation can inject properties into the Object prototype. This can result in Denial of Service (DoS), property injection, or Remote Code Execution (RCE) depending on the application environment. The issue is fixed in version 9.0.6.

Affected products

  • immerjs immer >=7.0.0 <9.0.6

Identifiers

  • CVE-2021-23436
  • GHSA-33f9-j839-rf8h

Timeline

  • 2021-08-12: disclosed: Vulnerability disclosed by Snyk Research Team
  • 2021-09-01: advisory: NVD and Snyk published advisories
  • 2021-09-02: patched: GitHub advisory published and fix confirmed in version 9.0.6

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.