CVE-2021-29549: Denial of Service in TensorFlow

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29549: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu 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 < 744009c9e5cc5d0447f0dc39d055f917e1fd9e16

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-29549 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 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 industries and research domains for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that can lead to a denial of service (DoS) attack.

Vulnerability Detail

The vulnerability, identified as CVE-2021-29549, exists in the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function of TensorFlow. An attacker can exploit this vulnerability by triggering a runtime division by zero error. The issue arises due to the lack of validation for a divisor being zero in the implementation of the function. By manipulating input shapes, an attacker can cause the computation of vector_num_elements to be zero, leading to a division by zero error. This vulnerability can result in a DoS condition, rendering the affected TensorFlow instance unresponsive.

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

As a temporary workaround, users can implement input validation to ensure that the divisor in the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function is not zero. By checking the divisor before performing the modulo operation, the vulnerability can be mitigated. Here is an example of how the input validation can be implemented in Python:

import tensorflow as tf

def safe_quantized_batch_norm_with_global_normalization(input, scale, offset, mean, variance, variance_epsilon, name=None):
    if tf.reduce_any(tf.equal(scale, 0.0)):
        raise ValueError('Scale divisor cannot be zero.')
    return tf.raw_ops.QuantizedBatchNormWithGlobalNormalization(input, scale, offset, mean, variance, variance_epsilon, name=name)

By using this modified function in place of the vulnerable one, the risk of a DoS attack can be mitigated.

Conclusion

In conclusion, a vulnerability has been identified in TensorFlow that can lead to a denial of service (DoS) attack. It is crucial to update TensorFlow to one of the fixed versions mentioned to mitigate the vulnerability. Additionally, implementing input validation as a temporary workaround can provide an extra layer of protection. For further support and assistance in 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 libraries for developing and deploying machine learning models.

This vulnerability can lead to a denial of service (DoS) attack, causing the affected TensorFlow instance to become unresponsive.

To fix this vulnerability, it is recommended to update TensorFlow to one of the fixed versions: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4.

Yes, a temporary workaround is to implement input validation to ensure that the divisor in the vulnerable function is not zero. By checking the divisor before performing the modulo operation, the vulnerability can be mitigated.

For more information about this vulnerability, you can refer to the official TensorFlow advisory and the CVE entry: CVE-2021-29549.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

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