Skip to content
OpenAdvisories

Description

Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, the Handlebars CLI precompiler (`bin/handlebars` / `lib/precompiler.js`) concatenates user-controlled strings — template file names and several CLI options — directly into the JavaScript it emits, without any escaping or sanitization. An attacker who can influence template filenames or CLI arguments can inject arbitrary JavaScript that executes when the generated bundle is loaded in Node.js or a browser. Version 4.7.9 fixes the issue. Some workarounds are available. First, validate all CLI inputs before invoking the precompiler. Reject filenames and option values that contain characters with JavaScript string-escaping significance (`"`, `'`, `;`, etc.). Second, use a fixed, trusted namespace string passed via a configuration file rather than command-line arguments in automated pipelines. Third, run the precompiler in a sandboxed environment (container with no write access to sensitive paths) to limit the impact of successful exploitation. Fourth, audit template filenames in any repository or package that is consumed by an automated build pipeline.

Affected products

VendorProductAffectedFixed
handlebars-lang handlebars.js >= 4.0.0, < 4.7.9 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 node-handlebars 3:4.7.9-1 —
Debian 13 node-handlebars No fix yet —
Debian 12 node-handlebars No fix yet —
ReleasePackageFixed inAdvisory
Ubuntu 26.10 node-handlebars No fix yet —
Ubuntu 26.04 LTS node-handlebars No fix yet —
Ubuntu 25.10 node-handlebars No fix yet —
Ubuntu 24.04 LTS node-handlebars No fix yet —
Ubuntu 22.04 LTS node-handlebars No fix yet —
Show 2 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu 20.04 LTS node-handlebars No fix yet —
Ubuntu 18.04 LTS node-handlebars No fix yet —

Wolfi

ReleasePackageFixed inAdvisory
Wolfi rolling jupyter-base-notebook 7.6.3-r2 —
Wolfi rolling lerna 9.0.7-r2 —
Wolfi rolling opensearch-dashboards-3 3.5.0-r12 —
Wolfi rolling prism 5.14.3-r13 —
Wolfi rolling py3.10-jupyterlab +3 4.6.1-r1 —
Wolfi rolling rancher-api-ui 1.2.3-r8 —
Wolfi rolling ts-patch 4.0.1-r0 —

Affected packages

EcosystemPackageAffectedFixedRecord
npm handlebars >= 4.0.0, < 4.7.9 4.7.9 GHSA-xjpj-3mr7-gcpf

Advisories 3

References