CVE-2021-29550: TensorFlow - Division by Zero Denial of Service

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Low
2.5

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

>= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < 548b5eaf23685d86f722233d8fbc21d0a4aecb96

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-29550 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. It offers support for both CPU and GPU computations, making it suitable for a wide range of hardware configurations. However, a vulnerability has been discovered in TensorFlow that can lead to a denial of service (DoS) attack.

Vulnerability Detail

The vulnerability (CVE-2021-29550) in TensorFlow exists in the tf.raw_ops.FractionalAvgPool function. An attacker can exploit this vulnerability by providing user-controlled values for input_size[i] and pooling_ratio_[i] parameters. If the value of input_size[i] is smaller than pooling_ratio_[i], the floor operation results in output_size[i] being 0. This leads to a division by zero error and a runtime crash. The issue arises due to the improper handling of user-controlled values in the computation of divisor quantity. In released versions of TensorFlow, the DCHECK_GT line, which could detect this issue, is a no-op outside of debug mode.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 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 manually validate the values of input_size[i] and pooling_ratio_[i] before passing them to the tf.raw_ops.FractionalAvgPool function. By ensuring that input_size[i] is greater than or equal to pooling_ratio_[i], the division by zero error can be avoided. Here is an example code snippet that demonstrates the workaround:

import tensorflow as tf

input_size = ...
pooling_ratio_ = ...

if input_size >= pooling_ratio_:
    output = tf.raw_ops.FractionalAvgPool(value, pooling_ratio_)
else:
    # Handle the case where input_size is smaller than pooling_ratio_
    ...

Conclusion

In conclusion, the vulnerability (CVE-2021-29550) in TensorFlow can be exploited by an attacker to cause a denial of service (DoS) by triggering a runtime division by zero error. The issue arises due to the improper handling of user-controlled values in the computation of divisor quantity. To mitigate this vulnerability, users should update their TensorFlow installations to the latest patched version once it becomes available. In the meantime, a temporary workaround is available by manually validating the input values. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

This vulnerability allows an attacker to cause a denial of service (DoS) by triggering a runtime division by zero error. This can lead to the crashing of TensorFlow applications, resulting in service disruption and potential loss of data.

You can use Vulert's vulnerability playground at Vulert Scanner to check if your TensorFlow installation is affected by this vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it for any open-source vulnerabilities, including CVE-2021-29550.

No, not all versions of TensorFlow are affected. The vulnerability exists in TensorFlow versions from 0 to 2.4.3. However, it is recommended to update to the latest patched version once it becomes available to ensure the security of your TensorFlow deployment.

Yes, the fix for this vulnerability will be included in TensorFlow 2.5.0. Additionally, the fix will be backported to earlier versions, including TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4. It is recommended to update your TensorFlow installation to the latest patched version as soon as it becomes available.

If you are unable to update to the latest TensorFlow version immediately, you can apply the temporary workaround mentioned in the 'workaround' section of this report. However, it is strongly recommended to update to the latest patched version as soon as possible to ensure the security and stability of your TensorFlow deployment.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 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