Cyber Posture

CVE-2026-33940

HighPublic PoCRCE

Published: 27 March 2026

Published
27 March 2026
Modified
31 March 2026
KEV Added
Patch
CVSS Score 8.1 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
EPSS Score 0.0003 8.9th percentile
Risk Priority 16 60% EPSS · 20% KEV · 20% CVSS

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 Exploit Public-Facing Application (T1190); ranked at the 8.9th percentile by exploit likelihood (below the median); it is not currently listed in the CISA KEV catalog; a public proof-of-concept is referenced.

The strongest mitigations our analysis identified are NIST 800-53 SI-10 (Information Input Validation) and SI-2 (Flaw Remediation).

Threat & Defense at a Glance

What attackers do: exploitation maps to Exploit Public-Facing Application (T1190) and 1 other technique. What defenders deploy: see the NIST 800-53 controls recommended below.
Threat & Defense Details

Mitigating Controls (NIST 800-53 r5)AI

prevent

Directly mitigates the vulnerability by requiring timely application of the vendor patch (Handlebars 4.7.9) to remediate the code injection flaw.

prevent

Requires validation and sanitization of template context data to block crafted non-primitive objects that bypass resolvePartial guards and enable compilation of injected AST code.

prevent

Enforces secure configuration settings such as using the runtime-only Handlebars build to eliminate the compile fallback path exploited in dynamic partial lookups.

MITRE ATT&CK Enterprise TechniquesAI

T1190 Exploit Public-Facing Application Initial Access
Adversaries may attempt to exploit a weakness in an Internet-facing host or system to initially access a network.
T1059.007 JavaScript Execution
Adversaries may abuse various implementations of JavaScript for execution.
Why these techniques?

CVE enables remote exploitation of a public-facing templating engine (Handlebars) for server-side arbitrary JavaScript execution via crafted AST injection into dynamic partials/compile path.

Confidence: HIGH · MITRE ATT&CK Enterprise v18.1

NVD Description

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.

Deeper analysisAI

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.

Details

CWE(s)

Affected Products

handlebarsjs
handlebars
4.0.0 — 4.7.9

CVEs Like This One

CVE-2026-33938Same product: Handlebarsjs Handlebars
CVE-2026-33937Same product: Handlebarsjs Handlebars
CVE-2026-33941Same product: Handlebarsjs Handlebars
CVE-2026-33939Same product: Handlebarsjs Handlebars
CVE-2026-25887Shared CWE-94
CVE-2026-4800Shared CWE-94
CVE-2026-40911Shared CWE-94
CVE-2025-1302Shared CWE-94
CVE-2026-33943Shared CWE-94
CVE-2025-26260Shared CWE-94

References