handlebars
cpe:2.3:a:handlebars.js_project:handlebars.js:*:*:*:*:node.js:*:*
- >= 4.0.0, <= 4.7.8
A vulnerability in Handlebars versions 4.0.0 through 4.7.8 allows for prototype pollution, which can lead to cross-site scripting (XSS) attacks. The issue arises in the Handlebars runtime, specifically within the `resolvePartial()` function. This function resolves partial names by directly accessing `options.partials` without any safeguards against prototype-chain traversal. If an attacker can inject a string value into `Object.prototype` that corresponds to a partial reference in a template, the injected string will be rendered as the partial body without HTML escaping. This vulnerability can be exploited to execute scripts in the context of the user.
Exploitation of this vulnerability allows for prototype pollution, which can be used to inject malicious payloads into the application. When these payloads are executed, they can lead to cross-site scripting (XSS) attacks, where an attacker can execute scripts in the context of the user's browser.
To reproduce this vulnerability, first, inject a string value into `Object.prototype` that matches a partial reference used in a Handlebars template. This can be done by adding a property to `Object.prototype` with a string value, such as an image tag with an XSS payload. Next, compile a Handlebars template that references the polluted prototype property as a partial. When the template is rendered, the injected payload will be executed as an XSS attack.
Users can upgrade to Handlebars version 4.7.9 or later, where this vulnerability has been patched. Alternatively, the Handlebars runtime-only build can be used, which does not compile templates and reduces the attack surface.
Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.