CVE-2026-106444

Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates

Published Oct 6, 2026 CVSS 3.1 · 4.7 Medium EPSS < 1% KEV · Not listed
Description
Handlebars provides the power necessary to let users build semantic templates. From 4.0.0 until 4.7.10, Handlebars.precompile() uses quotedString() in lib/handlebars/compiler/code-gen.js to emit static template text into generated JavaScript without escaping sequences that terminate an enclosing HTML script element. When an application precompiles attacker-controlled template text and embeds the generated source directly in an inline script element, a closing script delimiter can end the element and cause following attacker-controlled markup to be parsed and executed. Ordinary server-side rendering and precompiled templates served as external JavaScript files are not affected. This issue is fixed in version 4.7.10.

Analysis

AI-generated

Technical impact

Handlebars’ precompile function inserts template text directly into the generated JavaScript without escaping characters that could terminate an enclosing HTML <script> element. When an attacker controls the template content and the application embeds the compiled code inline, a specially crafted string can close the <script> tag and inject arbitrary markup or script that will then be parsed and executed by the victim’s browser. This flaw is a form of client‑side code injection that can lead to cross‑site scripting attacks, potentially exposing sensitive data or executing malicious actions on behalf of the user. The underlying weaknesses include improper handling of quoted strings (CWE‑116) and cross‑site scripting (CWE‑79).

Affected Systems

The vulnerability affects handlebars.js releases from 4.0.0 up to and including 4.7.9. The Handlebars.js library is maintained by the handlebars‑lang organization. The fix was introduced in version 4.7.10.

Risk and Exploitability

The CVSS score of 4.7 indicates a moderate severity, and the EPSS score is not available. The vulnerability is not listed in the CISA KEV catalog. Exploitation requires that an attacker can influence the template text that an application precompiles and embeds inline, a scenario that may arise if user input is used as template content. Once applied, the attack occurs in the victim’s browser and can be performed remotely by simply serving malicious template data.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade handlebars.js to version 4.7.10 or later to receive the fix.
  • Avoid embedding precompiled template source directly into inline <script> elements; instead serve compiled templates as external JavaScript files or use alternative delivery methods.
  • Validate and sanitize any user‑supplied template content before precompiling, or restrict template compilation to trusted, non‑user data.

Generated by OpenCVE AI on October 7, 2026 at 13:45 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-xw65-4hp5-5hc7 Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates
History
Type Values Removed Values Added
First Time appeared Handlebarsjs
Handlebarsjs handlebars
Vendors & Products Handlebarsjs
Handlebarsjs handlebars
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description Handlebars provides the power necessary to let users build semantic templates. From 4.0.0 until 4.7.10, Handlebars.precompile() uses quotedString() in lib/handlebars/compiler/code-gen.js to emit static template text into generated JavaScript without escaping sequences that terminate an enclosing HTML script element. When an application precompiles attacker-controlled template text and embeds the generated source directly in an inline script element, a closing script delimiter can end the element and cause following attacker-controlled markup to be parsed and executed. Ordinary server-side rendering and precompiled templates served as external JavaScript files are not affected. This issue is fixed in version 4.7.10.
Title Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates
Weaknesses CWE-116
References
Metrics cvssV3_1

{'score': 4.7, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N'}

Weaknesses
  • CWE-116

    Improper Encoding or Escaping of Output

  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Oct 6, 2026, 7:48 PM
Reserved
Oct 6, 2026, 4:49 PM
Status
Awaiting Analysis
Published
Oct 6, 2026, 8:17 PM
Modified
Oct 7, 2026, 1:58 PM
Severity
Moderate
Public date
Oct 6, 2026, 7:01 PM