Back to Blog
high SEVERITY3 min read

CVE-2026-4800: lodash Template Imports Allow Code Execution

CVE-2026-4800 affects lodash's `_.template()` templating API, where untrusted input reaching the `imports` option can lead to arbitrary code execution. The fix was shipped as a dependency upgrade from lodash 4.17.21 to 4.18.1 in the project's lockfile, though the PR itself notes it was never verified against the actual code paths in this repository.

O
By Orbis AppSec
•Technically reviewed by Anupam Mediratta•Published October 8, 2026•Reviewed October 8, 2026

Answer Summary

lodash versions up to and including 4.17.21 (the exact vulnerable range is unknown per the advisory) expose `_.template()`'s `imports` option to abuse when untrusted strings reach the templating engine. An attacker who controls the template source or the variables passed through `imports` can get lodash to compile and execute arbitrary JavaScript inside the host process. The fix, tracked as CVE-2026-4800, is addressed by upgrading lodash to 4.18.1 in the dependency lockfile. The CWE classification is unknown — it has not been published for this advisory.

Vulnerability at a Glance

cweunknown
fixDependency upgrade — lodash bumped to 4.18.1 (lockfile), carrying upstream's patch for CVE-2026-4800
riskUntrusted input compiled through `_.template()` can execute attacker-controlled JavaScript in the host application
languageJavaScript (npm)
root cause`_.template()`'s `imports` option builds a compiled function from input that was not sufficiently restricted in lodash 4.17.21
vulnerabilityArbitrary code execution via lodash template imports

Introduction

lodash's _.template() function compiles a string into an executable JavaScript function — that's the whole point of it. It accepts an imports option that lets callers inject named variables into the compiled function's scope. CVE-2026-4800 describes exactly the failure mode you'd expect from that design: when untrusted input is allowed to flow into the template string or into the imports map, lodash can end up compiling and running attacker-supplied JavaScript rather than the developer's intended template.

This matters for a very ordinary category of application code: anything that builds HTML, email bodies, config snippets, or report output by handing user-influenced strings to a templating helper. If that helper is lodash's _.template(), and the imports option (or the template body itself) is reachable by request data, the templating engine becomes a code-execution primitive instead of a string formatter.

The remediation that landed here is a dependency bump, not a first-party code change — the project's own code wasn't touched at all. The pull request upgrades lodash in the lockfile and flags, in its own description, that the author "has not verified that your code reaches the affected function." That caveat is worth taking seriously, and we'll come back to it.

Affected Versions

Affected unknown
Fixed in unknown
Ecosystem npm
CVE / GHSA CVE-2026-4800 / not assigned
CWE unknown

No GHSA advisory has been assigned yet, and the precise vulnerable version range for lodash hasn't been published at the time of this fix. What is known from the dependency tree: the project was pinned to lodash 4.17.21 before this change.

The Vulnerability Explained

The underlying flaw lives inside lodash itself — specifically in how _.template() handles the imports option when building its compiled function. Conceptually, _.template() works by stitching caller-provided pieces (the template string, variable names from imports) into source code that it then evaluates. If any of those pieces originate from untrusted input — a template body sourced from user content, or imports keys/values built from request data — the compiled function can contain logic the developer never intended, including code that executes arbitrary statements.

The lockfile shows exactly where the vulnerable version sat in this project's dependency tree:

"node_modules/lodash": {
-      "version": "4.17.21",
+      "version": "4.18.1",

Nothing else in this repository's own code changed — the exposure, if any, lived entirely inside lodash's packaged source for _.template(), not in application logic.

Attack scenario: picture a service that lets users customize a notification message, and the backend renders that customization with _.template(), passing in some computed values through imports for convenience. If the service doesn't strictly separate "static template defined by the developer" from "user-supplied content," an attacker who can influence the template string or the imports map could smuggle in a payload that lodash compiles into executable code. The result isn't a cross-site scripting issue confined to a browser — it's code execution inside whatever process is running _.template(), which could be a Node.js backend with filesystem and network access.

The Fix

Because the vul

Prevention and further reading

Frequently Asked Questions

Does the lockfile diff for this fix match the version named in the PR title?

Not exactly — the PR title says lodash is upgraded to 4.18.0, but the lockfile diff actually bumps the `version` field to 4.18.1. Confirm which release lands in your tree before closing the ticket.

Which lodash function is implicated by CVE-2026-4800?

The advisory description points to `_.template()` and its `imports` option, the mechanism lodash uses to inject variables into a compiled template function.

Is upgrading lodash from 4.17.21 enough to confirm I was exposed?

No — the PR explicitly states it did not verify that this codebase's calls actually reach the affected function, so you still need to check for `_.template()` usage with dynamic imports or template strings before assuming impact.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #5

Related Articles

critical

proxy-addr 2.0.7 IP Spoofing: CVE-2026-90711 Trust Bypass

A critical vulnerability in proxy-addr 2.0.7 allowed attackers to spoof client IP addresses by manipulating X-Forwarded-For headers when the trust chain evaluation contained specific misconfigurations. The fix in version 2.0.8 hardens the trust evaluation logic to prevent IP address falsification in Express.js applications relying on this common middleware dependency.

high

TweenMax `_applyCycle` Prototype Pollution via vars.cycle Keys

A bundled copy of the TweenMax animation library copied attacker-influenceable `vars.cycle` property names straight onto a tween configuration object using an unguarded `for...in` loop, so a key named `__proto__`, `constructor`, or `prototype` was written through to the object's prototype chain. The fix adds an explicit key denylist to both copies of the `_applyCycle` helper so those three names are skipped during the merge. No CVE or GHSA is assigned; the issue is tracked as CWE-1321 (Improperl

high

picomatch 2.3.1 ReDoS: Extglob Pattern Catastrophic Backtracking

picomatch versions below 2.3.2, 3.0.2, or 4.0.4 contain a Regular Expression Denial of Service vulnerability in extglob pattern parsing. An attacker can cause catastrophic backtracking with patterns containing nested alternations and quantifiers, freezing any Node.js process that evaluates untrusted glob expressions.

critical

pet-window.js Dynamic Code Evaluation: CWE-94 Hardening via Number

The pet-window module constructed dynamic JavaScript by embedding raw configuration values into code strings. An attacker with local access could inject arbitrary JavaScript by modifying stored configuration. The fix replaces string interpolation with explicit Number() coercion and NaN validation for all numeric configuration parameters.

high

sanitizeUnicodeInput(): Fullwidth U+ Bypasses Codepoint Validation

The `sanitizeUnicodeInput()` helper used by the project character-range settings screen rewrote `U+` prefixes to `0x` and called `parseInt()`, but never normalized its argument first. Compatibility-equivalent forms such as fullwidth `U+`, superscript digits, or mathematical alphanumerics never matched the `/U\+/gi` regex, fell through to the `else return inputString` branch, and were handed back to callers verbatim as "sanitized" values. The fix inserts a `String.prototype.normalize('NFKC')` pas

high

sanitizeBangumiHtml() XSS Fix: insertAdjacentHTML RCE via JSON

A high-severity cross-site scripting vulnerability existed where untrusted JSON data from bangumis.json was rendered directly into the DOM using insertAdjacentHTML without sanitization. An attacker who could modify this external data source could execute arbitrary JavaScript in visitors' browsers. The fix introduces a dedicated sanitizeBangumiHtml() function that strips script tags, event handlers, and javascript: URLs before insertion.