CVE-2021-37668: TensorFlow UnravelIndex division by zero

CVE-2021-37668 · Severity: low · CVSS 3.1 · Published 2021-08-12

TensorFlow's UnravelIndex operation, used for index manipulation in machine learning models, contains a flaw that allows an attacker to crash applications by providing specially crafted input containing zero values. This causes a denial-of-service condition, making services unavailable until restarted.

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

Quick answers

Is CVE-2021-37668 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2021-37668 being exploited in the wild.
How severe is CVE-2021-37668?
Low severity, with a CVSS score of 3.1, published 12 August 2021.
Which products and versions are affected?
Google TensorFlow versions prior to 2.3.4; 2.4.0–2.4.2; 2.5.0; tensorflow (PyPI) GIT:introduced=0,fixed=a776040a5e7ebf76eeb7eb923bf1ae417dd4d233|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-cpu (PyPI) GIT:introduced=0,fixed=a776040a5e7ebf76eeb7eb923bf1ae417dd4d233|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-gpu (PyPI) GIT:introduced=0,fixed=a776040a5e7ebf76eeb7eb923bf1ae417dd4d233|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3.
Is there a fix for CVE-2021-37668?
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-37668 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2021-37668?
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 division-by-zero error (CWE-369) in tf.raw_ops.UnravelIndex. The root cause is missing input validation: the operation does not verify that the dims tensor is non-empty or that none of its elements are zero before performing mathematical operations that divide by dim values. An attacker can trigger the flaw by calling UnravelIndex with dims containing a 0 value (e.g., dims=[1,0,2]). No authentication is required; the operation is network-reachable in applications serving TensorFlow models. The impact is denial of service through application crash. Patches are available in TensorFlow 2.3.4, 2.4.3, 2.5.1, and 2.6.0.

Affected products

  • Google TensorFlow versions prior to 2.3.4; 2.4.0–2.4.2; 2.5.0
  • Google TensorFlow CPU versions prior to 2.3.4; 2.4.0–2.4.2; 2.5.0
  • Google TensorFlow GPU versions prior to 2.3.4; 2.4.0–2.4.2; 2.5.0

Identifiers

  • CVE-2021-37668
  • GHSA-2wmv-37vq-52g5
  • PYSEC-2021-290
  • PYSEC-2021-581
  • PYSEC-2021-779

Timeline

  • 2021-08-12: disclosed: NVD publication
  • 2021-08-25: advisory: GitHub security advisory published
  • 2021-08-12: patched: Fix committed in TensorFlow; patches released in 2.3.4, 2.4.3, 2.5.1, and included in 2.6.0

References

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