Handlebars.js: JavaScript injection via AST type confusion in compile()
Summary
Handlebars.js versions 4.0.0 up to 4.7.9 accept pre-parsed AST objects in compile() and precompile() but validate only some AST values. An attacker who can supply an AST object instead of a template string can inject JavaScript that the compiler writes into generated code, leading to code execution in the server process. Applications that pass only template strings are not affected.
Affected
- handlebars.js from 4.0.0 up to and including 4.7.9
- Affected only if the application passes non-string AST objects to compile() or precompile()
- Check transitive dependencies in lock files; the range reported by one downstream audit starts at 3.0.0, which could not be confirmed
Fixed in
- handlebars.js 4.7.10 (released 5 October 2026)
- Precompiled templates must also be rebuilt with the fixed version
Workaround
- Allow only template strings to reach compile() and precompile() and reject all other input
- If templates are precompiled at build time, use the runtime-only build (handlebars/runtime) so that compile() is not available on the server
- These measures are interim only; patching is the complete fix
Exploitation
- CISA SSVC assessment: exploitation status 'poc', automatable: yes, technical impact: total
- No confirmed in-the-wild exploitation found; CISA KEV status unknown
- EPSS: 0.0064
- Exploitation requires that an application passes attacker-controlled objects, for example JSON from a request body, into the template compiler
Our recommendation
- Inventory all package-lock.json, yarn.lock and pnpm-lock.yaml files for handlebars below 4.7.10, including transitive and build-time dependencies
- Upgrade to 4.7.10 or later, including precompiled templates
- Review code paths that pass request data to compile() or precompile() and enforce string-only input until the upgrade is done
- Monitor the vendor advisory and CISA KEV for changes
Public exploits
PoC-in-GitHub, Metasploit and Exploit-DB list nothing for this CVE.
Research sources
- GitHub Security Advisory GHSA-8r5x-fm3f-whwj github.com
- Fix commit 703fdcc github.com
- Release v4.7.10 github.com
- Release notes v4.7.10 github.com
- Pull request #2185 github.com
- OSV entry CVE-2026-106446 osv.dev
- Red Hat CVE record access.redhat.com
- Tenable CVE record www.tenable.com
Researched and written up in English and German by an AI (Claude by Anthropic) based on NVD, CISA, EPSS and the sources listed. The vendor information is authoritative. Researched on 30 Oct 2026, 21:03.
Original description (NVD)
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.
NVD references (5)
- https://github.com/handlebars-lang/handlebars.js/commit/703fdcc5fd6cc8d1cc0c33cc19de40c467c4b8d2
- https://github.com/handlebars-lang/handlebars.js/pull/2185
- https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.10
- https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-8r5x-fm3f-whwj
- https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-8r5x-fm3f-whwj
Sources
The tracker combines official, freely usable data sources – updated continuously:
- NVD (NIST) – CVEs, rating (CVSS), affected products
- CISA KEV – vulnerabilities confirmed by CISA as actively exploited
- CISA Vulnrichment – CISA assessment (SSVC) in the official CVE record
- FIRST EPSS – probability of exploitation
- Microsoft MSRC – Patch Tuesday: vulnerabilities, severity, updates
- PoC-in-GitHub – public proof-of-concept repositories
- Metasploit (Rapid7) – modules of the Metasploit Framework
- Exploit-DB (OffSec) – archive of public exploits (links only)
- Patch days: official vendor pages (linked per vendor) (Vendor patch days)
This product uses data from the NVD API but is not endorsed or certified by the NVD. EPSS data © FIRST.org.
Affected? We can help.
We check whether your systems are affected, install updates and close the gap – continuously with the System Health Checker if you wish.
