Junglewise Threat Intelligence

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

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

Technologies: hermes-engine (npm), Meta Hermes. Vendors: npm, Meta.

Executive brief

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.

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

Timeline

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

References

Related threats