CVE-2021-29532: TensorFlow Heap Out-of-Bounds Read
Summary
CVE-2021-29532: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 5 version ranges.
>= 2.2.0, < 2.3.0rc0
< 2.2.0rc0
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< 44b7f486c0143f68b56c34e2d01e146ee445134a
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29532 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 allows users to build and train neural networks, perform data preprocessing, and evaluate model performance. It is widely used in various industries for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that can be exploited by an attacker to force accesses outside the bounds of heap allocated arrays.
Vulnerability Detail
The vulnerability exists in the tf.raw_ops.RaggedCross function of TensorFlow. By passing in invalid tensor values, an attacker can trigger accesses outside the bounds of heap allocated arrays. This is due to a lack of validation in the implementation of the function. The code does not check if the index values used to access array elements are within the valid range, leading to out-of-bounds reads in the heap. An attacker can potentially leverage this vulnerability to read sensitive data or cause a denial-of-service condition. The issue has been identified and a fix will be included in TensorFlow 2.5.0. Additionally, the fix will be backported to TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4, as these versions are also affected and still within the supported range.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-cpu==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.2.0rc02.2.0rc0pip install --upgrade "tensorflow-cpu==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-cpu==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-cpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-cpu==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 temporary workaround, users can implement input validation in their own code before passing tensors to the tf.raw_ops.RaggedCross function. By validating the tensor values and ensuring they are within the expected range, the risk of triggering the vulnerability can be mitigated. Here is an example of how input validation can be performed in Python:
import tensorflow as tf
def safe_ragged_cross(tensor):
if not isinstance(tensor, tf.Tensor):
raise ValueError('Input tensor must be a TensorFlow Tensor.')
if tensor.dtype != tf.float32:
raise ValueError('Input tensor must have dtype float32.')
if tensor.shape[0] > 1000:
raise ValueError('Input tensor size exceeds maximum limit.')
# Perform safe RaggedCross operation
return tf.raw_ops.RaggedCross(tensor)
Conclusion
In conclusion, a vulnerability has been discovered in TensorFlow that allows an attacker to perform out-of-bounds reads in heap allocated arrays. This can lead to unauthorized access to sensitive data or a denial-of-service condition. Users are advised to update to the latest patched version of TensorFlow or apply the respective patches for their affected versions. Implementing input validation in code can also serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
TensorFlow is an open source platform for machine learning that provides tools and resources for developing and deploying machine learning models.
The vulnerability allows an attacker to read outside the bounds of heap allocated arrays in TensorFlow, potentially leading to unauthorized access to sensitive data or a denial-of-service condition.
The vulnerability affects TensorFlow versions 2.1.4, 2.2.3, 2.3.3, 2.4.2, and any versions prior to 2.5.0.
To fix the vulnerability, it is recommended to update TensorFlow to the latest patched version. For affected versions, the respective patched versions are: TensorFlow 2.1.4, TensorFlow 2.2.3, TensorFlow 2.3.3, TensorFlow 2.4.2, or TensorFlow 2.5.0 (once released).
Yes, a temporary workaround is to implement input validation in your code before passing tensors to the vulnerable function. By validating the tensor values and ensuring they are within the expected range, the risk of triggering the vulnerability can be mitigated.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.