CVE-2026-33916: Handlebars.js Prototype Pollution Leading to XSS through Partial Template Injection

handlebars Updated 27 Mar 2026

Summary

26/03/2026
Yes i
Moderate
4.7

CVE-2026-33916: Handlebars.js has Prototype Pollution Leading to XSS through Partial Template Injection. Affects handlebars versions >= 4.0.0, < 4.7.9. Fixed in 4.7.9. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Handlebars.js is a popular templating engine for JavaScript that allows developers to create dynamic HTML content by embedding expressions within templates. It is widely used in web applications to separate HTML generation from JavaScript logic. However, it has a vulnerability that allows for prototype pollution, which can lead to cross-site scripting (XSS) attacks if not addressed.

Vulnerability Detail

The vulnerability arises from the resolvePartial() function in the Handlebars runtime, which resolves partial names through a direct property lookup on options.partials without checking for prototype-chain traversal. If an attacker can manipulate Object.prototype to include a key that matches a partial reference in a template, the application may render a polluted string as the partial body without HTML escaping. This can result in reflected or stored XSS, allowing attackers to execute arbitrary JavaScript in the context of the user's browser.

How To Fix

Latest published version: 4.7.10 as of 22 Oct 2026

npm install handlebars@4.7.10

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.7.9

This is the first release that contains the fix.

npm install handlebars@4.7.9

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, you can apply Object.freeze(Object.prototype) early in your application startup to prevent prototype pollution. However, be aware that this may break compatibility with other libraries that rely on modifying the prototype.

Conclusion

The Handlebars.js vulnerability (CVE-2026-33916) poses a significant risk due to its potential for prototype pollution and subsequent XSS attacks. It is crucial for developers using Handlebars to update to the patched version 4.7.9 or later and consider implementing the provided workarounds to mitigate the risk until they can update.

See every vulnerability recorded for handlebars →

Share this vulnerability

FAQ

Prototype pollution is a security vulnerability that allows an attacker to modify the prototype of built-in objects in JavaScript, potentially leading to unexpected behavior or security issues in applications.

An attacker can exploit this vulnerability by injecting a key into Object.prototype that matches a partial reference in a Handlebars template, allowing them to execute arbitrary JavaScript code.

The consequences include the potential for cross-site scripting (XSS) attacks, where an attacker can execute malicious scripts in the context of a user's browser, leading to data theft or session hijacking.

You can check if your application is affected by using Vulert, which monitors open-source vulnerabilities in your software. Visit Vulert Scanner to analyze your package-lock.json without needing to sign up.

The CVSS score of this vulnerability is 4.7, indicating a moderate severity level.

Related vulnerabilities

Recent vulnerabilities recorded for handlebars.

How To Fix

Latest published version: 4.7.10 as of 22 Oct 2026

npm install handlebars@4.7.10

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.7.9

This is the first release that contains the fix.

npm install handlebars@4.7.9

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback