Cyber Resilience

CVE-2026-33940

RCE in Handlebarsjs Handlebars 4.0.0 – 4.7.9

Published
27 March 2026
Modified
15 July 2026
Patch / advisory
CVSS Score v3.1 8.1
Click a component to see what it means
Raw vectorCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
EPSS Score 0.0070 50th percentile
Risk Priority 61 floored blend · peak EPSS

Summary

CVE-2026-33940 is a high-severity Code Injection (CWE-94) vulnerability in Handlebarsjs Handlebars. Its CVSS base score is 8.1 (High).

Operationally, exploitation aligns with the MITRE ATT&CK technique Command and Scripting Interpreter (T1059); ranked in the top 50% of CVEs by exploit likelihood; it is not currently listed in the CISA KEV catalog; a public proof-of-concept is referenced.

The strongest mitigations our analysis identified map to SA-11 (Developer Testing and Evaluation) and SI-10 (Information Input Validation) — see the control section below for these in your framework.

Deeper analysis AI-assisted summary

Synthesised by an AI model from the NVD description and linked references — a reading aid, not an authoritative source.

CVE-2026-33940 is a high-severity vulnerability (CVSS 3.1 score of 8.1) affecting Handlebars.js, a templating engine used for building semantic templates, specifically in versions 4.0.0 through 4.7.8. The issue stems from a crafted object placed in the template context that bypasses all conditional guards in the `resolvePartial()` function. This causes `invokePartial()` to return `undefined`, prompting the Handlebars runtime to treat the unresolved partial as a compilable source and pass the object to `env.compile()`. As the object is a valid Handlebars Abstract Syntax Tree (AST) with injected code, it results in the generation and execution of arbitrary JavaScript on the server, tied to CWE-94 (code injection) and CWE-843 (type confusion).

A remote attacker (AV:N, PR:N) can exploit this vulnerability over the network with high attack complexity (AC:H) by controlling a value returned by a dynamic partial lookup, such as in expressions like `{{> (lookup ...)}}` where the context data is user-controlled. Successful exploitation grants high confidentiality, integrity, and availability impacts (C:H/I:H/A:H), enabling arbitrary command execution on the server without user interaction (UI:N) in a single-instance context (S:U).

The vulnerability is fixed in Handlebars version 4.7.9, as detailed in the project's security advisory (GHSA-xhpv-hc6g-r9c6), release notes, and the fixing commit. Advisories recommend upgrading to the patched version and provide workarounds including: using the runtime-only build (`require('handlebars/runtime')`) to avoid the `compile()` fallback path; sanitizing context data to ensure no non-primitive objects are passed to dynamic partials; and avoiding dynamic partial lookups with user-controlled context data.

OWASP Top 10 for Web (2025)

EU & UK References

Vulnerability Data

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…

more

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.

CWE(s)

Related Threats

MITRE ATT&CK Enterprise Techniques

T1059 Command and Scripting Interpreter Execution
Adversaries may abuse command and script interpreters to execute commands, scripts, or binaries.
T1059.001 PowerShell Execution
Adversaries may abuse PowerShell commands and scripts for execution.
T1059.002 AppleScript Execution
Adversaries may abuse AppleScript for execution.
T1059.004 Unix Shell Execution
Adversaries may abuse Unix shell commands and scripts for execution.
T1059.005 Visual Basic Execution
Adversaries may abuse Visual Basic (VB) for execution.
T1059.006 Python Execution
Adversaries may abuse Python commands and scripts for execution.
Derived from this CVE’s CWE(s) via the direct CWE→ATT&CK cross-walk.

CVEs Like This One

CVE-2026-33937Same product: Handlebarsjs Handlebars
CVE-2026-33938Same product: Handlebarsjs Handlebars
CVE-2026-33941Same product: Handlebarsjs Handlebars
CVE-2025-29806Shared CWE-843, CWE-94
CVE-2026-44728Shared CWE-843, CWE-94
CVE-2024-7520Shared CWE-843, CWE-94
CVE-2026-55771Shared CWE-843, CWE-94
CVE-2026-1340Shared CWE-94
CVE-2024-54724Shared CWE-94
CVE-2013-3906Shared CWE-94

Affected Assets

handlebarsjs
handlebars
4.0.0 — 4.7.9

Mitigating Controls

Control response

Prevent
Stop it (NIST 800-53)

Detect
Catch it (NIST detect / respond)

Harden
Shrink the surface (DISA STIG)

Validate
Prove the fix (OWASP ASVS)
  • V1.5.2
  • V3.2.3
  • V15.3.5
  • V1.3.1

Mitigating Controls (NIST 800-53 r5) AI

Developer testing and evaluation finds code paths that accept and execute externally influenced strings.

Input validation directly stops untrusted data from being used to construct executable code without neutralization.

Least privilege limits the damage an injected code fragment can perform once executed.

Requiring documented secure development standards and tools enforces use of safe code-generation APIs and escaping.

Engineering principles can require use of type-safe languages, static typing, and runtime type checks that structurally avoid allocating one type and accessing another.

Memory-protection controls limit the blast radius when a type-confusion access occurs but do not stop the flaw itself.

Mitigating Controls (NIST CSF 2.0) AI

Derived directly from the weakness types (CWEs) cited in the NVD entry via our AI-authored CWE→CSF cross-walk (authority under review) — links open the control.

PR.PS-06 mostly match
prevents

PR.PS-06's SDLC practices directly target injection flaws via secure coding and testing (mostly), yet as a single broad outcome it leaves many code-generation specifics unaddressed (partial).

PR.DS-10 none match
prevents

PR.DS-10 protects runtime data confidentiality/integrity but has no bearing on neutralizing externally influenced input during code generation, so neither direction shows any preventive effect.

Mitigating Controls (ISO/IEC 27001:2022 Annex A) AI

Derived directly from the weakness types (CWEs) cited in the NVD entry via our AI-authored CWE→ISO cross-walk (authority under review) — links open the control.

finds

Security testing in development can detect type-confusion vulnerabilities through fuzzing and static analysis.

prevents

Secure SDLC mandates type-safe design and review that can catch type-confusion flaws.

prevents

Application security requirements can specify strong typing and interface contracts that reduce type confusion.

prevents

Secure architecture principles promote type-safe languages and memory-safety mechanisms that mitigate type confusion.

prevents

Banning unapproved code samples and unauthenticated web services, combined with secure-coding standards and SAST, prevents the dynamic generation or inclusion of attacker-supplied code.

none

Controls that restrict unauthorized or malicious code from being introduced via external networks or removable media limit opportunities for an attacker to inject and execute arbitrary code.

References