Junglewise Threat Intelligence

Handlebars.js property access validation bypass in container.lookup

Severity: low · CVSS 3.1 · Published 2026-03-29

Technologies: Handlebars.

Executive brief

Handlebars.js is a popular template engine used to render dynamic HTML pages. When the compatibility mode option is enabled, a security check designed to prevent unauthorized access to sensitive object properties can be bypassed, potentially allowing an attacker to access data that should be restricted through template expressions.

Technical details

The vulnerability is a TOCTOU race condition (CWE-367) in lib/handlebars/runtime.js where container.lookup() calls container.lookupProperty() as a gate to check whether a property access is allowed, but then discards the validated result and performs an independent, unguarded property access (depths[i][name]). The lookupProperty() function enforces hasOwnProperty checks and resultIsAllowed() prototype-access controls, but these are bypassed by the second access. The vulnerability only affects code compiled with the {compat: true} option, which activates depthiedLookup in the JavaScript compiler. An attacker can exploit this by crafting template expressions that access restricted properties when untrusted data is passed to the template context. The fix is to return the validated result from lookupProperty() directly instead of performing a second raw access. Versions 4.0.0 through 4.7.8 are affected; patched in 4.7.9.

Affected products

  • Handlebars handlebars 4.0.0 to 4.7.8

Timeline

  • 2026-03-29: disclosed: Advisory GHSA-442j-39wm-28r2 published
  • 2026-03-26: patched: Security fix committed and released in v4.7.9

References