CVE-2021-29513: TensorFlow GPU - Type Confusion Vulnerability
Summary
CVE-2021-29513: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu 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
< 030af767d357d1b4088c4a25c72cb3906abac489
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-cpu · PyPI
The same CVE-2021-29513 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 the power of GPUs for accelerated computation. It allows users to train and run machine learning models on GPU hardware, enabling faster and more efficient processing of large datasets. However, TensorFlow GPU is vulnerable to a type confusion vulnerability that can lead to null pointer dereferences when non-numeric tensors are passed to operations expecting numeric tensors.
Vulnerability Detail
The vulnerability in TensorFlow GPU arises from the conversion process between Python arrays and C++ arrays. When operations that expect numeric tensors are called with tensors of non-numeric types, a type confusion occurs, resulting in null pointer dereferences. This can lead to crashes or other unexpected behavior in TensorFlow GPU. The vulnerability has the potential to be exploited by an attacker to cause denial of service or execute arbitrary code in the context of the affected TensorFlow GPU application. The issue has been assigned CVE-2021-29513 and has been addressed in TensorFlow versions 2.5.0, 2.4.2, 2.3.3, 2.2.3, and 2.1.4.
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.2.0rc02.2.0rc0pip install --upgrade "tensorflow-gpu==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-gpu==2.3.0rc0" -
>= 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 temporary workaround, users can avoid passing tensors of non-numeric types to operations that expect numeric tensors in TensorFlow GPU. This can be achieved by performing appropriate type checks and conversions before calling the operations. Here is an example of how to perform a type check and conversion in Python:
import tensorflow as tf
def safe_operation(tensor):
if not tf.is_numeric_tensor(tensor):
tensor = tf.cast(tensor, tf.float32)
# Perform the operation with the converted tensor
...
By explicitly checking the type and converting non-numeric tensors to the expected numeric type, the vulnerability can be mitigated.
Conclusion
The type confusion vulnerability in TensorFlow GPU can lead to null pointer dereferences and potential exploitation by attackers. It is crucial for users to update their TensorFlow GPU installations to the patched versions and review their custom code for compatibility. By following the recommended steps, users can mitigate the vulnerability and ensure the security of their TensorFlow GPU applications. 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 hardware for accelerated computation. It allows users to train and run machine learning models on GPUs, enabling faster processing of large datasets.
A type confusion vulnerability occurs when an application or system mistakenly interprets data of one type as another type. In the case of TensorFlow GPU, passing tensors of non-numeric types to operations expecting numeric tensors leads to a type confusion vulnerability.
The vulnerability in TensorFlow GPU can result in null pointer dereferences, leading to crashes or other unexpected behavior. This can potentially be exploited by an attacker to cause denial of service or execute arbitrary code in the context of the affected TensorFlow GPU application.
To fix the vulnerability, it is recommended to update TensorFlow GPU to one of the patched versions: 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4. Users should also ensure that all dependencies and associated packages are updated to compatible versions.
As a temporary workaround, users can avoid passing tensors of non-numeric types to operations that expect numeric tensors in TensorFlow GPU. This can be achieved by performing appropriate type checks and conversions before calling the operations.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.