CVE-2026-33940: Handlebars.js has JavaScript Injection via AST Type Confusion when passing an object as dynamic partial
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, a crafted object placed in the template context can bypass all conditional guards in `resolvePartial()` and cause `invokePartial()` to return `undefined`. The Handlebars runtime then treats the unresolved partial as a source that needs to be compiled, passing the crafted object to `env.compile()`. Because the object is a valid Handlebars AST containing injected code, the generated JavaScript executes arbitrary commands on the server. The attack requires the adversary to control a value that can be returned by a dynamic partial lookup. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). Without `compile()`, the fallback compilation path in `invokePartial` is unreachable. Second, sanitize context data before rendering: Ensure no value in the context is a non-primitive object that could be passed to a dynamic partial. Third, avoid dynamic partial lookups (`{{> (lookup ...)}}`) when context data is user-controlled.
Security readout for executives and security teams
Plain-English summary
Affected servers may execute attacker-supplied code when vulnerable Handlebars versions render specially crafted data through dynamic partials. Exploitation requires a particular application pattern, so installation alone does not establish exploitability. Successful compromise could expose data, alter systems, or disrupt service. Handlebars 4.7.9 fixes the flaw.
Executive priority
Prioritize rapid investigation for externally reachable server applications using affected Handlebars versions. Remediate immediately where untrusted data can influence dynamic partials; otherwise schedule a prompt upgrade because future code changes could expose the dangerous path. Treat confirmed reachable conditions as a high-impact server compromise risk.
Technical view
Handlebars 4.0.0 through 4.7.8 can misclassify a crafted context object during dynamic partial resolution. After resolvePartial() guards are bypassed, invokePartial() reaches fallback compilation and passes the object to env.compile(). If it is a valid malicious Handlebars AST, generated JavaScript can execute arbitrary server-side commands.
Likely exposure
Exposure requires the full compiler-capable Handlebars build, an affected version, dynamic partial lookup, and attacker influence over a value returned by that lookup. Applications using only precompiled templates with the runtime-only build are covered by the documented workaround. Internet reachability increases concern but is not itself proof of exploitability.
Exploitation context
The supplied record assigns CVSS 3.1 score 8.1: network-accessible, unauthenticated, no user interaction, high complexity, and high confidentiality, integrity, and availability impact. KEV is false, and the provided sources do not establish active exploitation. No public exploitation status should be inferred beyond that evidence.
Researcher notes
The core issue combines type confusion (CWE-843) with code injection (CWE-94). Exploitability depends on reaching fallback compilation with a crafted object accepted as an AST. The supplied evidence names no indicators of compromise and does not confirm exploitation in the wild. Validate actual data flow rather than relying only on dependency presence.
Mitigation direction
Upgrade Handlebars to version 4.7.9 or later.
Use the runtime-only build where full template compilation is unnecessary.
Avoid dynamic partial lookups when rendering user-controlled context data.
Reject non-primitive context values that could reach dynamic partial resolution.
Review applicable Red Hat advisories for packaged or vendor-managed deployments.
Validation and detection
Inventory direct and transitive Handlebars versions in deployed applications.
Confirm whether deployments use the full build or runtime-only build.
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 · low confidence lookup
CWE-843: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. 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.
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-843 · source CWE mapping
Access of Resource Using Incompatible Type ('Type Confusion')
Access of Resource Using Incompatible Type ('Type Confusion') 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.