CVE-2026-33941: Handlebars.js has JavaScript Injection in CLI Precompiler via Unescaped Names and Options
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.
Security readout for executives and security teams
Plain-English summary
CVE-2026-33941 affects the Handlebars.js CLI precompiler. If an attacker can influence template filenames or certain command-line options, they may cause malicious JavaScript to be placed into generated bundles and run later. The issue is high severity, fixed in Handlebars 4.7.9, and most urgent for build pipelines processing untrusted templates or packages.
Executive priority
Prioritize remediation for software supply chain and build systems first. The impact can be severe because injected JavaScript may execute in production bundles, but exploitation depends on attacker influence over precompiler inputs.
Technical view
Handlebars.js 4.0.0 through 4.7.8 concatenate user-controlled filenames and CLI options into emitted JavaScript without proper escaping. This creates JavaScript injection in bin/handlebars and lib/precompiler.js. Successful exploitation requires attacker control over precompiler inputs and later execution of the generated bundle in Node.js or a browser.
Likely exposure
Exposure is most likely in CI, packaging, or frontend build workflows that run the Handlebars CLI precompiler on templates from contributors, dependencies, uploads, or generated paths. Applications only using Handlebars runtime rendering are not shown as affected by the provided sources.
Exploitation context
The source bundle does not show CISA KEV listing or confirmed active exploitation. Exploitation requires influence over template filenames or CLI arguments, plus a user or automated system loading the generated JavaScript bundle.
Researcher notes
Focus analysis on precompile paths, not general template rendering unless sources show that path. The CVSS vector indicates local attack, low complexity, low privileges, required user interaction, changed scope, and high confidentiality, integrity, and availability impact.
Mitigation direction
Upgrade handlebars to version 4.7.9 or later.
Validate filenames and CLI option values before precompilation.
Reject values containing JavaScript string-escaping or statement separator characters.
Use a fixed trusted namespace from configuration, not user-controlled CLI input.
Run precompilation in a sandboxed environment with limited filesystem access.
Audit template filenames in repositories and packages consumed by builds.
Validation and detection
Inventory projects using handlebars versions 4.0.0 through 4.7.8.
Search build scripts and CI jobs for bin/handlebars or precompiler.js usage.
Confirm whether template filenames or CLI options can come from untrusted sources.
Verify dependency updates resolve to handlebars 4.7.9 or later.
Review generated bundles from untrusted inputs for unexpected JavaScript additions.
Check Red Hat advisories if relying on vendor-packaged handlebars components.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-116: User-session and phishing behavior lookup
Client-side and session-facing weaknesses should be reviewed alongside initial-access and user-execution behaviors. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Client-side and session-facing weaknesses should be reviewed alongside initial-access and user-execution behaviors. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Code execution and unsafe deserialization weaknesses often justify reviewing execution behavior and process telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The affected technology mentions containers, so container-specific ATT&CK technique review may help. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
5Timeline events
2ADP providers
9Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: pocAutomatable: noTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-116 · source CWE mapping
Improper Encoding or Escaping of Output
Improper Encoding or Escaping of Output represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Improper Control of Generation of Code ('Code Injection')
Improper Control of Generation of Code ('Code Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.