CVE-2021-29595: Division by zero in TFLite's implementation of DepthToSpace
Summary
CVE-2021-29595: Division by zero in TFLite's implementation of DepthToSpace. 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-29595 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 specifically designed for mobile and embedded devices. It allows developers to run machine learning models on resource-constrained platforms. TFLite includes an operator called DepthToSpace, which rearranges data in the depth dimension of a tensor. This operator is vulnerable to a division by zero error, which can be exploited by an attacker.
Vulnerability Detail
The vulnerability in TFLite's DepthToSpace operator arises from a division by zero error in its implementation. The vulnerable code can be found in the depth_to_space.cc file of the TensorFlow Lite library. The operator calculates the output channel size by dividing the input channel size by the block size squared. However, if the block size is set to zero, a division by zero occurs, leading to a runtime error. An attacker can craft a malicious model that triggers this vulnerability, potentially causing the application to crash or behave unexpectedly. The impact of this vulnerability is considered low, as it requires the attacker to have control over the model inputs.
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 specific workaround mentioned for this vulnerability.
Conclusion
The division by zero vulnerability in TFLite's DepthToSpace operator has been addressed by the TensorFlow team. Users are advised to update their TensorFlow installations to the patched versions once they are available. For further support and assistance with vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides 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. It allows running machine learning models on resource-constrained platforms.
The DepthToSpace operator in TFLite rearranges data in the depth dimension of a tensor. It is used for tasks like upsampling and image super-resolution.
An attacker can craft a malicious model that triggers the division by zero error in the DepthToSpace operator. This can potentially cause the application to crash or behave unexpectedly.
The impact of this vulnerability is considered low, as it requires the attacker to have control over the model inputs. However, it can lead to application crashes or unexpected behavior.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.