CVE-2026-33938: CWE-94: Improper Control of Generation of Code ('Code Injection') 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, the `@partial-block` special variable is stored in the template data context and is reachable and mutable from within a template via helpers that accept arbitrary objects. When a helper overwrites `@partial-block` with a crafted Handlebars AST, a subsequent invocation of `{{> @partial-block}}` compiles and executes that AST, enabling arbitrary JavaScript execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). The `compile()` method is absent, eliminating the vulnerable fallback path. Second, audit registered helpers for any that write arbitrary values to context objects. Helpers should treat context data as read-only. Third, avoid registering helpers from third-party packages (such as `handlebars-helpers`) in contexts where templates or context data can be influenced by untrusted input.
AI Analysis
Technical Summary
Handlebars.js versions 4.0.0 through 4.7.8 contain a vulnerability where the @partial-block special variable is accessible and mutable within templates via helpers that accept arbitrary objects. If a helper overwrites @partial-block with a crafted Handlebars AST, a later invocation of {{> @partial-block}} compiles and executes that AST, enabling arbitrary server-side JavaScript execution. This vulnerability is fixed in version 4.7.9. Mitigations include using the runtime-only build which lacks the compile() method, auditing helpers to prevent writing arbitrary values to context objects, and avoiding registration of third-party helpers in contexts influenced by untrusted input.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary JavaScript code on the server, leading to full compromise of the server environment. This can result in complete confidentiality, integrity, and availability loss of the affected system. The CVSS v3.1 score is 8.1 (High), reflecting network attack vector, high impact on confidentiality, integrity, and availability, and requiring no privileges or user interaction but with high attack complexity.
Mitigation Recommendations
An official fix is available in handlebars.js version 4.7.9. Users should upgrade to this version to remediate the vulnerability. If upgrading immediately is not possible, use the runtime-only build of handlebars.js which does not include the vulnerable compile() method. Additionally, audit all registered helpers to ensure they do not overwrite context data such as @partial-block with arbitrary values, and avoid registering third-party helpers in environments where templates or context data can be influenced by untrusted input.
CVE-2026-33938: CWE-94: Improper Control of Generation of Code ('Code Injection') 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, the `@partial-block` special variable is stored in the template data context and is reachable and mutable from within a template via helpers that accept arbitrary objects. When a helper overwrites `@partial-block` with a crafted Handlebars AST, a subsequent invocation of `{{> @partial-block}}` compiles and executes that AST, enabling arbitrary JavaScript execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). The `compile()` method is absent, eliminating the vulnerable fallback path. Second, audit registered helpers for any that write arbitrary values to context objects. Helpers should treat context data as read-only. Third, avoid registering helpers from third-party packages (such as `handlebars-helpers`) in contexts where templates or context data can be influenced by untrusted input.
CVSS v3.1
Score 8.1high
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 contain a vulnerability where the @partial-block special variable is accessible and mutable within templates via helpers that accept arbitrary objects. If a helper overwrites @partial-block with a crafted Handlebars AST, a later invocation of {{> @partial-block}} compiles and executes that AST, enabling arbitrary server-side JavaScript execution. This vulnerability is fixed in version 4.7.9. Mitigations include using the runtime-only build which lacks the compile() method, auditing helpers to prevent writing arbitrary values to context objects, and avoiding registration of third-party helpers in contexts influenced by untrusted input.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary JavaScript code on the server, leading to full compromise of the server environment. This can result in complete confidentiality, integrity, and availability loss of the affected system. The CVSS v3.1 score is 8.1 (High), reflecting network attack vector, high impact on confidentiality, integrity, and availability, and requiring no privileges or user interaction but with high attack complexity.
Mitigation Recommendations
An official fix is available in handlebars.js version 4.7.9. Users should upgrade to this version to remediate the vulnerability. If upgrading immediately is not possible, use the runtime-only build of handlebars.js which does not include the vulnerable compile() method. Additionally, audit all registered helpers to ensure they do not overwrite context data such as @partial-block with arbitrary values, and avoid registering third-party helpers in environments where templates or context data can be influenced by untrusted input.
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-33938","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:10175","vendor":"Red Hat"}]
Threat ID: 69c6f3473c064ed76ff618a6
Added to database: 03/27/2026, 21:14:47 UTC
Last enriched: 07/15/2026, 13:21:45 UTC
Last updated: 07/31/2026, 19:22:58 UTC
Views: 155
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.