CVE-2021-29554: Division by 0 in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
Low
2.5

CVE-2021-29554: Division by 0 in DenseCountSparseOutput. Affects tensorflow across 2 version ranges.

>= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2

Fixed in 2.3.3 or 2.4.2, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-29554 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

TensorFlow is an open-source machine learning framework widely used for developing and training various deep learning models. It provides a comprehensive set of tools and libraries for building and deploying machine learning applications. TensorFlow is available for multiple programming languages, including Python, C++, and Java. This vulnerability affects versions 2.3.0 to 2.3.3 and 2.4.0 to 2.4.2 of the TensorFlow package.

Vulnerability Detail

The vulnerability, identified as CVE-2021-29554, involves a division by zero issue in the DenseCountSparseOutput function of TensorFlow. An attacker can exploit this vulnerability to cause a denial of service (DoS) attack by triggering a floating-point exception (FPE) runtime error. The vulnerable code does not check if the divisor value is zero before performing the division, leading to the FPE error. The issue arises when the num_batch_elements variable is calculated from user data, resulting in a zero value. This vulnerability has a CVSS score of 2.5, indicating a low severity level.

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.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip 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

As a temporary workaround, users can avoid triggering the vulnerability by ensuring that the values argument provided to the DenseCountSparseOutput function does not result in a zero value for num_batch_elements. This can be achieved by validating the input data and ensuring it meets the necessary requirements before passing it to the function.

Conclusion

In conclusion, the CVE-2021-29554 vulnerability in TensorFlow can be mitigated by updating to the patched versions or applying the temporary workaround. It is recommended to upgrade to TensorFlow 2.3.3 or 2.4.2 to ensure the security and stability of machine learning applications. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open-source machine learning framework used for developing and training deep learning models.

The vulnerability allows an attacker to cause a denial of service by triggering a floating-point exception runtime error.

To fix the vulnerability, update TensorFlow to version 2.3.3 or 2.4.2, which include the necessary patches.

A temporary workaround is to validate the input data to avoid triggering the vulnerability.

The vulnerability has a CVSS score of 2.5, indicating a low severity level.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip 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 →

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