# CVE-2021-23369: Handlebars remote code execution in template compilation

Source: https://junglewise.ai/threats/cve-2021-23369-handlebars-remote-code-execution-in-template-compilation  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-05-06. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2021-23369 · Severity: low · CVSS 3.1 · Published 2021-05-06

Handlebars is a widely-used templating engine for generating dynamic web content. This vulnerability allows attackers to execute arbitrary code on the server when applications compile untrusted templates with certain compiler options enabled. An attacker could exploit this to take complete control of affected applications, access sensitive data, or deploy malware.

Vendors: [Maven](https://junglewise.ai/threats/vendors/maven).

## Quick answers

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

**How severe is CVE-2021-23369?** Low severity, with a CVSS score of 3.1, published 6 May 2021.

**Which products and versions are affected?** org.webjars:handlebars (Maven) ECOSYSTEM:introduced=0,fixed=4.7.7; org.webjars.bowergithub.wycats:handlebars.js (Maven) ECOSYSTEM:introduced=0,fixed=4.7.7; org.webjars.npm:handlebars (Maven) ECOSYSTEM:introduced=0,fixed=4.7.7.

**Is there a fix for CVE-2021-23369?** Yes. org.webjars:handlebars (Maven): upgrade to 4.7.7 or later; org.webjars.bowergithub.wycats:handlebars.js (Maven): upgrade to 4.7.7 or later; org.webjars.npm:handlebars (Maven): upgrade to 4.7.7 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

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

**Am I affected by CVE-2021-23369?** Check whether you run org.webjars:handlebars (Maven), org.webjars.bowergithub.wycats:handlebars.js (Maven) or org.webjars.npm:handlebars (Maven) 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

- org.webjars:handlebars (Maven): upgrade to 4.7.7 or later

  ```sh
  # set org.webjars:handlebars to 4.7.7 in your pom.xml or build.gradle
  ```

- org.webjars.bowergithub.wycats:handlebars.js (Maven): upgrade to 4.7.7 or later

  ```sh
  # set org.webjars.bowergithub.wycats:handlebars.js to 4.7.7 in your pom.xml or build.gradle
  ```

- org.webjars.npm:handlebars (Maven): upgrade to 4.7.7 or later

  ```sh
  # set org.webjars.npm:handlebars to 4.7.7 in your pom.xml or build.gradle
  ```


## Technical details

The vulnerability is a code injection flaw (CWE-94) in Handlebars' template compilation process. When specific compiling options are used to process templates from untrusted sources, the parser fails to properly sanitize prototype property access, allowing attackers to inject and execute arbitrary JavaScript code. The attack requires no authentication and no user interaction—an attacker can send a malicious template directly to a vulnerable compilation endpoint. This was fixed in version 4.7.7 by adding strict-mode prototype property access checks in the runtime.

## Affected products

- Handlebars Handlebars.js before 4.7.7

## Identifiers

- CVE-2021-23369
- GHSA-f2jv-r9rf-7988

## Timeline

- 2021-04-12: disclosed
- 2021-04-13: patched: Patch committed to fix prototype property access checks

## References

- [https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8](https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8)
