Quick answers
- Is CVE-2021-37654 exploited in the wild?
- No. Junglewise Threat Intelligence has no report of CVE-2021-37654 being exploited in the wild.
- How severe is CVE-2021-37654?
- Low severity, with a CVSS score of 3.1, published 12 August 2021.
- Which products and versions are affected?
- Google TensorFlow before 2.3.4; 2.4.0-2.4.2; 2.5.0; tensorflow (PyPI) GIT:introduced=0,fixed=bc9c546ce7015c57c2f15c168b3d9201de679a1d|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-cpu (PyPI) GIT:introduced=0,fixed=bc9c546ce7015c57c2f15c168b3d9201de679a1d|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3; tensorflow-gpu (PyPI) GIT:introduced=0,fixed=bc9c546ce7015c57c2f15c168b3d9201de679a1d|ECOSYSTEM:introduced=2.3.0,fixed=2.3.4,introduced=2.4.0,fixed=2.4.3.
- Is there a fix for CVE-2021-37654?
- 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-37654 attacked?
- It is attacked with local access.
- Am I affected by CVE-2021-37654?
- 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 heap out-of-bounds (OOB) read in the ResourceGather operation caused by missing validation of the batch_dims parameter against the input tensor rank. The vulnerable code uses batch_dims to iterate over tensor dimensions without checking that batch_dims ≤ tensor.dims(), causing reads beyond valid heap memory. In debug builds, a DCHECK catches the out-of-bounds access; in release builds, the DCHECK becomes a no-op, allowing the OOB read to proceed. The attack requires calling tf.raw_ops.ResourceGather with a batch_dims value exceeding the input tensor's rank. Patches are available in TensorFlow 2.3.4, 2.4.3, 2.5.1, and 2.6.0.
Affected products
- Google TensorFlow before 2.3.4; 2.4.0-2.4.2; 2.5.0
- Google TensorFlow CPU before 2.3.4; 2.4.0-2.4.2; 2.5.0
- Google TensorFlow GPU before 2.3.4; 2.4.0-2.4.2; 2.5.0
Identifiers
- CVE-2021-37654
- GHSA-2r8p-fg3c-wcj4
- PYSEC-2021-276
- PYSEC-2021-567
- PYSEC-2021-765
Timeline
- 2021-08-11: disclosed
- 2021-08-25: patched: TensorFlow 2.3.4, 2.4.3, 2.5.1, and 2.6.0 released with fix