HIGH 8.1

CVE-2026-4800

lodash vulnerable to Code Injection via `_.template` imports key names

Description

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.

Affected Maven artifacts (7)

ArtifactAffected versionsFixed in
org.mvnpm » lodashvia npm lodash
>= 4.0.0, < 4.18.0
4.18.0
org.mvnpm » lodash-esvia npm lodash-es
>= 4.0.0, < 4.18.0
4.18.0
org.mvnpm » lodash.templatevia npm lodash.template
>= 4.0.0, < 4.18.0
4.18.0
org.webjars » lodashvia npm lodash
>= 4.0.0, < 4.18.0
4.18.0
org.webjars.npm » lodashvia npm lodash
>= 4.0.0, < 4.18.0
4.18.0
org.webjars.npm » lodash-esvia npm lodash-es
>= 4.0.0, < 4.18.0
4.18.0
org.webjars.npm » lodash.templatevia npm lodash.template
>= 4.0.0, < 4.18.0
4.18.0

Blast radius

7affected artifacts
84affected versions
222dependent artifacts (est.)
2,298dependent versions

46% of the dependent artifacts (104) still pull an affected version in their latest release.

DepthDependent versions
Direct
719
2 hops
1,019
3 hops
359
4 hops
183
5 hops
12
6 hops
6

Most used dependents

Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.

Other ecosystems

Also affects npm (4 packages) . See all on OSV

References

Advisorynvd.nist.gov
Advisorygithub.com
Packagegithub.com
Webgithub.com
Webgithub.com
Webcna.openjsf.org