GHSA-r5fr-rjxr-66jc CVE-2026-4800
lodash vulnerable to Code Injection via `_.template` imports key names
- Severity
- 8.1 / 10
- Critical · CVSS 3.1
- Exploit chance (EPSS)
- 2.81%
- Chance of exploitation in the next 30 days. Higher than 86.51% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Fix
- Available
- 4 packages have a fixed version
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:
- Validate
importsKeysagainst the existingreForbiddenIdentifierCharsregex (same check already used for thevariableoption) - Replace
assignInWithwithassignWithwhen 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 versions
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| lodash | >= 4.0.0, <= 4.17.23 |
No fix yet |
| lodash | >= 4.0.0, < 4.18.0 |
4.18.0 |
| lodash-amd | >= 4.0.0, <= 4.17.23 |
No fix yet |
| lodash-amd | >= 4.0.0, < 4.18.0 |
4.18.0 |
| lodash-es | >= 4.0.0, <= 4.17.23 |
No fix yet |
| lodash-es | >= 4.0.0, < 4.18.0 |
4.18.0 |
| lodash.template | >= 4.0.0, < 4.18.0 |
4.18.0 |
| lodash.template | >= 4.0.0, < 4.18.0 |
4.18.0 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
lodash npm → 4.18.0
- npm
npm install lodash@4.18.0- yarn
yarn add lodash@4.18.0- pnpm
pnpm add lodash@4.18.0
lodash-amd npm → 4.18.0
- npm
npm install lodash-amd@4.18.0- yarn
yarn add lodash-amd@4.18.0- pnpm
pnpm add lodash-amd@4.18.0
lodash-es npm → 4.18.0
- npm
npm install lodash-es@4.18.0- yarn
yarn add lodash-es@4.18.0- pnpm
pnpm add lodash-es@4.18.0
lodash.template npm → 4.18.0
- npm
npm install lodash.template@4.18.0- yarn
yarn add lodash.template@4.18.0- pnpm
pnpm add lodash.template@4.18.0
Severity breakdown
CVSS 3.1 8.1
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- High
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-94: Improper Control of Generation of Code ('Code Injection')
The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
How to prevent it
- Architecture and Design: Refactor your program so that you do not have to dynamically generate code.
- Architecture and Design: Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. To reduce the likelihood of code injection, use stringent allowlists that limit which constructs are allowed. If you are dynamically constructing code that invokes a function, then verifying that the input is alphanumeric might be insufficient. An attacker might still be able to reference a dangerous function that you did not intend to allow, such as system(), exec(), or exit().
- Testing: Use dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product's operation may slow down, but it should not become unstable, crash, or generate incorrect results.
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Operation: Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
- Implementation: For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures [REF-1372], so the python documentation discourages use of ast.literal_eval() on untrusted data [REF-1373].
References
Advisories
Fixes and patches
Packages
Other links
- cna.openjsf.org/security-advisories.html
- access.redhat.com/errata/RHBA-2026:21387
- access.redhat.com/errata/RHSA-2026:10131
- access.redhat.com/errata/RHSA-2026:10175
- access.redhat.com/errata/RHSA-2026:10710
- access.redhat.com/errata/RHSA-2026:10713
- access.redhat.com/errata/RHSA-2026:11454
- access.redhat.com/errata/RHSA-2026:11469
- access.redhat.com/errata/RHSA-2026:11470
- access.redhat.com/errata/RHSA-2026:11471
- access.redhat.com/errata/RHSA-2026:11493
- access.redhat.com/errata/RHSA-2026:11494
- access.redhat.com/errata/RHSA-2026:11495
- access.redhat.com/errata/RHSA-2026:11516
- access.redhat.com/errata/RHSA-2026:12277
- access.redhat.com/errata/RHSA-2026:12279
- access.redhat.com/errata/RHSA-2026:13545
- access.redhat.com/errata/RHSA-2026:13553
- access.redhat.com/errata/RHSA-2026:13571
- access.redhat.com/errata/RHSA-2026:13826
- access.redhat.com/errata/RHSA-2026:14870
- access.redhat.com/errata/RHSA-2026:14871
- access.redhat.com/errata/RHSA-2026:16874
- access.redhat.com/errata/RHSA-2026:17448
- access.redhat.com/errata/RHSA-2026:17468
- access.redhat.com/errata/RHSA-2026:17469
- access.redhat.com/errata/RHSA-2026:17547
- access.redhat.com/errata/RHSA-2026:17549
- access.redhat.com/errata/RHSA-2026:17550
- access.redhat.com/errata/RHSA-2026:17598
- access.redhat.com/errata/RHSA-2026:17789
- access.redhat.com/errata/RHSA-2026:19008
- access.redhat.com/errata/RHSA-2026:19167
- access.redhat.com/errata/RHSA-2026:19409
- access.redhat.com/errata/RHSA-2026:19410
- access.redhat.com/errata/RHSA-2026:19712
- access.redhat.com/errata/RHSA-2026:20041
- access.redhat.com/errata/RHSA-2026:20042
- access.redhat.com/errata/RHSA-2026:20943
- access.redhat.com/errata/RHSA-2026:20946
- access.redhat.com/errata/RHSA-2026:21658
- access.redhat.com/errata/RHSA-2026:22619
- access.redhat.com/errata/RHSA-2026:24331
- access.redhat.com/errata/RHSA-2026:24762
- access.redhat.com/errata/RHSA-2026:24977
- access.redhat.com/errata/RHSA-2026:29795
- access.redhat.com/errata/RHSA-2026:34100
- access.redhat.com/errata/RHSA-2026:34342
- access.redhat.com/errata/RHSA-2026:34608
- access.redhat.com/errata/RHSA-2026:36621
- access.redhat.com/errata/RHSA-2026:36651
- access.redhat.com/errata/RHSA-2026:37186
- access.redhat.com/errata/RHSA-2026:40118
- access.redhat.com/errata/RHSA-2026:40795
- access.redhat.com/errata/RHSA-2026:40945
- access.redhat.com/errata/RHSA-2026:40984
- access.redhat.com/errata/RHSA-2026:41928
- access.redhat.com/errata/RHSA-2026:41941
- access.redhat.com/errata/RHSA-2026:41944
- access.redhat.com/errata/RHSA-2026:42078
- access.redhat.com/errata/RHSA-2026:44235
- access.redhat.com/errata/RHSA-2026:48699
- access.redhat.com/errata/RHSA-2026:54188
- access.redhat.com/errata/RHSA-2026:56789
- access.redhat.com/errata/RHSA-2026:56854
- access.redhat.com/errata/RHSA-2026:56912
- access.redhat.com/errata/RHSA-2026:59833
- access.redhat.com/errata/RHSA-2026:60023
- access.redhat.com/errata/RHSA-2026:8483
- access.redhat.com/errata/RHSA-2026:8484
- access.redhat.com/errata/RHSA-2026:8490
- access.redhat.com/errata/RHSA-2026:8491
- access.redhat.com/errata/RHSA-2026:8493
- access.redhat.com/errata/RHSA-2026:8498
- access.redhat.com/errata/RHSA-2026:9385
- access.redhat.com/errata/RHSA-2026:9742
- access.redhat.com/security/cve/CVE-2026-4800
- bugzilla.redhat.com/show_bug.cgi
- security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-4800.json
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-f23m-r3pf-42rh lodash vulnerable to Prototype Pollution via array path bypass in `_.unset` and `_.omit` | Medium | Also affects lodash |
| GHSA-xxjr-mmjv-4gpg Lodash has Prototype Pollution Vulnerability in `_.unset` and `_.omit` functions | Medium | Also affects lodash |
| GHSA-29mw-wpgm-hmr9 Regular Expression Denial of Service (ReDoS) in lodash | Medium | Also affects lodash |
| GHSA-35jh-r3h4-6jhm Command Injection in lodash | High | Also affects lodash |
| GHSA-p6mc-m468-83gw Prototype Pollution in lodash | High | Also affects lodash |
| GHSA-x5rq-j2xg-h7qm Regular Expression Denial of Service (ReDoS) in lodash | Medium | Also affects lodash |
| GHSA-jf85-cpcp-j695 Prototype Pollution in lodash | Critical | Also affects lodash |
| GHSA-4xc9-xhrj-v574 Prototype Pollution in lodash | High | Also affects lodash |
Credits: M0nd0R, UlisesGascon, bugbunny-research, dolevmiz1, falsyvalues, jdalton, jonchurch, threalwinky
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor