CVE-2026-4800: Lodash Lodash Vulnerable To Code Injection Vulnerability

HIGH
Advisory Identifier: GHSA-r5fr-rjxr-66jc
CVSS 8.1
CWE-94
Published
Advisory Summary

CVE-2026-4800 is a HIGH (CVSS 8.1) lodash vulnerable to code injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Lodash libraries in the npm ecosystem. The issue involves lodash vulnerable to code injection via `_.template` imports key names. Remediation is available by upgrading affected packages to version 4.18.0.

CVE-2026-4800 at a Glance

CVE Identifier CVE-2026-4800
GHSA Identifier GHSA-r5fr-rjxr-66jc
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Lodash
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-4800

To remediate this vulnerability, upgrade all affected Lodash dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

lodash fixed: 4.18.0
npm install lodash@4.18.0
lodash-es fixed: 4.18.0
npm install lodash-es@4.18.0
lodash-amd fixed: 4.18.0
npm install lodash-amd@4.18.0
lodash.template fixed: 4.18.0
npm install lodash.template@4.18.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls lodash

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-4800, inspect your project dependencies using npm:

npm ls lodash

Analyze the terminal output to locate any version of Lodash in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.18.0), your application is affected.

Note: The npm ls lodash command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where 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. In Lodash, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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. 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.

CVE-2026-4800 Affected Lodash Versions

4 component(s)
Fixed Versions:
4.18.0
Product / Package Ecosystem Affected Versions Fixed Version
lodash
npm
≥ 4.0.0
< 4.18.0
4.18.0
lodash-es
npm
≥ 4.0.0
< 4.18.0
4.18.0
lodash-amd
npm
≥ 4.0.0
< 4.18.0
4.18.0
lodash.template
npm
≥ 4.0.0
< 4.18.0
4.18.0

References

Frequently Asked Questions

What is CVE-2026-4800?
CVE-2026-4800 is a security vulnerability in Lodash involving lodash vulnerable to Code Injection via `_.template` imports key names under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Lodash versions are affected?
Affected versions include releases prior to 4.18.0 across affected packages: lodash, lodash-es, lodash-amd, lodash.template.
What version fixes CVE-2026-4800?
Upgrading to 4.18.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is lodash affected?
Yes, lodash is affected in releases prior to 4.18.0. Upgrade your dependency to 4.18.0 or later.
Is lodash-es affected?
Yes, lodash-es is affected in releases prior to 4.18.0. Upgrade your dependency to 4.18.0 or later.
What is the CVSS score of CVE-2026-4800?
CVE-2026-4800 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-4800?
CVE-2026-4800 is classified under 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 can I check npm dependencies for CVE-2026-4800?
Run the dependency tree command: 'npm ls lodash'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r5fr-rjxr-66jc",
  "modified" : "2026-04-01T23:51:12Z",
  "published" : "2026-04-01T23:51:12Z",
  "aliases" : [ "CVE-2026-4800" ],
  "summary" : "lodash vulnerable to Code Injection via `_.template` imports key names",
  "details" : "### Impact\n\nThe 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.\n\nWhen 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.\n\nAdditionally, `_.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()`.\n\n### Patches\n\nUsers should upgrade to version 4.18.0.\n\nThe fix applies two changes:\n1. Validate `importsKeys` against the existing `reForbiddenIdentifierChars` regex (same check already used for the `variable` option)\n2. Replace `assignInWith` with `assignWith` when merging imports, so only own properties are enumerated\n\n### Workarounds\n\nDo not pass untrusted input as key names in `options.imports`. Only use developer-controlled, static key names.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.18.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.17.23"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash-es"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.18.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.17.23"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash-amd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.18.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.17.23"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash.template"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.18.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/lodash/lodash/security/advisories/GHSA-r5fr-rjxr-66jc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-4800"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lodash/lodash/commit/3469357cff396a26c363f8c1b5a91dde28ba4b1c"
  }, {
    "type" : "WEB",
    "url" : "https://cna.openjsf.org/security-advisories.html"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-35jh-r3h4-6jhm"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lodash/lodash"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-01T23:51:12Z",
    "nvd_published_at" : "2026-03-31T20:16:29Z"
  }
}