CVE-2021-29549: Denial of Service in TensorFlow
Summary
CVE-2021-29549: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu 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
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
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.
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 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 supports both CPU and GPU computations, allowing for efficient training and inference on different hardware architectures.
Vulnerability Detail
The vulnerability identified as CVE-2021-29549 affects the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function in TensorFlow. An attacker can exploit this vulnerability to cause a runtime division by zero error, leading to a denial of service. The vulnerability arises from a lack of validation in the implementation of the function, specifically in the computation of a modulo operation without checking if the divisor is zero. By manipulating the input shapes, an attacker can trigger scenarios where the divisor becomes zero, resulting in a division by zero error and subsequent denial of service. The impact of this vulnerability can disrupt the availability of TensorFlow-based applications and systems.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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.0rc02.2.0rc0pip install --upgrade "tensorflow-gpu==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-gpu==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-gpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-gpu==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 in their own code to ensure that the input shapes passed to the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function do not trigger a division by zero scenario. This can be achieved by checking the input shapes and avoiding cases where the divisor becomes zero. Here is an example of how the input validation can be performed in Python:
import tensorflow as tf
def safe_quantized_batch_norm(input_tensor, scale, offset):
if input_tensor.shape[0] == 0 or scale.shape[0] == 0 or offset.shape[0] == 0:
raise ValueError('Invalid input shapes')
else:
return tf.raw_ops.QuantizedBatchNormWithGlobalNormalization(input_tensor, scale, offset)
Conclusion
In conclusion, the vulnerability identified as CVE-2021-29549 in TensorFlow can lead to a denial of service by causing a runtime division by zero error. It is crucial for users to update their TensorFlow installation to one of the fixed versions mentioned above to mitigate this vulnerability. Additionally, implementing input validation in user code can serve as a temporary workaround until the upgrade is performed. For further support and guidance on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
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. It is widely used in various domains, including research, industry, and academia.
The vulnerability can be exploited by an attacker to cause a runtime division by zero error, resulting in a denial of service. This can disrupt the availability of TensorFlow-based applications and systems.
To fix this vulnerability, it is recommended to upgrade to one of the fixed versions of TensorFlow: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4. Users can update their TensorFlow installation using the package manager or by manually downloading and installing the fixed version from the official TensorFlow repository.
Yes, as a temporary workaround, users can implement input validation in their own code to ensure that the input shapes passed to the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function do not trigger a division by zero scenario. This can be achieved by checking the input shapes and avoiding cases where the divisor becomes zero.
For more information about this vulnerability, you can refer to the official CVE entry: CVE-2021-29549. Additionally, you can reach out to the TensorFlow development team or consult the official TensorFlow documentation for guidance on vulnerability remediation.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.