CVE-2021-29548: Division by 0 in tensorflow - Division by 0 in QuantizedBatchNormWithGlobalNormalization
Summary
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
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
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.
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.
No signup required · Results in about 60 seconds
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.42.1.4pip install --upgrade "tensorflow==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip 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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.