CVE-2020-1912: Facebook Hermes out-of-bounds read/write in generator compilation

CVE-2020-1912 · Severity: low · CVSS 3.1 · Published 2022-05-24

Facebook Hermes is a JavaScript engine used in React Native applications. An out-of-bounds memory access vulnerability in the lazy compilation of generator functions could allow an attacker to execute arbitrary code if the application evaluates untrusted JavaScript. However, most React Native apps are unaffected since they do not typically permit such evaluation.

Technologies: hermes-engine (npm). Vendors: npm.

Quick answers

Is CVE-2020-1912 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2020-1912 being exploited in the wild.
How severe is CVE-2020-1912?
Low severity, with a CVSS score of 3.1, published 24 May 2022.
Which products and versions are affected?
hermes-engine (npm) SEMVER:introduced=0,fixed=0.5.2.
Is there a fix for CVE-2020-1912?
Yes. hermes-engine (npm): upgrade to 0.5.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2020-1912 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2020-1912?
Check whether you run 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.5.2 or later
    npm install hermes-engine@0.5.2

Technical details

An out-of-bounds read and write vulnerability exists in Facebook Hermes prior to commit 091835377369c8fd5917d9b87acffa721ad2a168. When a generator function is large enough to trigger lazy compilation, the engine incorrectly loses information about whether the function is an inner generator. This causes the function to be generated as a regular function instead, leading to memory access violations. The vulnerability is exploitable only if untrusted JavaScript evaluation is permitted. The root cause is improper restoration of function context during lazy compilation. The fix involves correctly tracking the isGeneratorInnerFunction flag during serialization and deserialization.

Affected products

  • Facebook Hermes prior to 0.5.2

Identifiers

  • CVE-2020-1912
  • GHSA-pf27-929j-9pmm

Timeline

  • 2020-09-09: disclosed
  • 2020-09-08: patched: Fix committed to Hermes repository

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.