CVE-2021-29548: Division by 0 in tensorflow - Division by 0 in QuantizedBatchNormWithGlobalNormalization

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
Low
2.5

CVE-2021-29548: Division by 0 in QuantizedBatchNormWithGlobalNormalization. Affects tensorflow across 4 version ranges.

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

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-29548 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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an open-source machine learning framework that provides a comprehensive ecosystem of tools, libraries, and community resources. It is widely used for building and deploying machine learning models. The vulnerability affects the QuantizedBatchNormWithGlobalNormalization function in TensorFlow, which is responsible for performing batch normalization on quantized tensors. Batch normalization is a technique used to improve the training and performance of deep neural networks. The vulnerability allows an attacker to trigger a runtime division by zero error, leading to a denial of service.

Vulnerability Detail

The vulnerability arises due to the lack of proper validation of constraints in the implementation of the QuantizedBatchNormWithGlobalNormalization function. An attacker can exploit this vulnerability by providing specific inputs that result in a division by zero error. This can cause the affected TensorFlow application to crash, resulting in a denial of service. The impact of this vulnerability is limited to the availability of the application and does not directly lead to unauthorized access or data leakage.

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.1.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 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 using the QuantizedBatchNormWithGlobalNormalization function in their TensorFlow applications. By replacing the function with an alternative implementation or using a different approach for batch normalization, users can mitigate the risk of encountering the division by zero error. Here is an example of a workaround using a custom batch normalization implementation:

import tensorflow as tf

def custom_batch_norm(x):
    # Custom batch normalization implementation
    # ...
    return normalized_x

x = tf.constant([], shape=[0, 0, 0, 0], dtype=tf.quint8)
normalized_x = custom_batch_norm(x)

Conclusion

The division by zero vulnerability in the QuantizedBatchNormWithGlobalNormalization function of TensorFlow can be exploited by an attacker to cause a denial of service. The vulnerability has been patched in the latest version of TensorFlow, and users are advised to update their installations once the fix is released. In the meantime, a temporary workaround is available by avoiding the use of the affected function. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

The vulnerability allows an attacker to trigger a runtime division by zero error in TensorFlow, leading to a denial of service. However, it does not directly result in unauthorized access or data leakage.

The vulnerability has been patched in TensorFlow commit d6ed5bcfe1dcab9e85a4d39931bd18d99018e75b. To fix the vulnerability, it is recommended to update the TensorFlow package to the latest version once the fix is released.

As a temporary workaround, users can avoid using the QuantizedBatchNormWithGlobalNormalization function in their TensorFlow applications. By replacing the function with an alternative implementation or using a different approach for batch normalization, users can mitigate the risk of encountering the division by zero error.

The vulnerability affects TensorFlow versions 2.1.4, 2.2.3, 2.3.3, and 2.4.2. Users of these versions should update to the fixed version once it is released.

For more information, please refer to the TensorFlow GitHub repository and the security guide provided by the TensorFlow team.

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