REDHAT-BUG-2452523: 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, Handlebars.compile() accepts a pre-parsed AST object in addition to a template string. The value field of a NumberLiteral AST node is emitted directly into the generated JavaScript without quoting or sanitization. An attacker who can supply a crafted AST to compile() can therefore inject and execute arbitrary JavaScript, leading to Remote Code Execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. Validate input type before calling Handlebars.compile(); ensure the argument is always a string, never a plain object or JSON-deserialized value. Use the Handlebars runtime-only build (handlebars/runtime) on the server if templates are pre-compiled at build time; compile() will be unavailable.

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 to a fixed release to a version that resolves this vulnerability.

    Fixed in 4.7.9
  2. Configuration

    If templates are pre-compiled at build time, use the Handlebars runtime-only build (`handlebars/runtime`) on the server so `compile()` is unavailable.

    Handlebars (server-side template compilation) Use runtime-only build handlebars/runtime vs full build = handlebars/runtime
  3. Configuration

    Before calling `Handlebars.compile()`, validate that the argument is always a `string` and ensure it is never a plain object or a JSON-deserialized value.

    Handlebars.compile() Input validation for compile() argument type = string only

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