CVE-2026-33941 Handlebars.js has JavaScript Injection in CLI Precompiler via Unescaped Names and Options

High 8.3 Published Updated

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.

Weakness: CWE-94, CWE-79, CWE-116

Which versions are affected by CVE-2026-33941?

2 open source packages ship an affected version, including handlebars. It affects 1 product.

PackageAffectedFixed in
handlebars npmFrom 4.0.04.7.9
handlebars npmFrom 4.0.04.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.

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.

Is CVE-2026-33941 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free