CVE-2021-37642: TensorFlow Division by Zero Vulnerability

tensorflow Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Moderate
5.5

CVE-2021-37642: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow across 3 version ranges.

>= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < 4aacb30888638da75023e6601149415b39763d76

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-37642 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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 is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in TensorFlow that can lead to a division by zero error.

Vulnerability Detail

The vulnerability (CVE-2021-37642) exists in the implementation of tf.raw_ops.ResourceScatterDiv in TensorFlow. The vulnerable code fails to handle the division by zero case separately, resulting in a potential division by zero error. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) condition or potentially execute arbitrary code.

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

As a temporary workaround, users can avoid the vulnerability by ensuring that the division operation in their TensorFlow code does not involve a divisor of zero. It is recommended to add appropriate checks and error handling to prevent division by zero errors. Here is an example of how to handle the division operation safely:

# Check if the divisor is zero before performing the division
if divisor != 0:
    result = dividend / divisor
else:
    # Handle the division by zero case
    result = 0

Conclusion

In conclusion, a division by zero vulnerability (CVE-2021-37642) has been identified in TensorFlow. This vulnerability can lead to a denial-of-service (DoS) condition or potential code execution. The TensorFlow development team has released patches for the affected versions, and users are advised to update their installations as soon as the patched versions become available. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models.

This vulnerability can lead to a division by zero error in TensorFlow, which can result in a denial-of-service (DoS) condition or potentially allow an attacker to execute arbitrary code.

The vulnerability affects TensorFlow versions 2.3.0 and above. Specifically, TensorFlow versions 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and 2.5.1 are affected. The issue has been patched in TensorFlow 2.6.0.

To fix this vulnerability, it is recommended to update your TensorFlow installation to the patched versions. Once TensorFlow 2.6.0 or the cherrypicked versions (2.5.1, 2.4.3, and 2.3.4) are available, you should upgrade your TensorFlow installation.

Yes, as a temporary workaround, you can ensure that the division operation in your TensorFlow code does not involve a divisor of zero. Add appropriate checks and error handling to prevent division by zero errors.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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