Improper Control of Generation of Code ('Code Injection') in lodash
CVE-2026-4800
- lodash
Summary
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. Additionally, do not pass untrusted input as key names in "options.imports". Only use developer-controlled, static key names, if upgrading to a fixed version is not possible. All versions from 4.0.0 prior to 4.18.0 are affected.
- LOW
- NETWORK
- HIGH
- UNCHANGED
- NONE
- NONE
- HIGH
- HIGH
CWE-94 - Code Injection
Code injection is a type of vulnerability that allows an attacker to execute arbitrary code. This vulnerability fully compromises the machine and can cause a wide variety of security issues, such as unauthorized access to sensitive information, manipulation of data, denial of service attacks etc. Code injection is different from command injection in the fact that it is limited by the functionality of the injected language (e.g. PHP), as opposed to command injection, which leverages existing code to execute commands, usually within the context of a shell.
References
Advisory Timeline
- Published