CVE-2026-106446: Handlebars: JavaScript Injection via AST Type Confusion in compile (Program.blockParams)
Handlebars provides the power necessary to let users build semantic templates. From 4.0.0 until 4.7.10, Handlebars.compile() and Handlebars.precompile() accept pre-parsed AST objects while validating only selected PathExpression, NumberLiteral, and BooleanLiteral values. This issue bypasses the AST validation introduced in version 4.7.9 for CVE-2026-33937. An attacker who can supply an object instead of a template string can place JavaScript expressions in unchecked values such as Program.blockParams.length, a non-PathExpression parameter depth, a non-string StringLiteral.value, or a non-string PathExpression.original. The compiler emits those values into generated JavaScript, causing code execution in the server process when compile output renders or wherever precompile output is loaded. Applications that pass only template strings are not affected. This issue is fixed in version 4.7.10.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Handlebarsto a version that resolves this vulnerability.Fixed in 4.7.10
Event History
Frequently Asked Questions
Which applications are actually exposed to this issue?
Applications are affected only if they pass attacker-controlled pre-parsed AST objects to Handlebars.compile() or Handlebars.precompile(). Applications that pass only template strings are not affected.
What does an attacker need to achieve code execution?
The attacker must be able to supply an object in place of a template string. They can use unchecked AST fields, including Program.blockParams.length, a non-PathExpression parameter depth, a non-string StringLiteral.value, or a non-string PathExpression.original, to cause JavaScript to be emitted.
When does the injected code execute?
Code execution occurs in the server process when generated output from compile() renders. For precompile(), execution occurs wherever the generated output is loaded.
What version fixes the issue?
Upgrade Handlebars to version 4.7.10. The affected range is from 4.0.0 until 4.7.10.