CVE-2026-106444 is a medium-severity (CVSS 4.7) CWE-116 vulnerability in handlebars. A fix is available for handlebars — see the affected versions and patch details below.
Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
Exploitation and automatability from CISA’s SSVC triage for CVE-2026-106444.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2026-106444 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 394,803 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
handlebarsReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Summary
Handlebars.precompile() generates JavaScript source that is commonly embedded in browser <script> elements. Before the fix, static template text containing </script> was emitted unchanged. HTML parsers recognize </script> even inside a JavaScript string literal, closing the surrounding script element and allowing following attacker-controlled markup to be parsed and executed.
This affects applications that precompile attacker-controlled templates and embed the generated source directly in an HTML <script> element. It does not affect ordinary server-side rendering or precompiled templates delivered as external JavaScript files.
Details
Static text is serialized by quotedString() in lib/handlebars/compiler/code-gen.js. The generated JavaScript is valid, but JavaScript quoting alone does not make it safe to embed in HTML. In HTML script data, the sequence </script> terminates the element regardless of JavaScript string context.
On affected releases, this template:
safe</script><script>alert("XSS")</script><script>
could produce generated source containing:
return 'safe</script><script>alert("XSS")</script><script>';
When included inline in an HTML document, the first </script> closes the script containing the precompiled template. The next <script> element is then parsed as HTML and executes.
Proof of Concept
const Handlebars = require('handlebars');
const template = 'safe</script><script>alert("XSS")</script><script>';
const output = Handlebars.precompile(template);
console.log(output.includes('</script>'));
Affected versions print true. Embedding output directly in an inline <script> element allows the injected script tag to be parsed by the browser.
Workarounds
- Do not inline precompiled output from untrusted templates into HTML documents.
- Serve generated precompiled templates as external JavaScript files where practical.
Credits
Reported by Curly-Haired-Baboon Aka Laplas
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | handlebars | ≥ 4.0.0&&< 4.7.10 | 4.7.10npm install handlebars@4.7.10 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for handlebars, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update handlebars to 4.7.10 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-106444 is resolved across your whole dependency graph.
Workarounds
Escape or sanitise the affected output on the server side rather than relying on client-side filtering, and add a Content-Security-Policy that blocks inline script execution so injected markup cannot run even if it reaches the page.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
A moderate severity cross-site scripting (XSS) flaw was found in the Handlebars JavaScript template library. When serializing static template text into generated JavaScript, Handlebars.precompile() does not escape sequences that terminate an enclosing HTML script element. An application that precompiles…
This flaw can be avoided without upgrading: do not embed precompiled output from untrusted or attacker-controlled Handlebars templates directly in inline HTML script elements. Where practical, serve generated precompiled templates as external JavaScript files, or rely on ordinary server-side rendering, since those usage patterns are not affected. Restricting template precompilation to trusted template sources also prevents attacker-controlled template text from reaching Handlebars.precompile(). Updating Handlebars to the upstream fixed version (4.7.10) also resolves this issue.Source: Red Hat security advisory for CVE-2026-106444 (CC BY 4.0)
Frequently Asked Questions
Is CVE-2026-106444 in your dependencies?
Find it across npm, including transitive dependencies.