CVE-2021-37690: TensorFlow use-after-free in shape inference functions

CVE-2021-37690 · Severity: low · CVSS 3.1 · Published 2021-08-13

TensorFlow is an open-source machine learning framework used to build and train neural network models. A use-after-free vulnerability in the shape inference component can cause a segmentation fault, leading to denial of service when processing certain model operations. This affects systems using TensorFlow to perform machine learning inference or training tasks.

Technologies: Google TensorFlow, tensorflow (PyPI), tensorflow-cpu (PyPI), tensorflow-gpu (PyPI). Vendors: Google, PyPI.

Quick answers

Is CVE-2021-37690 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2021-37690 being exploited in the wild.
How severe is CVE-2021-37690?
Low severity, with a CVSS score of 3.1, published 13 August 2021.
Which products and versions are affected?
Google TensorFlow < 2.3.4, 2.4.0-2.4.2, 2.5.0; tensorflow (PyPI) GIT:introduced=0,fixed=ee119d4a498979525046fba1c3dd3f13a039fbb1|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-cpu (PyPI) GIT:introduced=0,fixed=ee119d4a498979525046fba1c3dd3f13a039fbb1|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-gpu (PyPI) GIT:introduced=0,fixed=ee119d4a498979525046fba1c3dd3f13a039fbb1|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3.
Is there a fix for CVE-2021-37690?
Yes. tensorflow (PyPI): upgrade to 2.4.3 or later; tensorflow-cpu (PyPI): upgrade to 2.4.3 or later; tensorflow-gpu (PyPI): upgrade to 2.4.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2021-37690 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2021-37690?
Check whether you run Google TensorFlow, tensorflow (PyPI), tensorflow-cpu (PyPI) or one of the others listed 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

  • tensorflow (PyPI): upgrade to 2.4.3 or later
    pip install "tensorflow>=2.4.3"
  • tensorflow-cpu (PyPI): upgrade to 2.4.3 or later
    pip install "tensorflow-cpu>=2.4.3"
  • tensorflow-gpu (PyPI): upgrade to 2.4.3 or later
    pip install "tensorflow-gpu>=2.4.3"

Technical details

The vulnerability is a use-after-free (CWE-416) in shape inference functions, specifically when handling ShapeAndType structs produced by functions like MutableHashTableShape. Shape information is owned by an inference context that is freed immediately after use; if upstream code attempts to access this shape data afterward, it triggers a segmentation fault. The ShapeRefiner was cloning normal output shapes to prevent this, but was not applying the same logic to shapes and types. The fix involves cloning output shapes and types to place them under ownership of a longer-lived inference context. Patches are available in TensorFlow 2.6.0 and backported versions 2.5.1, 2.4.3, and 2.3.4.

Affected products

  • Google TensorFlow < 2.3.4, 2.4.0-2.4.2, 2.5.0
  • Google TensorFlow CPU < 2.3.4, 2.4.0-2.4.2, 2.5.0
  • Google TensorFlow GPU < 2.3.4, 2.4.0-2.4.2, 2.5.0

Identifiers

  • CVE-2021-37690
  • GHSA-3hxh-8cp2-g4hg
  • PYSEC-2021-312
  • PYSEC-2021-603
  • PYSEC-2021-801

Timeline

  • 2021-08-25: disclosed: Vulnerability published in GitHub Advisory Database
  • 2021-08-13: patched: Fix available in TensorFlow 2.6.0 and backported to 2.3.4, 2.4.3, 2.5.1

References

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