
Key points
- Versions 4.0.0 through 4.7.9 of the npm handlebars package are vulnerable to CVE-2026-106446.
- The flaw allows arbitrary JavaScript execution when untrusted objects are passed to compile functions.
- Applications using only template strings are not affected by this specific vulnerability.
Security operations teams should assess their dependency trees immediately, as a critical remote code execution vulnerability has been identified in the popular Handlebars templating library. The flaw, tracked as CVE-2026-106446, allows attackers to inject and execute arbitrary JavaScript code if an application passes untrusted data structures to the library’s compilation functions.
The vulnerability exists in versions 4.0.0 through 4.7.9 of the npm handlebars package. A patched version, 4.7.10, is available to resolve the issue. The flaw was disclosed via GitHub advisory GHSA-8r5x-fm3f-whwj and is rated as critical severity. It represents a significant regression in security controls, effectively bypassing validation mechanisms that were introduced in version 4.7.9 to address previous issues.
Context and Background
The vulnerability stems from incomplete validation of abstract syntax trees (ASTs) within `Handlebars.compile()` and `Handlebars.precompile()`. While version 4.7.9 added checks for specific node types—namely `PathExpression`, `NumberLiteral`, and `BooleanLiteral`—the compiler still processes other AST values without scrutiny.
According to the advisory, the validator overlooks plain objects that lack a `type` property, as well as strings and other non-object values. The compiler then writes these unchecked values directly into the generated JavaScript code. For instance, a `Program` object with a manipulated `blockParams` length can inject code that runs on the server during template rendering. Similarly, if the `stringParams` option is enabled, manipulated `StringLiteral` or `PathExpression` values can result in raw JavaScript literals being embedded in the output.
This bypass undermines previous fixes for GHSA-2w6w-674q-4c4q, GHSA-xhpv-hc6g-r9c6, and GHSA-3mfm-83xf-c92r. The advisory notes that the first exploitation vector works with default options, making it accessible to a wider range of applications.
Who Is Affected
The impact depends entirely on how an application interacts with the Handlebars library. Applications that exclusively pass template strings to the compilation functions are not affected by this vulnerability.
However, any application that passes an untrusted object—such as a parsed JSON request body—to `compile()` or `precompile()` is at risk. If an attacker can control the structure of this object, they can embed malicious JavaScript. With `compile()`, this code executes on the server. With `precompile()`, the malicious code is embedded in the precompiled output and executes wherever that output is loaded, potentially affecting client-side environments.
Our take on the response
The release of version 4.7.10 provides a clear mitigation path. Security teams must verify that their applications are not inadvertently passing structured data objects to Handlebars when only string templates are intended. The complexity of the AST structure means that even indirect data flows could expose systems to this flaw if validation is not strictly enforced at the input stage.
What to do and how to stay safe: Handlebars
- Audit your application code to identify any instances where `Handlebars.compile()` or `Handlebars.precompile()` receive objects derived from user input or external APIs.
- Ensure that only string templates are passed to these functions; reject or sanitize any incoming data structures that resemble AST nodes before processing.
- Update the handlebars npm package to version 4.7.10 or later to apply the vendor-provided fix for CVE-2026-106446.
- Monitor server logs for unusual JavaScript execution patterns or unexpected template rendering behaviour that may indicate exploitation attempts.
Step-by-step guide: Out-of-Band Patches: How Emergency Updates Prevent Downtime
General security guidance from the Breach Observer newsroom. It is not confirmed advice from the organisations named in this story.
Frequently asked questions
Is my application affected if I only use string templates with Handlebars?
No, applications that only ever pass template strings to the compilation functions are not affected by this vulnerability.
Which versions of Handlebars are vulnerable to CVE-2026-106446?
Versions 4.0.0 through 4.7.9 of the npm handlebars package are vulnerable.
What is the recommended fix for this critical vulnerability?
Users should update to Handlebars version 4.7.10, which includes the necessary patches to prevent AST validation bypasses.