CVE-2021-37654: Heap OOB and CHECK fail in ResourceGather in TensorFlow
Summary
CVE-2021-37654: Heap OOB and CHECK fail in ResourceGather. Affects tensorflow across 3 version ranges.
< 2.3.4
>= 2.4.0, < 2.4.3
>= 2.5.0, < 2.5.1
Fixed in 2.3.4, 2.4.3 or 2.5.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-37654 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow allows users to create and manipulate tensors, which are multi-dimensional arrays used as the fundamental data structure for computations. The ResourceGather API in TensorFlow is used to gather values from a resource tensor based on specified indices. This vulnerability affects versions 0 to 2.3.4, 2.4.0 to 2.4.3, and 2.5.0 to 2.5.1 of the TensorFlow package.
Vulnerability Detail
The vulnerability in TensorFlow arises from a failure to validate the 'batch_dims' parameter supplied by the user in the ResourceGather API. An attacker can exploit this vulnerability to trigger a crash in debug builds or read data from outside the bounds of the heap allocated buffer in release builds. By providing a 'batch_dims' value greater than the rank of the input tensor, the implementation of ResourceGather attempts to access data beyond the allocated memory, leading to a heap out-of-bounds (OOB) read. This can result in information disclosure or denial of service. The vulnerability has a CVSS score of 7.3.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.0"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 2.3.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3" -
>= 2.5.0, < 2.5.12.5.1pip install --upgrade "tensorflow==2.5.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
There is no known workaround for this vulnerability. Users are strongly encouraged to apply the provided patches or upgrade to a patched version of TensorFlow.
Conclusion
The vulnerability in TensorFlow's ResourceGather API can be exploited to trigger crashes or read data from outside the allocated memory. It is crucial for users to upgrade to the patched versions or apply the provided patches to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides tools and resources for building and deploying machine learning models.
The ResourceGather API in TensorFlow is used to gather values from a resource tensor based on specified indices.
An attacker can trigger a crash in debug builds or read data from outside the bounds of the heap allocated buffer in release builds, potentially leading to information disclosure or denial of service.
To fix this vulnerability, users should upgrade their TensorFlow installation to version 2.6.0 or later, or apply the provided patches for versions 2.3.4, 2.4.3, and 2.5.1.
There is no known workaround for this vulnerability. It is recommended to apply the provided patches or upgrade to a patched version of TensorFlow.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.