CVE-2021-29549: TensorFlow - Division by Zero Denial of Service
Summary
CVE-2021-29549: Division by 0 in QuantizedAdd. 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 · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
- tensorflow-gpu · 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 set 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 division by zero error and denial of service.
Vulnerability Detail
The vulnerability exists in the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function of TensorFlow. The implementation of this function performs a modulo operation without validating that the divisor is not zero. By manipulating the input shapes, an attacker can trigger scenarios where the divisor becomes zero, resulting in a runtime division by zero error. This error can cause the TensorFlow application to crash or become unresponsive, leading to a denial of service condition. The vulnerability has been assigned the CVE identifier CVE-2021-29549.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 2.1.42.1.4 -
>= 2.2.0, < 2.2.32.2.3 -
>= 2.3.0, < 2.3.32.3.3 -
>= 2.4.0, < 2.4.22.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 workaround, you can modify the affected code to include a check for zero divisor before performing the modulo operation. Here is an example of how the code can be modified:
def quantized_batch_norm_with_global_normalization(divisor):
if divisor == 0:
raise ValueError('Divisor cannot be zero')
# Rest of the code
Conclusion
In conclusion, TensorFlow is vulnerable to a division by zero error and denial of service in the tf.raw_ops.QuantizedBatchNormWithGlobalNormalization function. This vulnerability can be mitigated by upgrading to TensorFlow 2.5.0 once it is released or applying the provided patch to the affected versions. It is important to stay updated with the latest security patches and follow best practices for secure coding in TensorFlow applications. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides tools and resources for developing and deploying machine learning models.
This vulnerability can lead to a runtime division by zero error and denial of service in TensorFlow applications.
The vulnerability affects TensorFlow versions 2.1.4, 2.2.3, 2.3.3, and 2.4.2.
The vulnerability will be fixed in TensorFlow 2.5.0. It is recommended to upgrade to the latest version once it becomes available. In the meantime, you can apply the provided patch to the affected versions (2.1.4, 2.2.3, 2.3.3, and 2.4.2) to mitigate the risk.
Yes, you can modify the affected code to include a check for zero divisor before performing the modulo operation. Refer to the 'workaround' section for more details.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.