CVE-2021-29546: TensorFlow Integer Division by Zero Vulnerability
Summary
CVE-2021-29546: 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
< 67784700869470d65d5f2ef20aeb5e97c31673cb
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-gpu · PyPI
The same CVE-2021-29546 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. The vulnerability described in this report affects the 'tensorflow-cpu' package, which is a Python package for running TensorFlow on CPUs. This package is commonly used when GPU acceleration is not available or required.
Vulnerability Detail
The vulnerability (CVE-2021-29546) in TensorFlow arises from an integer division by zero undefined behavior in the 'tf.raw_ops.QuantizedBiasAdd' function. The issue stems from the implementation of the Eigen kernel, specifically in the 'quantization_utils.h' file. The kernel performs a division by the number of elements of the smaller input, based on shape, without checking if the divisor is zero. This can lead to a division by zero error, resulting in unexpected behavior or crashes. An attacker can exploit this vulnerability to cause a denial-of-service (DoS) condition or potentially execute arbitrary code.
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.0rc02.2.0rc0pip install --upgrade "tensorflow-cpu==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-cpu==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-cpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip 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 workaround, if updating to the fixed versions is not immediately feasible, you can consider avoiding the usage of the 'tf.raw_ops.QuantizedBiasAdd' function in your code. This can be achieved by using alternative functions or methods provided by TensorFlow for similar functionality. Here is an example of a code snippet that demonstrates the workaround:
import tensorflow as tf
# Instead of using tf.raw_ops.QuantizedBiasAdd
# Use an alternative function or method
# Example:
# bias_added = tf.add(quantized_input, quantized_bias)
Conclusion
In conclusion, the CVE-2021-29546 vulnerability in TensorFlow poses a risk of integer division by zero undefined behavior in the 'tf.raw_ops.QuantizedBiasAdd' function. This can lead to a denial-of-service (DoS) condition or potential code execution. It is crucial to update to the fixed versions of TensorFlow to mitigate this vulnerability. If immediate updates are not possible, consider the provided workaround and avoid using the affected function. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
This vulnerability can potentially lead to a denial-of-service (DoS) condition or allow an attacker to execute arbitrary code. It is crucial to update to the fixed versions of TensorFlow to mitigate the risk.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. The Vulert Playground allows you to analyze your Pipfile.lock and provides real-time alerts for open-source vulnerabilities, including this TensorFlow vulnerability.
At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is essential to update to the fixed versions of TensorFlow to prevent potential exploitation.
The recommended mitigation is to update TensorFlow to the fixed versions. However, if immediate updates are not feasible, you can consider the provided workaround of avoiding the usage of the 'tf.raw_ops.QuantizedBiasAdd' function in your code.
Yes, this vulnerability specifically affects the 'tensorflow-cpu' package, which is used for running TensorFlow on CPUs. If you are using other TensorFlow packages, such as 'tensorflow-gpu' for GPU acceleration, this vulnerability does not impact those packages.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.