CVE
CVE-2026-106445, CVE-2026-106444
CWE
CWE-184, CWE-1289, CWE-116
Affected Surface
- npm consumers of `handlebars` 4.0.0 through 4.7.9 that compile or render attacker-controlled templates with `allowProtoMethodsByDefault: true`
- Applications that call `Handlebars.precompile()` on attacker-controlled template text and embed the generated source directly inside inline HTML `<script>` elements
- Frameworks, CMSs, generators, and internal tooling that pull Handlebars transitively and expose either template authoring or precompile-to-inline-script flows
The most relevant new package vulnerability cluster from the 6 to 9 October window sits in a library that often disappears into the background: handlebars.
handlebars@4.7.10 fixes two different boundary failures:
CVE-2026-106445, the higher-signal bug, let a hostile template walk from an exposed function toFunction.prototype.constructorand then execute arbitrary JavaScript on the server.CVE-2026-106444let hostile template text break out of inline precompiled output when an application embeddedHandlebars.precompile()results straight into an HTML<script>element.
These are not “every Handlebars install is instantly compromised” bugs. Both need a specific application pattern. What matters for AppSec teams is that those patterns are common in CMS features, email-template builders, static-site helpers, and internal admin tooling. A dependency inventory is only the first step. You also need to know who can author templates and how your application turns templates into code.
What is affected
The same package range is affected in both advisories: handlebars 4.0.0 through 4.7.9. The trigger conditions differ:
| CVE | Package surface | Trigger condition | Fixed in |
|---|---|---|---|
CVE-2026-106445 | Handlebars.compile() / runtime template rendering | An attacker can supply template source, the template context exposes a function, and runtime options enable allowProtoMethodsByDefault: true | 4.7.10 |
CVE-2026-106444 | Handlebars.precompile() output embedded in inline HTML | An attacker can supply template source and the application inlines the generated JavaScript into a <script> tag | 4.7.10 |
That distinction matters. CVE-2026-106445 is serious because it reaches server-side code execution, but it does not apply to the default Handlebars runtime posture. CVE-2026-106444 has a lower impact ceiling, but it fits a pattern many teams treat as harmless build or presentation logic.
CVE-2026-106445: lookupProperty() trusted the wrong kind of own property
The vulnerable logic is short:
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
return result;
}
That early return treated any own property on parent as trusted context data. The advisory points out why that assumption fails for prototype objects:
Function.prototype.constructor === Function;
String.prototype.constructor === String;
Object.prototype.constructor === Object;
Once a template could reach Function.prototype, asking for constructor did not go through Handlebars’ prototype-access deny list. It returned Function directly.
The shortest attacker path is not complicated:
{{lookup (lookup fn "__proto__") "constructor"}}
If fn is an accessible function in the template context and allowProtoMethodsByDefault is enabled, that lookup yields the Function constructor. From there, the attacker no longer needs a Handlebars bug. They have a JavaScript code-generation primitive inside the server process.
The published proof of concept turns that into command execution:
const template = Handlebars.compile(
'{{#with a}}' +
'{{lookup "" (push "return process.mainModule.require(\\'child_process\\').execSync(\\'id\\').toString()")}}' +
'{{lookup "" (pop)}}' +
'{{lookup "" (shift)}}' +
'{{/with}}' +
'{{lookup "" (@root.a.push (lookup (lookup fn "__proto__") "constructor"))}}' +
'{{#each @root}}{{#if @index}}{{else}}' +
'{{#with (this.apply null @root.a)}}{{this}}{{/with}}' +
'{{/if}}{{/each}}'
);
The 4.7.10 fix is also compact, but it closes exactly the trust boundary that failed:
if (
Object.prototype.hasOwnProperty.call(parent, propertyName) &&
!isPrototypeConstructor(parent, propertyName, result)
) {
return result;
}
And the new helper makes the intent explicit:
export function isPrototypeConstructor(parent, propertyName, result) {
return (
propertyName === 'constructor' &&
typeof result === 'function' &&
parent === result.prototype
);
}
That change means ordinary own properties still short-circuit. The dangerous back-reference from a prototype object to its constructor does not.
One useful extra detail from the same fix train: escapeExpression() also stopped trusting any truthy toHTML property and now requires it to be callable. That is not the headline CVE, but it shows the same cleanup theme. Data-shaped objects should not be able to masquerade as privileged runtime objects just because a property name matches an internal convention.
CVE-2026-106444: valid JavaScript was still unsafe HTML
The second bug sits on a different boundary. Handlebars.precompile() produces JavaScript source, and many projects inline that source into an HTML <script> element. Before 4.7.10, Handlebars treated JavaScript string escaping as sufficient:
return 'safe</script><script>alert("XSS")</script><script>';
That string is valid JavaScript. It is not safe HTML. Browsers do not care that </script> appears inside a JavaScript string literal. In script data, </script> still ends the enclosing element, so the following attacker-controlled markup is parsed and executed.
The advisory’s proof of concept is simple:
const template = 'safe</script><script>alert("XSS")</script><script>';
const output = Handlebars.precompile(template);
console.log(output.includes('</script>'));
Affected versions print true. If an application then writes output into an inline <script> block, the browser gets a real script break, not just a weird string literal.
The patch moved this problem into code, not documentation. Handlebars added explicit escaping for HTML script delimiters:
const SCRIPT_DELIMITERS = /<(?=!--|\/?script)/gi;
function escapeScriptDelimiters(code) {
return code.replace(SCRIPT_DELIMITERS, '\\u003C');
}
quotedString() now builds on safeJsonLiteral() so the compiler escapes < before <!--, <script, and </script>, along with line separators and surrogates that can also create cross-engine surprises in generated code.
That fix landed broadly across the compiler path. It is not only static template content that changed. The same PR updates lookup names, partial indents, tracked IDs, source locations, and CLI-emitted template names so they are all quoted with the same HTML-safe literal routine instead of raw JSON.stringify(...).
Why the cluster matters to AppSec teams
The two CVEs are different, but they share the same root lesson: code generation and template safety are boundary problems, not presentation problems.
In CVE-2026-106445, a runtime fast path trusted the wrong object shape and let a template reach Function.
In CVE-2026-106444, a compiler path produced syntactically correct JavaScript but forgot that the browser parses inline <script> contents with HTML rules first.
Those are the kinds of bugs that slip into production when teams think of templates as “just strings” or “just view logic.” Handlebars is often wired into systems where untrusted people really can author template text: storefront themes, email editors, CMS blocks, notification builders, multi-tenant customization systems, and internal admin consoles that expose templating to power users.
Scoping your exposure
Start by finding the package:
npm ls handlebars
pnpm why handlebars
yarn why handlebars
Then search for the high-risk usage patterns:
rg -n "\"handlebars\"|Handlebars\\.compile|Handlebars\\.precompile|from \"handlebars\"|from 'handlebars'" \
package.json package-lock.json pnpm-lock.yaml yarn.lock src lib app
rg -n 'allowProtoMethodsByDefault|allowProtoPropertiesByDefault|precompile\\(|<script|</script>|<!--' \
src lib app templates views
For CVE-2026-106445, the most important questions are:
- can an untrusted user supply template source;
- does the template context expose functions or helpers that lead to functions; and
- does runtime configuration enable
allowProtoMethodsByDefault: true.
For CVE-2026-106444, the important question is narrower: does any path precompile attacker-controlled templates and then inline the generated JavaScript into an HTML document instead of serving it as an external file.
Remediation
Upgrade handlebars to 4.7.10 or later.
If you cannot patch immediately:
- keep
allowProtoMethodsByDefaultat its defaultfalsevalue for any untrusted template surface; - do not inline precompiled output from attacker-controlled templates into HTML documents;
- prefer external JavaScript files or server-side compilation over inline precompiled script blocks; and
- review any application feature that treats template authors as “trusted enough” without giving them full code-execution authority.
The bigger point is that this is not a niche library issue. Handlebars sits in enough build systems, Node.js services, theme engines, and UI toolchains that a package-level fix can still map to a real application boundary. If your product lets users shape template source, 4.7.10 belongs on the patch queue.
From research to remediation
Check whether this pattern exists in your codebase
Turn this research into a remediation workflow. Scan dependencies and package manifests for similar supply-chain risk, then prioritize fixes with reachability context.