{"id":"CVE-2026-33916","aliases":["CVE-2026-33916","GHSA-2qvq-rjwj-gvw9"],"related":[],"kind":"vulnerability","state":"published","title":"Handlebars.js has Prototype Pollution Leading to XSS through Partial Template Injection","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"## Summary\n\n`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.\n\n## Description\n\nThe root cause is in `lib/handlebars/runtime.js` inside `resolvePartial()` and `invokePartial()`:\n\n```javascript\n// Vulnerable: plain bracket access traverses Object.prototype\npartial = options.partials[options.name];\n```\n\n`hasOwnProperty` is never checked, so if `Object.prototype` has been seeded with a key whose name matches a partial reference in the template (e.g. `widget`), the lookup succeeds and the polluted string is returned. The runtime emits a prototype-access warning, but the partial is still resolved and its content is inserted into the rendered output unescaped. This contradicts the documented security model and is distinct from CVE-2021-23369 and CVE-2021-23383, which addressed data property access rather than partial template resolution.\n\n**Prerequisites for exploitation:**\n1. The target application must be vulnerable to prototype pollution (e.g. via `qs`, `minimist`, or\n   any querystring/JSON merge sink).\n2. The attacker must know or guess the name of a partial reference used in a template.\n\n## Proof of Concept\n\n```javascript\nconst Handlebars = require('handlebars');\n\n// Step 1: Prototype pollution (via qs, minimist, or another vector)\nObject.prototype.widget = '<img src=x onerror=\"alert(document.domain)\">';\n\n// Step 2: Normal template that references a partial\nconst template = Handlebars.compile('<div>Welcome! {{> widget}}</div>');\n\n// Step 3: Render — XSS payload injected unescaped\nconst output = template({});\n// Output: <div>Welcome! <img src=x onerror=\"alert(document.domain)\"></div>\n```\n\n> The runtime prints a prototype access warning claiming \"access has been denied,\" but the partial still resolves and returns the polluted value.\n\n## Workarounds\n\n- Apply `Object.freeze(Object.prototype)` early in application startup to prevent prototype  pollution. Note: this may break other libraries.\n- Use the Handlebars runtime-only build (`handlebars/runtime`), which does not compile templates  and reduces the attack surface.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Handlebars proporciona la potencia necesaria para permitir a los usuarios construir plantillas semánticas. En las versiones 4.0.0 a 4.7.8, “resolvePartial()” en el tiempo de ejecución de Handlebars resuelve nombres de parciales a través de una búsqueda de propiedad simple en “options.partials” sin proteger contra el recorrido de la cadena de prototipos. Cuando “Object.prototype” ha sido contaminado con un valor de cadena cuya clave coincide con una referencia de parcial en una plantilla, la cadena contaminada se utiliza como cuerpo del parcial y se renderiza sin escape HTML, lo que resulta en XSS reflejado o almacenado. La versión 4.7.9 corrige el problema. Algunas soluciones alternativas están disponibles. Aplique “Object.freeze(Object.prototype)” al principio del inicio de la aplicación para evitar la contaminación de prototipos. Nota: esto puede romper otras bibliotecas, y/o use la compilación solo en tiempo de ejecución de Handlebars (“handlebars/runtime”), que no compila plantillas y reduce la superficie de ataque.","source":"nvd"}],"published":"2026-03-26T22:20:51.000Z","modified":"2026-10-26T22:10:00.163Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","score":4.7,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","score":4.7,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","score":4.7,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","score":4.7,"rating":"MEDIUM"}],"cwes":["CWE-79","CWE-1321"],"affected":[{"ranges":[{"version":">= 4.0.0, < 4.7.9","status":"affected"}],"vendor":"handlebars-lang","product":"handlebars.js","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"4.0.0","status":"affected","fixed":"4.7.9"}],"ecosystem":"npm","package":"handlebars","purl":"pkg:npm/handlebars","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"4.0.0","fixed":"4.7.9"}],"vendor":"handlebarsjs","product":"handlebars","cpe":"cpe:2.3:a:handlebarsjs:handlebars:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-2qvq-rjwj-gvw9","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-23369","tags":["advisory"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-23383","tags":["advisory"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33916","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/handlebars-lang/handlebars.js","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-03-30T15:41:27.326Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-33916","url":"https://www.cve.org/CVERecord?id=CVE-2026-33916","licence":"CVE Terms of Use","modified":"2026-03-30T15:41:36.977Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2qvq-rjwj-gvw9","url":"https://github.com/advisories/GHSA-2qvq-rjwj-gvw9","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:36.381Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-33916","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33916","licence":"Public domain","modified":"2026-10-26T22:10:00.163Z"}],"updatedAt":"2026-11-25T22:59:17.446Z","epss":{"score":0.00286,"percentile":0.22706,"date":"2026-12-01T12:00:22.000Z"}}