CVE-2021-29602: Division by zero in TFLite's implementation of DepthwiseConv
Summary
CVE-2021-29602: Division by zero in TFLite's implementation of DepthwiseConv. 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-29602 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
The TensorFlow package is an open-source machine learning framework developed by Google. It provides a comprehensive set of tools and libraries for building and deploying machine learning models. TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. TFLite includes various operators, including the DepthwiseConv operator, which performs depthwise convolution on input tensors. This vulnerability affects versions of TensorFlow prior to 2.1.4, 2.2.3, 2.3.3, and 2.4.2.
Vulnerability Detail
The vulnerability in TFLite's implementation of the DepthwiseConv operator arises from a division by zero error. The code responsible for the vulnerability checks if the number of input channels is a factor of the number of filter channels. However, it fails to handle the case where the number of input channels is zero. An attacker can exploit this vulnerability by crafting a model with a fourth-dimensional input tensor that has zero channels. This can lead to a division by zero error, potentially causing the application to crash or exhibit unexpected behavior.
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
There is no known workaround for this vulnerability. It is recommended to apply the provided fix by updating to the patched versions of TensorFlow.
Conclusion
The division by zero vulnerability in TFLite's implementation of the DepthwiseConv operator can be exploited by crafting a model with a zero-channel input tensor. To mitigate this vulnerability, users should update their TensorFlow installations to the patched versions. No known workaround exists for this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. It provides a set of tools and libraries for running machine learning models on resource-constrained platforms.
The DepthwiseConv operator is an operator in TFLite that performs depthwise convolution on input tensors. It is commonly used in convolutional neural networks for tasks such as image classification and object detection.
An attacker can exploit this vulnerability by crafting a model with a fourth-dimensional input tensor that has zero channels. This can trigger a division by zero error in the DepthwiseConv operator, potentially causing the application to crash or exhibit unexpected behavior.
No, only versions of TensorFlow prior to 2.1.4, 2.2.3, 2.3.3, and 2.4.2 are affected by this vulnerability. Users of these versions should update to the respective patched versions to mitigate the vulnerability.
No, there is no known workaround for this vulnerability. It is recommended to update to the patched versions of TensorFlow to mitigate the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.