REDHAT-BUG-2452521: High severity Handlebars Handlebars vulnerability

Published Mar 27, 2026
·
Updated

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 Software

2 affected components
Handlebars Handlebars>=4.0.0<=4.7.8
Handlebars Handlebars=4.7.9

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade handlebars to a version that resolves this vulnerability.

    Fixed in 4.7.9
  2. Configuration

    Use the runtime-only build of Handlebars (use require('handlebars/runtime') instead of the full build) to reduce exposure from template/code execution paths.

    Handlebars Build/require target = require('handlebars/runtime')
  3. Configuration

    Before rendering, sanitize the template context so that no value is a non-primitive object; prevent objects from being passed into dynamic partial resolution/compilation paths.

    Template rendering context Context data types = Only primitives allowed (no non-primitive objects)
  4. Configuration

    Avoid dynamic partial lookups such as {{> (lookup ...)}} when the lookup inputs/context data are user-controlled.

    Handlebars templates Dynamic partial lookups = Avoid {{> (lookup ...)}} with user-controlled context

Event History

Mar 27, 2026
Data Sourced
via Red Hat·10:03 PM
DescriptionSeverityAffected Software

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203