CVE-2021-29589: TensorFlow - Division by Zero Error in GatherNd TFLite Operator
Summary
CVE-2021-29589: Division by zero in TFLite's implementation of GatherNd. 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-29589 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. The vulnerability affects the reference implementation of the GatherNd TFLite operator in TensorFlow. This operator is used for gathering elements from a tensor based on indices specified in another tensor. The vulnerability arises when the params input tensor is empty, resulting in a division by zero error. This vulnerability has been assigned the identifier CVE-2021-29589.
Vulnerability Detail
The vulnerability in the GatherNd TFLite operator allows an attacker to craft a malicious model that triggers a division by zero error. This can be achieved by providing an empty tensor as the params input, causing at least one dimension of params_shape.Dims(.) to be zero. The division by zero error can lead to various consequences, including crashes, denial of service, or potential information disclosure. The vulnerability has been classified as high severity with a CVSSv3 score of 8.8 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).
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 check the dimensions of the params input tensor before passing it to the GatherNd TFLite operator. If any dimension is zero, the operator should not be invoked to avoid triggering the division by zero error. Here is an example code snippet demonstrating the workaround:
import tensorflow as tf
params = ... # Get the `params` tensor
params_shape = tf.shape(params)
if 0 in params_shape:
# Handle the empty tensor case
...
else:
# Invoke the `GatherNd` TFLite operator
...
Conclusion
In conclusion, the vulnerability in the GatherNd TFLite operator of TensorFlow can be exploited by providing an empty tensor as the params input, resulting in a division by zero error. This vulnerability has been assigned the identifier CVE-2021-29589 and has a high severity rating. Users are advised to update their TensorFlow installations to the latest patched version and apply the provided workaround if necessary. 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 set of tools and resources for building and deploying machine learning models.
The GatherNd TFLite operator is used in TensorFlow for gathering elements from a tensor based on indices specified in another tensor.
The vulnerability arises when the params input tensor of the GatherNd TFLite operator is empty, causing a division by zero error.
The consequences of this vulnerability can include crashes, denial of service, or potential information disclosure.
The vulnerability will be fixed in TensorFlow 2.5.0. Users should update their TensorFlow installations to the latest patched version as soon as it becomes available.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.