CVE-2021-29538: TensorFlow GPU Division by Zero Denial of Service
Summary
CVE-2021-29538: 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
< c570e2ecfc822941335ad48f6e10df4e21f11c96
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-29538 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
The vulnerability (CVE-2021-29538) exists in the Conv2DBackpropFilter implementation of TensorFlow GPU. The implementation computes a divisor based on user-provided data, specifically the shape of the tensors given as arguments. If all shapes are empty, the divisor 'work_unit_size' becomes 0. However, there is no check for this case before division, resulting in a division by zero runtime exception. This vulnerability can be exploited by an attacker to cause a denial of service (DoS) by triggering the division by zero error. The impact of this vulnerability can disrupt the availability of TensorFlow GPU and any applications relying on it.
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 triggering the division by zero error by ensuring that the shapes of the tensors provided as arguments to Conv2DBackpropFilter are not all empty. This can be achieved by validating the input data and ensuring that at least one tensor has a non-empty shape. Here is an example code snippet demonstrating the workaround:
import tensorflow as tf
# Validate input tensors
if all(tensor.shape == [] for tensor in input_tensors):
# Add a dummy tensor with a non-empty shape
dummy_tensor = tf.constant([1], dtype=tf.float32)
input_tensors.append(dummy_tensor)
# Perform Conv2DBackpropFilter operation
output_tensor = tf.nn.conv2d_backprop_filter(input_tensors, ...)
Conclusion
The vulnerability (CVE-2021-29538) in TensorFlow GPU's Conv2DBackpropFilter can lead to a division by zero error, potentially causing a denial of service. It is crucial for users to update their TensorFlow GPU installations to the patched versions once they are released. In the meantime, a temporary workaround is available to mitigate the risk. For further support on 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 ecosystem of tools and resources for developing and deploying machine learning models.
TensorFlow GPU is a 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 an attacker to cause a denial of service (DoS) by triggering a division by zero error in TensorFlow GPU. The impact can disrupt the availability of TensorFlow GPU and any applications relying on it.
The vulnerability will be fixed in TensorFlow 2.5.0. Users are advised to update their TensorFlow GPU installations to the patched versions once they are released. Regularly checking for updates and applying them promptly is recommended for maintaining the security and stability of TensorFlow GPU.
Yes, as a temporary workaround, users can ensure that the shapes of the tensors provided as arguments to Conv2DBackpropFilter are not all empty. This can be achieved by validating the input data and adding a dummy tensor with a non-empty shape if needed.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.