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, a crafted object placed in the template context can bypass all conditional guards in `resolvePartial()` and cause `invokePartial()` to return `undefined`. The Handlebars runtime then treats the unresolved partial as a source that needs to be compiled, passing the crafted object to `env.compile()`. Because the object is a valid Handlebars AST containing injected code, the generated JavaScript executes arbitrary commands on the server. The attack requires the adversary to control a value that can be returned by a dynamic partial lookup. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). Without `compile()`, the fallback compilation path in `invokePartial` is unreachable. Second, sanitize context data before rendering: Ensure no value in the context is a non-primitive object that could be passed to a dynamic partial. Third, avoid dynamic partial lookups (`{{> (lookup ...)}}`) when context data is user-controlled.

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-xhpv-hc6g-r9c6

Advisories 2

References