CVE-2021-37640: TensorFlow-CPU - Division by 0 in SparseReshape Implementation
Summary
CVE-2021-37640: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< 4923de56ec94fff7770df259ab7f2288a74feb41
Fixed in 2.3.4 or 2.4.3, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-37640 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-CPU is a specific package within TensorFlow that focuses on CPU-based computations. It is widely used in various industries and research domains for machine learning tasks.
Vulnerability Detail
The vulnerability identified as CVE-2021-37640 affects the implementation of tf.raw_ops.SparseReshape in TensorFlow-CPU. This vulnerability arises due to a lack of proper input validation in the reshaping process. The implementation does not check if the input or target shape has a non-zero number of elements, leading to a division by zero exception. An attacker can exploit this vulnerability by providing malicious input data, causing the division by zero exception to occur. The ramifications of this vulnerability include potential crashes, denial of service, or the execution of arbitrary code.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-cpu==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.0, < 2.3.42.3.4pip install --upgrade "tensorflow-cpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-cpu==2.4.3"
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. However, as a general best practice, it is recommended to validate and sanitize input data before passing it to TensorFlow-CPU functions. This can help mitigate the risk of potential vulnerabilities.
Conclusion
The vulnerability identified as CVE-2021-37640 in TensorFlow-CPU can lead to a division by zero exception, potentially resulting in crashes, denial of service, or the execution of arbitrary code. It is crucial to update TensorFlow-CPU to the latest version and regularly apply security patches to mitigate this vulnerability. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
TensorFlow is an open source platform for machine learning that provides tools and resources for developing and deploying machine learning models.
TensorFlow-CPU is a specific package within TensorFlow that focuses on CPU-based computations. It is widely used for machine learning tasks.
The impact of this vulnerability includes potential crashes, denial of service, or the execution of arbitrary code.
To fix this vulnerability, update TensorFlow-CPU to version 2.6.0 or later. Alternatively, if you are using version 2.5.1, you can apply the fix by cherrypicking commit 4923de56ec94fff7770df259ab7f2288a74feb41.
There are no specific workarounds mentioned for this vulnerability. However, validating and sanitizing input data before passing it to TensorFlow-CPU functions can help mitigate potential risks.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.