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

Published Mar 31, 2026
·
Updated

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.

Other sources

Impact:

The fix for CVE-2021-23337 (https://github.com/advisories/GHSA-35jh-r3h4-6jhm) 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.

Workarounds:

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

MITRE

Affected Software

12 affected componentsFixes available
npm/lodash<4.18.0
npm/lodash.template>=4.0.0<4.18.0
4.18.0
npm/lodash-amd>=4.0.0<=4.17.23
4.18.0
npm/lodash-es>=4.0.0<=4.17.23
4.18.0
npm/lodash>=4.0.0<=4.17.23
4.18.0
debian/node-lodash<=4.17.21+dfsg+~cs8.31.173-1, <=4.17.21+dfsg+~cs8.31.198.20210220-9
4.18.1+dfsg-3
Lodash Lodash Node.js>=4.0.0<4.18.0
Lodash Lodash-amd Node.js>=4.0.0<4.18.0
Lodash Lodash-es Node.js>=4.0.0<4.18.0
Lodash Lodash.template Node.js>=4.0.0<4.18.0
IBM Db2 Genius Hub<=1.1, 1.1.1, 1.1.2
IBM Agentics<=1.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/lodash.template to a version that resolves this vulnerability.

    Fixed in 4.18.0
  2. Upgrade

    Upgrade npm/lodash-amd to a version that resolves this vulnerability.

    Fixed in 4.18.0
  3. Upgrade

    Upgrade npm/lodash-es to a version that resolves this vulnerability.

    Fixed in 4.18.0
  4. Upgrade

    Upgrade npm/lodash to a version that resolves this vulnerability.

    Fixed in 4.18.0
  5. Upgrade

    Upgrade debian/node-lodash to a version that resolves this vulnerability.

    Fixed in 4.18.1+dfsg-3
  6. Upgrade

    Upgrade lodash to a version that resolves this vulnerability.

    Fixed in 4.18.0
  7. Configuration

    Update lodash so that _.template validates options.imports key names (importsKeys) against the existing reForbiddenIdentifierChars regex; the CVE-2021-23337 fix only covered the variable option and needs the same validation for imports key names.

    lodash _.template options.imports key names (importsKeys) = Validate importsKeys against the existing reForbiddenIdentifierChars regex (same check already used for the variable option)
  8. Configuration

    Replace assignInWith with assignWith when merging imports, so only own properties are enumerated (prevents inherited/polluted keys from being copied into the imports object that is later passed to Function() ).

    lodash _.template imports merge implementation = Use assignWith instead of assignInWith when merging imports
  9. Compensating control

    Do not pass untrusted input as key names in options.imports.

Event History

Mar 31, 2026
CVE Published
via MITRE·07:25 PM
Data Sourced
via MITRE·07:25 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·08:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·08:16 PM
DescriptionSeverityWeaknessAffected Software
Apr 1, 2026
Advisory Published
via GitHub·11:51 PM
Data Sourced
via GitHub·11:51 PM
DescriptionSeverityWeaknessAffected Software
Jun 9, 2026
Data Sourced
via Debian·06:09 PM
DescriptionAffected Software
Data Sourced
via Launchpad·06:09 PM
Description
Jun 10, 2026
Data Sourced
via Ubuntu·06:08 PM
RemedyDescriptionSeverityAffected Software
Jul 13, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-4800?

CVE-2026-4800 is rated as a high severity vulnerability due to its potential for code injection.

2

How can I fix CVE-2026-4800?

To fix CVE-2026-4800, update lodash to version 4.18.1 or later, where the issue has been addressed.

3

What impact does CVE-2026-4800 have on my application?

CVE-2026-4800 allows attackers to execute arbitrary code within the context of the application that uses lodash's template function.

4

Which versions of lodash are affected by CVE-2026-4800?

Lodash versions before 4.18.1 are affected by CVE-2026-4800.

5

Is there a workaround for CVE-2026-4800?

There is no effective workaround for CVE-2026-4800 other than upgrading to a patched version of lodash.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203