CVE-2021-29517: TensorFlow GPU Division by Zero Vulnerability
Summary
CVE-2021-29517: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.
< 2.1.4
>= 2.2.0, < 2.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
< 799f835a3dfa00a4d852defa29b15841eea9d64f
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-29517 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 specific package that enables GPU acceleration for TensorFlow computations. It allows users to leverage the power of GPUs to accelerate training and inference processes in machine learning models.
Vulnerability Detail
A division by zero vulnerability exists in the Conv3D implementation of TensorFlow GPU. The vulnerability arises due to a modulo operation that is performed based on user-controlled input. If the fifth element of the 'filter' tensor is set to zero, a division by zero occurs. Additionally, if the shape of the two tensors is invalid, it can trigger an Eigen assertion, leading to a program crash. This vulnerability can be exploited by a malicious user to cause a denial-of-service (DoS) attack or potentially execute arbitrary code on the affected system.
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.1.42.1.4pip install --upgrade "tensorflow-gpu==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow-gpu==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow-gpu==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow-gpu==2.4.2"
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 ensure that the 'filter' tensor does not contain a zero as the fifth element. Additionally, it is important to validate the shapes of the tensors used in the Conv3D operation to avoid triggering the Eigen assertion. Here is an example code snippet that demonstrates the workaround:
import tensorflow as tf
# Ensure 'filter' tensor does not have zero as the fifth element
filter = tf.constant([1, 2, 3, 4, 1], dtype=tf.float32)
# Validate tensor shapes
if filter.shape[0] != expected_shape[0] or filter.shape[1] != expected_shape[1] or filter.shape[2] != expected_shape[2]:
raise ValueError('Invalid tensor shape')
# Perform Conv3D operation
output = tf.nn.conv3d(input, filter, strides, padding)
Note: This workaround should only be used until the package is updated to a fixed version.
Conclusion
The division by zero vulnerability in TensorFlow GPU's Conv3D implementation can lead to a program crash or potential code execution. It is crucial to update the TensorFlow GPU package to the fixed versions or apply the provided workaround to mitigate the risk. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models.
TensorFlow GPU is a specific package that enables GPU acceleration for TensorFlow computations. It allows users to leverage the power of GPUs to accelerate training and inference processes in machine learning models.
This vulnerability can be exploited by a malicious user to cause a denial-of-service (DoS) attack or potentially execute arbitrary code on the affected system.
To fix this vulnerability, it is recommended to update the TensorFlow GPU package to version 2.5.0 or later. For users on older versions, the fix has been backported to TensorFlow 2.4.2, 2.3.3, 2.2.3, and 2.1.4. Users should upgrade their packages to the corresponding fixed versions.
Yes, a temporary workaround is to ensure that the 'filter' tensor does not contain a zero as the fifth element. Additionally, validate the shapes of the tensors used in the Conv3D operation to avoid triggering the Eigen assertion.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.