CVE-2021-29522: Division by 0 in TensorFlow
Summary
CVE-2021-29522: Division by 0 in Conv3DBackprop*. Affects tensorflow across 4 version ranges.
< 2.1.4
>= 2.2.0, < 2.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29522 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 open-source machine learning framework widely used for developing and training deep learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications. TensorFlow supports various operations, including convolutional operations like Conv3DBackprop*, which are used in 3D convolutional neural networks (CNNs). These operations are critical for tasks such as image and video processing.
Vulnerability Detail
The vulnerability, identified as CVE-2021-29522, affects the tf.raw_ops.Conv3DBackprop* operations in TensorFlow. These operations fail to validate the input tensors, allowing an attacker to trigger a division by zero error. By controlling the input sizes, an attacker can exploit this vulnerability to cause a denial of service (DoS) attack. The issue arises from the lack of checks in the implementation code, specifically in the computation of the shard size. This vulnerability has a CVSS score of 2.5, indicating a low severity level.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==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.1.42.1.4pip install --upgrade "tensorflow==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow==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 input tensors passed to Conv3DBackprop* operations are not empty. By validating the input sizes and ensuring they are non-zero, the division by zero error can be avoided. Here is an example of how to validate the input tensors:
import tensorflow as tf
input_sizes = tf.constant([1], shape=[1, 1, 1, 1, 1], dtype=tf.float32)
filter_tensor = tf.constant([0, 0, 0, 1, 0], shape=[5], dtype=tf.int32)
out_backprop = tf.constant([], shape=[1, 1, 1, 1, 0], dtype=tf.float32)
tf.raw_ops.Conv3DBackpropFilterV2(input=input_sizes, filter_sizes=filter_tensor, out_backprop=out_backprop, strides=[1, 1, 1, 1, 1], padding='SAME', data_format='NDHWC', dilations=[1, 1, 1, 1, 1])
Conclusion
The vulnerability in TensorFlow's Conv3DBackprop* operations allows an attacker to trigger a division by zero error, leading to a potential denial of service (DoS) attack. The TensorFlow team has addressed this vulnerability in the latest versions and provided patches for older versions. Users are strongly advised to update their TensorFlow installations to the patched versions once they become available. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework used for developing and training deep learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications.
Conv3DBackprop* operations in TensorFlow are used for computing the gradients of the input or filter tensors in 3D convolutional neural networks. These operations are critical for tasks such as image and video processing.
The vulnerability allows an attacker to trigger a division by zero error in the tf.raw_ops.Conv3DBackprop* operations. This can lead to a denial of service (DoS) attack by causing the affected TensorFlow application to crash or become unresponsive.
The TensorFlow team has released patches for this vulnerability in TensorFlow versions 2.5.0, 2.4.2, 2.3.3, 2.2.3, and 2.1.4. Users are advised to update their TensorFlow installations to the patched versions once they become available.
Yes, as a temporary workaround, users can ensure that the input tensors passed to Conv3DBackprop* operations are not empty. By validating the input sizes and ensuring they are non-zero, the division by zero error can be avoided.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.