CVE-2021-37654: TensorFlow GPU - Out-of-Bounds Read Vulnerability
Summary
CVE-2021-37654: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< bc9c546ce7015c57c2f15c168b3d9201de679a1d
Fixed in 2.3.4 or 2.4.3, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-cpu · 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 end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is widely used in various industries and research domains for training and inference of deep learning models.
Vulnerability Detail
The vulnerability (CVE-2021-37654) in TensorFlow GPU allows an attacker to trigger a crash or read data from outside the bounds of heap allocated data. The issue arises from a lack of validation in the tf.raw_ops.ResourceGather API, specifically in the batch_dims parameter. By supplying a batch_dims value greater than or equal to the rank of the input tensor, an attacker can cause the program to read data beyond the allocated buffer, leading to potential information disclosure or a crash. This vulnerability affects debug builds of TensorFlow GPU and release builds with the tf.raw_ops.ResourceGather API.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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.0, < 2.3.42.3.4pip install --upgrade "tensorflow-gpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-gpu==2.4.3"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a workaround, users can avoid using the tf.raw_ops.ResourceGather API with a batch_dims value greater than or equal to the rank of the input tensor. It is recommended to review the codebase and ensure that the batch_dims parameter is properly validated before invoking the API. Here is an example of how to validate the batch_dims parameter:
import tensorflow as tf
def resource_gather_with_validation(tensor, indices, batch_dims):
if batch_dims >= tf.rank(tensor):
raise ValueError('Invalid batch_dims value')
return tf.raw_ops.ResourceGather(tensor=tensor, indices=indices, batch_dims=batch_dims)
By implementing this validation check, the vulnerability can be mitigated.
Conclusion
The vulnerability (CVE-2021-37654) in TensorFlow GPU exposes a potential risk of crashing the program or reading data from outside the bounds of heap allocated data. The TensorFlow development team has addressed this issue and will release patched versions to mitigate the vulnerability. Users are advised to update their TensorFlow GPU installations to the patched versions once they are available. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow GPU is a variant of TensorFlow that utilizes GPU acceleration for faster computation of machine learning models. It is commonly used in scenarios where large-scale deep learning models require significant computational power.
This vulnerability allows an attacker to trigger a crash or read data from outside the bounds of heap allocated data. Depending on the specific scenario, this could lead to potential information disclosure or denial of service.
The vulnerability affects TensorFlow GPU versions 2.3.0 and above. Specifically, TensorFlow GPU versions 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and 2.5.1 are affected. The upcoming TensorFlow GPU version 2.6.0 will include the fix for this vulnerability.
To fix this vulnerability, it is recommended to update your TensorFlow GPU installation to the patched versions once they are released. The fix will be included in TensorFlow GPU versions 2.6.0, 2.5.1, 2.4.3, and 2.3.4.
Yes, as a workaround, users can avoid using the tf.raw_ops.ResourceGather API with a batch_dims value greater than or equal to the rank of the input tensor. It is also recommended to validate the batch_dims parameter before invoking the API to mitigate the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.