CVE-2026-106444: Handlebars JavaScript Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-xw65-4hp5-5hc7
CVSS 4.7
CWE-116
Published
Advisory Summary

CVE-2026-106444 is a MODERATE (CVSS 4.7) javascript injection vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Handlebars libraries in the npm ecosystem. The issue involves javascript injection via unsafe inline embedding of precompiled templates. Remediation is available by upgrading affected packages to version 4.7.10.

CVE-2026-106444 at a Glance

CVE Identifier CVE-2026-106444
GHSA Identifier GHSA-xw65-4hp5-5hc7
Severity MODERATE
CVSS v3.1 Base Score 4.7
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Handlebars
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-106444

To remediate this vulnerability, upgrade all affected Handlebars dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

handlebars fixed: 4.7.10
npm install handlebars@4.7.10
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls handlebars

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-106444, inspect your project dependencies using npm:

npm ls handlebars

Analyze the terminal output to locate any version of Handlebars in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.7.10), your application is affected.

Note: The npm ls handlebars command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Handlebars, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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: ```handlebars safe</script><script>alert("XSS")</script><script> ``` could produce generated source containing: ```js 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 ```js 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

CVE-2026-106444 Affected Handlebars Versions

1 component(s)
Fixed Versions:
4.7.10
Product / Package Ecosystem Affected Versions Fixed Version
handlebars
npm
≥ 4.0.0
< 4.7.10
4.7.10

References

Frequently Asked Questions

What is CVE-2026-106444?
CVE-2026-106444 is a security vulnerability in Handlebars involving JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates under CWE-116: Improper Encoding or Escaping of Output.
Which Handlebars versions are affected?
Affected versions include releases prior to 4.7.10 across affected packages: handlebars.
What version fixes CVE-2026-106444?
Upgrading to 4.7.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is handlebars affected?
Yes, handlebars is affected in releases prior to 4.7.10. Upgrade your dependency to 4.7.10 or later.
What is the CVSS score of CVE-2026-106444?
CVE-2026-106444 has a CVSS v3.1 base score of 4.7 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-106444?
CVE-2026-106444 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check npm dependencies for CVE-2026-106444?
Run the dependency tree command: 'npm ls handlebars'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xw65-4hp5-5hc7",
  "modified" : "2026-10-08T17:52:37Z",
  "published" : "2026-10-08T17:52:37Z",
  "aliases" : [ "CVE-2026-106444" ],
  "summary" : "Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates",
  "details" : "## Summary\n\n`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.\n\nThis 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.\n\n## Details\n\nStatic 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.\n\nOn affected releases, this template:\n\n```handlebars\nsafe</script><script>alert(\"XSS\")</script><script>\n```\n\ncould produce generated source containing:\n\n```js\nreturn 'safe</script><script>alert(\"XSS\")</script><script>';\n```\n\nWhen 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.\n\n## Proof of Concept\n\n```js\nconst Handlebars = require('handlebars');\n\nconst template = 'safe</script><script>alert(\"XSS\")</script><script>';\nconst output = Handlebars.precompile(template);\n\nconsole.log(output.includes('</script>'));\n```\n\nAffected versions print `true`. Embedding `output` directly in an inline `<script>` element allows the injected script tag to be parsed by the browser.\n\n## Workarounds\n\n- Do not inline precompiled output from untrusted templates into HTML documents.\n- Serve generated precompiled templates as external JavaScript files where practical.\n\n## Credits\n\nReported by Curly-Haired-Baboon Aka Laplas",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "handlebars"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.7.10"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.7.9"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-xw65-4hp5-5hc7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-106444"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/handlebars-lang/handlebars.js/pull/2185"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/handlebars-lang/handlebars.js/commit/609d1b11c833c9a3e00f56f2f34d22f425446725"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/handlebars-lang/handlebars.js"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.10"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T17:52:37Z",
    "nvd_published_at" : "2026-10-06T20:17:26Z"
  }
}