CVE-2021-37640: TensorFlow-CPU - Division by 0 in SparseReshape Implementation

tensorflow-cpu Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Unrated
Not published

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

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.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback