CVE-2021-29526: Division by 0 in TensorFlow Conv2D
Summary
CVE-2021-29526: Division by 0 in Conv2D. 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-29526 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. The Conv2D function in TensorFlow is used for performing 2D convolution operations on input tensors. This vulnerability affects versions 0.0.0 to 2.1.4 of the TensorFlow package.
Vulnerability Detail
The vulnerability (CVE-2021-29526) arises from a division by zero issue in the Conv2D function of TensorFlow. An attacker can exploit this vulnerability by providing specific input and filter tensors that result in a division by zero during the convolution operation. This can lead to a crash or unexpected behavior in the application using TensorFlow. The 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
If updating TensorFlow is not immediately possible, a workaround can be implemented by validating the input and filter tensors before passing them to the Conv2D function. This can involve checking the dimensions and ensuring that the division operation will not result in a division by zero. Here is an example of a workaround in Python:
import tensorflow as tf
input = tf.constant([], shape=[0, 0, 0, 0], dtype=tf.float32)
filter = tf.constant([], shape=[0, 0, 0, 0], dtype=tf.float32)
strides = [1, 1, 1, 1]
padding = "SAME"
if input.shape[3] % filter.shape[2] != 0:
# Handle the division by zero case
print("Invalid input and filter dimensions")
else:
tf.raw_ops.Conv2D(input=input, filter=filter, strides=strides, padding=padding)
Conclusion
In conclusion, the vulnerability (CVE-2021-29526) in TensorFlow's Conv2D function can be exploited to trigger a division by zero, leading to a crash or unexpected behavior. It is recommended to update the TensorFlow package to one of the patched versions or implement the provided workaround. 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.
The Conv2D function in TensorFlow is used for performing 2D convolution operations on input tensors. It is commonly used in image processing and computer vision tasks.
An attacker can exploit this vulnerability to trigger a division by zero in the Conv2D function, leading to a crash or unexpected behavior in the application using TensorFlow.
To fix this vulnerability, update your TensorFlow package to one of the patched versions: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4. Run the command pip install --upgrade tensorflow to update.
Yes, if updating TensorFlow is not immediately possible, you can implement a workaround by validating the input and filter tensors before passing them to the Conv2D function. Check the dimensions and ensure the division operation will not result in a division by zero.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.