CVE-2021-29573: TensorFlow-CPU - Division by 0 in tf.raw_ops.MaxPoolGradWithArgmax

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2 < 376c352a37ce5a68b721406dc7e77ac4b6cf483d

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-29573 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-CPU is a specific package that focuses on providing CPU support for TensorFlow. It allows users to run TensorFlow models on CPUs without the need for GPU hardware. However, the package is vulnerable to a division by 0 issue in the implementation of tf.raw_ops.MaxPoolGradWithArgmax.

Vulnerability Detail

The vulnerability arises from a lack of validation in the implementation of tf.raw_ops.MaxPoolGradWithArgmax in TensorFlow-CPU. The code fails to check if the batch dimension of the tensor is non-zero before dividing by this quantity. As a result, when the batch dimension is 0, a division by 0 occurs, leading to a potential crash or unexpected behavior. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) attack or to manipulate the program's behavior.

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==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 workaround, users can manually validate the batch dimension of the tensor before calling the vulnerable function. By ensuring that the batch dimension is non-zero, the division by 0 issue can be avoided. Here is an example of how to perform the validation in Python:

import tensorflow as tf

# Assuming 'tensor' is the input tensor
batch_dim = tf.shape(tensor)[0]
if batch_dim != 0:
    result = tf.raw_ops.MaxPoolGradWithArgmax(...)
else:
    # Handle the case when batch dimension is 0
    ...

By explicitly checking the batch dimension, users can prevent the vulnerable code from executing when the batch dimension is 0.

Conclusion

The division by 0 vulnerability in TensorFlow-CPU's tf.raw_ops.MaxPoolGradWithArgmax has the potential to cause crashes or unexpected behavior. It is crucial for users of TensorFlow-CPU to update their package to version 2.5.0 or newer to fix this vulnerability. Additionally, users can implement the provided workaround to mitigate the issue. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

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. It is widely used in both research and production environments.

TensorFlow-CPU is a specific package that focuses on providing CPU support for TensorFlow. It allows users to run TensorFlow models on CPUs without the need for GPU hardware.

The vulnerability can lead to a division by 0, causing a potential crash or unexpected behavior in TensorFlow-CPU. It can be exploited by an attacker to launch a denial-of-service (DoS) attack or manipulate the program's behavior.

To fix this vulnerability, users of TensorFlow-CPU should update their package to the latest version available, which includes the necessary fix. Specifically, upgrading to TensorFlow-CPU version 2.5.0 or newer will resolve the division by 0 issue.

Yes, users can manually validate the batch dimension of the tensor before calling the vulnerable function to avoid the division by 0 issue. By ensuring that the batch dimension is non-zero, the vulnerability can be mitigated.

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==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