NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · npm

CVE-2026-4800: lodash vulnerable to Code Injection via `_.template` imports key names

highCVSS 3.1 8.1GHSA-r5fr-rjxr-66jc

Impact The fix for CVE-2021-23337 added validation for the variable option in .template but did not apply the same validation to options.imports key names. Both paths flow into the same Function() constructor sink. When an application passes untrusted input as options.imports key names, an attacker can inject default-parameter expressions that execute arbitrary code at template compilation time.

Published Apr 1, 2026

Affected packages

lodash

Ecosystem
npm
Affected
>= 4.0.0, <= 4.17.23
Fixed in
4.18.0
Check
npm ls lodash

lodash-es

Ecosystem
npm
Affected
>= 4.0.0, <= 4.17.23
Fixed in
4.18.0
Check
npm ls lodash-es

lodash-amd

Ecosystem
npm
Affected
>= 4.0.0, <= 4.17.23
Fixed in
4.18.0
Check
npm ls lodash-amd

lodash.template

Ecosystem
npm
Affected
>= 4.0.0, < 4.18.0
Fixed in
4.18.0
Check
npm ls lodash.template

Advisory details

From the GitHub Advisory Database (CC BY 4.0).

Impact

The fix for CVE-2021-23337 added validation for the variable option in _.template but did not apply the same validation to options.imports key names. Both paths flow into the same Function() constructor sink.

When an application passes untrusted input as options.imports key names, an attacker can inject default-parameter expressions that execute arbitrary code at template compilation time.

Additionally, _.template uses assignInWith to merge imports, which enumerates inherited properties via for..in. If Object.prototype has been polluted by any other vector, the polluted keys are copied into the imports object and passed to Function().

Patches

Users should upgrade to version 4.18.0.

The fix applies two changes:

  1. Validate importsKeys against the existing reForbiddenIdentifierChars regex (same check already used for the variable option)
  2. Replace assignInWith with assignWith when merging imports, so only own properties are enumerated

Workarounds

Do not pass untrusted input as key names in options.imports. Only use developer-controlled, static key names.

Credited to dolevmiz1, bugbunny-research, M0nd0R, UlisesGascon, falsyvalues, jonchurch, threalwinky, jdalton.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology

More npm vulnerabilities

All npm entries