CVE-2021-29588: TensorFlow - Division by Zero Vulnerability
Summary
CVE-2021-29588: Division by zero in TFLite's implementation of TransposeConv. 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-29588 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 building 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 the optimized implementation of the TransposeConv TFLite operator in TensorFlow.
Vulnerability Detail
The vulnerability in TensorFlow arises from a division by zero error in the optimized implementation of the TransposeConv TFLite operator. This vulnerability can be exploited by an attacker who crafts a malicious model with stride_{h,w} values set to 0. When the vulnerable code is called with these arguments, a division by zero occurs, leading to a potential crash or arbitrary code execution. It is crucial for code using this function to validate the stride_{h,w} arguments to prevent this vulnerability.
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 temporary workaround, users can manually validate the stride_{h,w} arguments before calling the vulnerable code. By checking if the stride_{h,w} values are non-zero, the division by zero error can be avoided. Here is an example of how to perform the validation in Python:
if stride_h != 0 and stride_w != 0:
# Call the vulnerable code
else:
# Handle the case where stride_h or stride_w is 0
Note that this workaround should only be used until the fixed versions of TensorFlow are available.
Conclusion
In conclusion, the vulnerability in TensorFlow's optimized implementation of the TransposeConv TFLite operator can be exploited by an attacker to cause a division by zero error. This can lead to crashes or arbitrary code execution. Users are advised to update their TensorFlow installations to the fixed versions as soon as they are released. Regularly updating TensorFlow is important to stay protected against potential security vulnerabilities. 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 building and deploying machine learning models.
The TransposeConv TFLite operator is an optimized implementation in TensorFlow for performing transposed convolution operations, commonly used in tasks like image upsampling and deconvolution.
An attacker can exploit this vulnerability by crafting a malicious model with stride_{h,w} values set to 0. When the vulnerable code is called with these arguments, a division by zero occurs, potentially leading to a crash or arbitrary code execution.
The vulnerability affects TensorFlow versions 0 and 2.1.4 to 2.4.2. The fix will be included in TensorFlow 2.5.0, and backported to TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4.
To protect your TensorFlow installation, it is recommended to update to the fixed versions once they become available. Regularly updating TensorFlow ensures that you have the latest security patches applied.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.