CVE-2021-29517: TensorFlow - Division by 0 in Conv3D Implementation
Summary
CVE-2021-29517: Division by zero in Conv3D. 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-29517 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 for building and deploying machine learning models. TensorFlow is widely used in various industries and research fields for tasks such as image recognition, natural language processing, and recommendation systems. This vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2, and it can be exploited by a malicious user to trigger a division by 0 in the Conv3D implementation.
Vulnerability Detail
The vulnerability arises from a modulo operation performed on user-controlled input in the Conv3D implementation of TensorFlow. When the fifth element of the 'filter' tensor is set to 0, a division by 0 occurs. Additionally, if the shape of the two tensors is invalid, it can trigger an Eigen assertion, leading to a program crash. This vulnerability can be exploited to cause denial of service (DoS) attacks or potentially execute arbitrary code.
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 validate the shape of the tensors before passing them to the Conv3D function. Additionally, it is important to ensure that the 'filter' tensor does not contain a 0 as its fifth element. Here is an example of how to perform the shape validation:
import tensorflow as tf
def validate_tensors(tensor1, tensor2):
if tensor1.shape != tensor2.shape:
raise ValueError('Invalid tensor shapes')
# Rest of the code
validate_tensors(tensor1, tensor2)
Conclusion
The vulnerability in TensorFlow's Conv3D implementation can be exploited to trigger a division by 0 and potentially cause denial of service (DoS) attacks or arbitrary code execution. It is crucial to upgrade to the patched versions or apply the recommended workarounds to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem for building and deploying machine learning models.
This vulnerability can be exploited by a malicious user to trigger a division by 0 in the Conv3D implementation, potentially leading to denial of service (DoS) attacks or arbitrary code execution.
Versions of TensorFlow ranging from 0 to 2.4.2 are affected by this vulnerability.
To fix this vulnerability, it is recommended to upgrade to the patched versions available for TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4.
Yes, as a temporary workaround, users can validate the shape of the tensors before passing them to the Conv3D function and ensure that the 'filter' tensor does not contain a 0 as its fifth element.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.