# CVE-2021-24037: Meta Hermes JavaScript engine use after free

Source: https://junglewise.ai/threats/cve-2021-24037-meta-hermes-javascript-engine-use-after-free  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2022-05-24. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2021-24037 · Severity: low · CVSS 3.1 · Published 2022-05-24

Hermes is a JavaScript engine used by React Native applications to execute application code. A use-after-free vulnerability in error message handling allows attackers to execute arbitrary code if an application evaluates untrusted JavaScript. Most React Native apps are not affected because they do not evaluate arbitrary untrusted code, but applications that do permit dynamic script execution face a critical risk.

Technologies: [Meta Hermes](https://junglewise.ai/threats/technologies/hermes), [hermes-engine (npm)](https://junglewise.ai/threats/technologies/hermes-engine). Vendors: [Meta](https://junglewise.ai/threats/vendors/meta), [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

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

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

**Which products and versions are affected?** Meta Hermes <=0.7.2; hermes-engine (npm) SEMVER:introduced=0,fixed=0.8.0.

**Is there a fix for CVE-2021-24037?** Yes. hermes-engine (npm): upgrade to 0.8.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

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

**Am I affected by CVE-2021-24037?** Check whether you run Meta Hermes or hermes-engine (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

- hermes-engine (npm): upgrade to 0.8.0 or later

  ```sh
  npm install hermes-engine@0.8.0
  ```


## Technical details

This is a use-after-free vulnerability (CWE-416) in the Hermes JavaScript engine occurring in the error message emission path, specifically in the `transientObjectPutErrorMessage` function. The root cause is that a UTF16Ref returned from `StringView::getUTF16Ref` can be invalidated when more content is appended to the allocator, but the invalidated pointer is still used, resulting in access to freed memory. An attacker can trigger this by crafting malicious JavaScript that causes specific error messages to be emitted. The vulnerability is only exploitable if the host application permits evaluation of untrusted JavaScript; applications that only execute trusted/bundled code are not affected. Successful exploitation allows arbitrary code execution with the privileges of the application. The vulnerability was fixed in Hermes version 0.8.0 (commit d86e185e485b6330216dee8e854455c694e3a36e).

## Affected products

- Meta Hermes <=0.7.2

## Identifiers

- CVE-2021-24037
- GHSA-mph8-6787-r8hw

## Timeline

- 2021-06-15: disclosed
- 2022-05-24: advisory
- 2022-05-24: patched: Fixed in version 0.8.0

## References

- [https://github.com/facebook/hermes/commit/d86e185e485b6330216dee8e854455c694e3a36e](https://github.com/facebook/hermes/commit/d86e185e485b6330216dee8e854455c694e3a36e)

## Related threats

- [Meta Hermes out-of-bounds read in JavaScript interpreter](https://junglewise.ai/threats/cve-2020-1915-meta-hermes-out-of-bounds-read-in-javascript-interpreter)
- [Facebook Hermes out-of-bounds read in SaveGeneratorLong](https://junglewise.ai/threats/cve-2020-1914-facebook-hermes-out-of-bounds-read-in-savegeneratorlong)
- [Facebook Hermes signed to unsigned conversion error](https://junglewise.ai/threats/cve-2020-1913-facebook-hermes-signed-to-unsigned-conversion-error)
- [Facebook Hermes out-of-bounds read/write in generator compilation](https://junglewise.ai/threats/cve-2020-1912-facebook-hermes-out-of-bounds-read-write-in-generator-compilation)
- [Facebook Hermes type confusion in prototype chain resolution](https://junglewise.ai/threats/cve-2020-1911-facebook-hermes-type-confusion-in-prototype-chain-resolution)
