Loading advisory.
Loading advisory.
Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates
Handlebars.precompile() generates JavaScript source that is commonly embedded in browser <script> elements. Before the fix, static template text containing </script> was emitted unchanged.
Published 2026-10-06 19:01 UTC · Modified 2026-10-08 18:00 UTC
Severity and EPSS are shown separately. Helm does not combine them into one score.
| Package | Ecosystem | Affected | Fixed in | Upgrade command |
|---|---|---|---|---|
| handlebars | npm | >= 4.0.0, < 4.7.10 | 4.7.10 | npm install handlebars@4.7.10 |
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.
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.
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.
Do not inline precompiled output from untrusted templates into HTML documents.
Serve generated precompiled templates as external JavaScript files where practical.
Reported by Curly-Haired-Baboon Aka Laplas
No public exploit code known to Helm's sources (Nuclei templates, Metasploit, Exploit-DB and PoC-in-GitHub). That does not mean none exists.
EPSS went from 0.003 on 2026-11-24 to 0.003 on 2026-11-26, over 2 recorded scores.
| Date | Score | Previous | Model |
|---|---|---|---|
| 2026-11-24 | 0.003 | first score | v2026.06.15 |
| 2026-11-26 | 0.003 | 0.003 | v2026.06.15 |