CVE-2026-33916

Handlebars.js has Prototype Pollution Leading to XSS through Partial Template Injection

Published Mar 27, 2026 CVSS 3.1 · 4.7 Medium EPSS < 1% KEV · Not listed
Description
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, `resolvePartial()` in the Handlebars runtime resolves partial names via a plain property lookup on `options.partials` without guarding against prototype-chain traversal. When `Object.prototype` has been polluted with a string value whose key matches a partial reference in a template, the polluted string is used as the partial body and rendered without HTML escaping, resulting in reflected or stored XSS. Version 4.7.9 fixes the issue. Some workarounds are available. Apply `Object.freeze(Object.prototype)` early in application startup to prevent prototype pollution. Note: this may break other libraries, and/or use the Handlebars runtime-only build (`handlebars/runtime`), which does not compile templates and reduces the attack surface.

Analysis

AI-generated

Technical impact

Handlebars.js versions 4.0.0 through 4.7.8 allow an attacker to inject a specially crafted property into Object.prototype. When the runtime resolves a partial name, it performs a plain property lookup on options.partials without guarding against prototype‑chain traversal. If Object.prototype contains a string value whose key matches a partial reference, that string is used as the partial body and rendered without HTML escaping, leading to reflected or stored XSS. The weakness is a Prototype Pollution flaw (CWE‑1321) combined with a Reflected XSS condition (CWE‑79).

Affected Systems

The vulnerability affects projects that use Handlebars.js versions 4.0.0 through 4.7.8, including any Node.js applications that depend on the handlebars-lang:handlebars.js library. Versions starting at 4.7.9 are not impacted.

Risk and Exploitability

The CVSS score is 4.7, indicating a low to moderate severity, and the EPSS score is below 1%, suggesting a low exploitation probability in the wild. The vulnerability is not listed in the CISA KEV catalog. An attacker would need to supply a template that references the polluted partial name; once executed, the malicious payload can execute arbitrary JavaScript within the victim’s browser context. The attack can be carried out from the client side if an attacker controls template rendering, making it a practical risk in web applications that allow dynamic template injection.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Handlebars.js to version 4.7.9 or later.
  • If an upgrade is not immediately possible, add Object.freeze(Object.prototype) at application startup to prevent further prototype pollution.
  • Consider migrating to the Handlebars runtime‑only build (handlebars/runtime) which does not compile templates and reduces the attack surface.

Generated by OpenCVE AI on March 31, 2026 at 19:42 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-2qvq-rjwj-gvw9 Handlebars.js has Prototype Pollution Leading to XSS through Partial Template Injection
History
Type Values Removed Values Added
CPEs cpe:2.3:a:handlebarsjs:handlebars:*:*:*:*:*:node.js:*:*
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Handlebarsjs
Handlebarsjs handlebars
Vendors & Products Handlebarsjs
Handlebarsjs handlebars
Type Values Removed Values Added
Description Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, `resolvePartial()` in the Handlebars runtime resolves partial names via a plain property lookup on `options.partials` without guarding against prototype-chain traversal. When `Object.prototype` has been polluted with a string value whose key matches a partial reference in a template, the polluted string is used as the partial body and rendered without HTML escaping, resulting in reflected or stored XSS. Version 4.7.9 fixes the issue. Some workarounds are available. Apply `Object.freeze(Object.prototype)` early in application startup to prevent prototype pollution. Note: this may break other libraries, and/or use the Handlebars runtime-only build (`handlebars/runtime`), which does not compile templates and reduces the attack surface.
Title Handlebars.js has Prototype Pollution Leading to XSS through Partial Template Injection
Weaknesses CWE-1321
CWE-79
References
Metrics cvssV3_1

{'score': 4.7, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N'}

Weaknesses
  • CWE-1321

    Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

  • CWE-915

    Improperly Controlled Modification of Dynamically-Determined Object Attributes

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Mar 30, 2026, 3:41 PM
Reserved
Mar 24, 2026, 3:41 PM
Status
Analyzed
Published
Mar 27, 2026, 9:17 PM
Modified
Oct 26, 2026, 10:10 PM
Severity
Moderate
Public date
Mar 27, 2026, 9:00 PM