CVE-2021-37675: Division by 0 in TensorFlow Convolution Operators
Summary
CVE-2021-37675: Division by 0 in most convolution operators. Affects tensorflow across 3 version ranges.
< 2.3.4
>= 2.4.0, < 2.4.3
>= 2.5.0, < 2.5.1
Fixed in 2.3.4, 2.4.3 or 2.5.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-37675 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 neural networks. It provides a comprehensive set of tools and libraries for building and deploying machine learning models. TensorFlow includes various operators for convolution, a fundamental operation in deep learning that involves applying filters to input data. These convolution operators are used in many applications, including image and speech recognition. However, most implementations of convolution operators in TensorFlow are vulnerable to a division by 0 issue.
Vulnerability Detail
The division by 0 vulnerability in TensorFlow convolution operators allows an attacker to trigger a denial of service (DoS) by causing a crash. By providing specific input data, an attacker can exploit the vulnerability and cause the program to divide by zero, leading to a crash. The vulnerability arises from a lack of validation in the shape inference implementation of TensorFlow. The shape inference process fails to perform necessary validations before performing divisions and modulo operations, allowing the division by 0 vulnerability to occur. This vulnerability has a CVSS score of 5.5, indicating a moderate 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.3.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3" -
>= 2.5.0, < 2.5.12.5.1pip install --upgrade "tensorflow==2.5.1"
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 implement input validation in their code to prevent the division by 0 vulnerability. By checking the dimensions and shapes of input tensors before passing them to convolution operators, developers can ensure that the division operation will not result in a division by 0 error. Here is an example of how to perform input validation for a Conv2D operation in TensorFlow:
import tensorflow as tf
def conv2d_with_validation(input, filter, strides, padding):
if input.shape[1] == 0 or input.shape[2] == 0 or filter.shape[1] == 0 or filter.shape[2] == 0:
raise ValueError('Invalid input or filter shape')
return tf.raw_ops.Conv2D(input=input, filter=filter, strides=strides, padding=padding)
By adding this validation step, the division by 0 vulnerability can be mitigated.
Conclusion
The division by 0 vulnerability in TensorFlow convolution operators can be mitigated by updating to the patched versions of TensorFlow. Users should regularly update their TensorFlow installation to ensure the latest security patches are applied. Implementing input validation in code can also help prevent the vulnerability. For further support and assistance in 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 neural networks. It provides a comprehensive set of tools and libraries for building and deploying machine learning models.
Convolution operators in TensorFlow are operations that apply filters to input data. They are commonly used in deep learning applications, such as image and speech recognition, to extract features from input data.
The division by 0 vulnerability in TensorFlow convolution operators occurs due to a lack of validation in the shape inference implementation. The shape inference process fails to perform necessary validations before performing divisions and modulo operations, allowing the division by 0 vulnerability to occur.
The division by 0 vulnerability in TensorFlow convolution operators can be exploited by an attacker to trigger a denial of service (DoS) by causing a crash. By providing specific input data, an attacker can exploit the vulnerability and cause the program to divide by zero, leading to a crash.
The division by 0 vulnerability in TensorFlow convolution operators can be fixed by updating TensorFlow to one of the patched versions: TensorFlow 2.3.4, TensorFlow 2.4.3, TensorFlow 2.5.1, or TensorFlow 2.6.0. Users should ensure they are using the latest version of TensorFlow to apply the necessary security patches.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.