# CVE-2026-33940: Handlebars.js remote code execution via AST type confusion

Source: https://junglewise.ai/threats/cve-2026-33940-handlebars-js-remote-code-execution-via-ast-type-confusion  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-03-27. Updated: 2026-06-30  
License: CC BY 4.0 with a link back

CVE-2026-33940 · Severity: high · CVSS 8.1 · Published 2026-03-27

Handlebars is a popular library used to generate web pages and other documents from templates. A security flaw in certain versions allows an attacker to inject malicious code into the server's memory by providing a specially crafted data object. If successful, this could allow the attacker to take full control of the server, steal sensitive data, or disrupt operations.

Technologies: [handlebars (npm)](https://junglewise.ai/threats/technologies/npm-handlebars). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2026-33940 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-33940 being exploited in the wild.

**How severe is CVE-2026-33940?** High severity, with a CVSS score of 8.1, published 27 March 2026.

**Which products and versions are affected?** handlebars (npm) SEMVER:introduced=4.0.0,fixed=4.7.9.

**Is there a fix for CVE-2026-33940?** Yes. handlebars (npm): upgrade to 4.7.9 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-33940 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-33940?** Check whether you run handlebars (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- handlebars (npm): upgrade to 4.7.9 or later

  ```sh
  npm install handlebars@4.7.9
  ```


## Technical details

A type confusion vulnerability exists in the Handlebars runtime within the `resolvePartial()` and `invokePartial()` functions. By providing a crafted object with a `call: true` property in the template context, an attacker can bypass conditional guards in `resolvePartial()`, causing `invokePartial()` to return `undefined`. The runtime then incorrectly treats this object as an uncompiled partial and passes it to `env.compile()`. Since the crafted object is a valid Handlebars AST containing injected code, the resulting JavaScript executes arbitrary commands on the server. This exploit requires the attacker to control a value used in a dynamic partial lookup (e.g., `{{> (lookup ...)}}`). The issue is fixed in version 4.7.9.

## Affected products

- handlebars-lang handlebars.js >= 4.0.0, <= 4.7.8

## Identifiers

- CVE-2026-33940
- GHSA-xhpv-hc6g-r9c6

## Timeline

- 2026-03-24: other: Fix authored
- 2026-03-26: patched: Version 4.7.9 released
- 2026-03-27: disclosed: CVE published

## References

- [https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2](https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2)
- [https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9](https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9)
- [https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-xhpv-hc6g-r9c6](https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-xhpv-hc6g-r9c6)
- [https://access.redhat.com/errata/RHSA-2026:10175](https://access.redhat.com/errata/RHSA-2026:10175)
- [https://access.redhat.com/security/cve/CVE-2026-33940](https://access.redhat.com/security/cve/CVE-2026-33940)
- [https://bugzilla.redhat.com/show_bug.cgi?id=2452521](https://bugzilla.redhat.com/show_bug.cgi?id=2452521)
- [https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33940.json](https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33940.json)

## Related threats

- [Handlebars AST validation bypass in compile and precompile](https://junglewise.ai/threats/cve-2026-106446-handlebars-provides-the-power-necessary-to-let-users-build)
- [Handlebars prototype pollution RCE via constructor bypass](https://junglewise.ai/threats/cve-2026-106445-handlebars-provides-the-power-necessary-to-let-users-build)
- [Handlebars precompile script injection in generated code](https://junglewise.ai/threats/cve-2026-106444-handlebars-provides-the-power-necessary-to-let-users-build)
- [Handlebars.js prototype method access control gap via missing __lookupSetter__](https://junglewise.ai/threats/handlebars-js-prototype-method-access-control-gap-via-missing-f97c2407)
- [Handlebars.js property access validation bypass in container.lookup](https://junglewise.ai/threats/handlebars-js-property-access-validation-bypass-in-container-lookup-25bcfec0)
