CVE-2021-29517: TensorFlow - Division by 0 in Conv3D Implementation
Summary
CVE-2021-29517: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow 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-cpu · PyPI
- tensorflow-gpu · 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 is widely used in various domains, including research, industry, and academia. The Conv3D implementation in TensorFlow is responsible for performing 3D convolution operations, which are commonly used in video and volumetric data analysis. This vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2.
Vulnerability Detail
The vulnerability arises from a division by 0 in the Conv3D implementation of TensorFlow. The implementation performs a modulo operation based on user-controlled input. If the fifth element of the 'filter' tensor is set to 0, a division by 0 occurs. Additionally, if the shape of the two tensors involved in the convolution operation is invalid, it can trigger an Eigen assertion, leading to a program crash. An attacker with the ability to control the input to the Conv3D operation could exploit this vulnerability to cause a denial of service (DoS) or potentially execute arbitrary code.
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 workaround, users can validate the input tensors' shapes before performing the Conv3D operation. By ensuring that the shapes are valid and the fifth element of the 'filter' tensor is non-zero, the division by 0 can be avoided. Here is an example code snippet demonstrating the workaround:
import tensorflow as tf
# Validate tensor shapes
if tensor1.shape[4] != 0 and tensor2.shape[4] != 0:
# Perform Conv3D operation
result = tf.nn.conv3d(tensor1, tensor2, strides=[1, 1, 1, 1, 1], padding='SAME')
else:
# Handle invalid shapes
print('Invalid tensor shapes')
Conclusion
The division by 0 vulnerability in the Conv3D implementation of TensorFlow can be exploited by a malicious user to cause a program crash, execute arbitrary code, or launch a denial of service attack. It is crucial for users to upgrade their TensorFlow installations to the patched versions or apply the provided workaround to mitigate the risk. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
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.
Conv3D is an operation in TensorFlow that performs 3D convolution, which is commonly used in video and volumetric data analysis.
This vulnerability can lead to a division by 0 and trigger an Eigen assertion, resulting in a program crash or potential execution of arbitrary code. It can also be exploited to cause a denial of service (DoS) attack.
Versions of TensorFlow ranging from 0 to 2.4.2 are affected by this vulnerability.
To fix this vulnerability, it is recommended to upgrade TensorFlow to version 2.5.0 or later. Alternatively, users can also upgrade to the patched versions 2.4.2, 2.3.3, 2.2.3, or 2.1.4.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.