CVE-2026-33937: CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') in handlebars-lang handlebars.js
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, `Handlebars.compile()` accepts a pre-parsed AST object in addition to a template string. The `value` field of a `NumberLiteral` AST node is emitted directly into the generated JavaScript without quoting or sanitization. An attacker who can supply a crafted AST to `compile()` can therefore inject and execute arbitrary JavaScript, leading to Remote Code Execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. Validate input type before calling `Handlebars.compile()`; ensure the argument is always a `string`, never a plain object or JSON-deserialized value. Use the Handlebars runtime-only build (`handlebars/runtime`) on the server if templates are pre-compiled at build time; `compile()` will be unavailable.
AI Analysis
Technical Summary
Handlebars.js versions 4.0.0 through 4.7.8 have a type confusion vulnerability (CWE-843) where the compile() function accepts a pre-parsed AST object. The value field of a NumberLiteral AST node is emitted directly into generated JavaScript code without quoting or sanitization, enabling an attacker with the ability to supply a crafted AST to perform remote code execution on the server. This vulnerability is tracked as CVE-2026-33937 and has a CVSS 3.1 score of 9.8 (critical). The issue is resolved in version 4.7.9. Mitigations include validating that the input to compile() is always a string and never a plain object, or using the runtime-only build on the server side to avoid using compile().
Potential Impact
Successful exploitation allows an unauthenticated attacker who can supply a crafted AST object to Handlebars.compile() to execute arbitrary JavaScript code remotely on the server, leading to full compromise of the server environment. The vulnerability affects confidentiality, integrity, and availability with a critical severity rating (CVSS 9.8).
Mitigation Recommendations
An official fix is available in Handlebars.js version 4.7.9. Users should upgrade to this version to remediate the vulnerability. Until upgrading, mitigate by validating input types before calling Handlebars.compile() to ensure the argument is always a string and not a deserialized object. Alternatively, use the Handlebars runtime-only build on the server if templates are pre-compiled at build time, which disables the compile() function and prevents exploitation.
CVE-2026-33937: CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') in handlebars-lang handlebars.js
Description
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, `Handlebars.compile()` accepts a pre-parsed AST object in addition to a template string. The `value` field of a `NumberLiteral` AST node is emitted directly into the generated JavaScript without quoting or sanitization. An attacker who can supply a crafted AST to `compile()` can therefore inject and execute arbitrary JavaScript, leading to Remote Code Execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. Validate input type before calling `Handlebars.compile()`; ensure the argument is always a `string`, never a plain object or JSON-deserialized value. Use the Handlebars runtime-only build (`handlebars/runtime`) on the server if templates are pre-compiled at build time; `compile()` will be unavailable.
CVSS v3.1
Score 9.8critical
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Handlebars.js versions 4.0.0 through 4.7.8 have a type confusion vulnerability (CWE-843) where the compile() function accepts a pre-parsed AST object. The value field of a NumberLiteral AST node is emitted directly into generated JavaScript code without quoting or sanitization, enabling an attacker with the ability to supply a crafted AST to perform remote code execution on the server. This vulnerability is tracked as CVE-2026-33937 and has a CVSS 3.1 score of 9.8 (critical). The issue is resolved in version 4.7.9. Mitigations include validating that the input to compile() is always a string and never a plain object, or using the runtime-only build on the server side to avoid using compile().
Potential Impact
Successful exploitation allows an unauthenticated attacker who can supply a crafted AST object to Handlebars.compile() to execute arbitrary JavaScript code remotely on the server, leading to full compromise of the server environment. The vulnerability affects confidentiality, integrity, and availability with a critical severity rating (CVSS 9.8).
Mitigation Recommendations
An official fix is available in Handlebars.js version 4.7.9. Users should upgrade to this version to remediate the vulnerability. Until upgrading, mitigate by validating input types before calling Handlebars.compile() to ensure the argument is always a string and not a deserialized object. Alternatively, use the Handlebars runtime-only build on the server if templates are pre-compiled at build time, which disables the compile() function and prevents exploitation.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-03-24T19:50:52.103Z
- Cvss Version
- 3.1
- State
- PUBLISHED
- Vendor Advisory Urls
- [{"url":"https://access.redhat.com/security/cve/CVE-2026-33937","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:10175","vendor":"Red Hat"}]
Threat ID: 69c6f3473c064ed76ff618a1
Added to database: 03/27/2026, 21:14:47 UTC
Last enriched: 07/15/2026, 13:22:00 UTC
Last updated: 07/31/2026, 19:22:58 UTC
Views: 448
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.