Loading advisory.
Loading advisory.
lodash vulnerable to Code Injection via `_.template` imports key names
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.
Published 2026-03-31 19:25 UTC · Modified 2026-10-17 02:56 UTC
Severity and EPSS are shown separately. Helm does not combine them into one score.
| Package | Ecosystem | Affected | Fixed in | Upgrade command |
|---|---|---|---|---|
| lodash | npm | >= 4.0.0, < 4.18.0 | 4.18.0 | npm install lodash@4.18.0 |
| lodash-es | npm | >= 4.0.0, < 4.18.0 | 4.18.0 | npm install lodash-es@4.18.0 |
| lodash-amd | npm | >= 4.0.0, < 4.18.0 | 4.18.0 | npm install lodash-amd@4.18.0 |
| lodash.template | npm | >= 4.0.0, < 4.18.0 | 4.18.0 | npm install lodash.template@4.18.0 |
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().
Users should upgrade to version 4.18.0.
The fix applies two changes:
Validate importsKeys against the existing reForbiddenIdentifierChars regex (same check already used for the variable option)
Replace assignInWith with assignWith when merging imports, so only own properties are enumerated
Do not pass untrusted input as key names in options.imports. Only use developer-controlled, static key names.
Exploit code or a detection template for this CVE is published by the sources below. This is not a report of use against real systems (that is what CISA KEV records) and it does not change the tier.
EPSS went from 0.029 on 2026-11-24 to 0.031 on 2026-11-26, over 2 recorded scores.
| Date | Score | Previous | Model |
|---|---|---|---|
| 2026-11-24 | 0.029 | first score | v2026.06.15 |
| 2026-11-26 | 0.031 | 0.029 | v2026.06.15 |