CVE-2026-33941 Handlebars.js has JavaScript Injection in CLI Precompiler via Unescaped Names and Options
Attackers can inject arbitrary JavaScript into Handlebars.js CLI precompiler output via unescaped filenames or options, leading to code execution.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Local or same network only
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2026-33941?
CVE-2026-33941 is a high-severity code injection vulnerability in handlebars-lang handlebars.js, published on 27 Mar 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Official description
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, the Handlebars CLI precompiler (`bin/handlebars` / `lib/precompiler.js`) concatenates user-controlled strings — template file names and several CLI options — directly into the JavaScript it emits, without any escaping or sanitization. An attacker who can influence template filenames or CLI arguments can inject arbitrary JavaScript that executes when the generated bundle is loaded in Node.js or a browser. Version 4.7.9 fixes the issue. Some workarounds are available. First, validate all CLI inputs before invoking the precompiler. Reject filenames and option values that contain characters with JavaScript string-escaping significance (`"`, `'`, `;`, etc.). Second, use a fixed, trusted namespace string passed via a configuration file rather than command-line arguments in automated pipelines. Third, run the precompiler in a sandboxed environment (container with no write access to sensitive paths) to limit the impact of successful exploitation. Fourth, audit template filenames in any repository or package that is consumed by an automated build pipeline.
Which versions are affected by CVE-2026-33941?
2 open source packages ship an affected version, including handlebars. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
handlebars npm | From 4.0.0 | 4.7.9 |
handlebars npm | From 4.0.0 | 4.7.9 |
Products include Handlebarsjs Handlebars.
How do I fix CVE-2026-33941?
Upgrade handlebars to 4.7.9 or later.
Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.
Is CVE-2026-33941 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-33941 exists.
Other vulnerabilities in handlebars-lang handlebars.js
- CVE-2026-33937 Handlebars.js has JavaScript Injection via AST Type Confusion
- CVE-2026-33938 Handlebars.js has JavaScript Injection via AST Type Confusion by tampering @partial-block
- CVE-2026-33940 Handlebars.js has JavaScript Injection via AST Type Confusion when passing an object as dynamic partial
- CVE-2019-20920 Arbitrary Code Execution in Handlebars
- CVE-2026-33939 Handlebars.js has Denial of Service via Malformed Decorator Syntax in Template Compilation
Sources
Also known as CLEANSTART-2026-IF99885, CLEANSTART-2026-SZ10382, DEBIAN-CVE-2026-33941, GHSA-xjpj-3mr7-gcpf, MINI-2fq2-pv58-m848, MINI-5h5g-6g95-p5w6 and 14 more.