CVE-2021-29589: TensorFlow-GPU - Division by Zero Error in GatherNd TFLite Operator
Summary
CVE-2021-29589: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu 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
< 8e45822aa0b9f5df4b4c64f221e64dc930a70a9d
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-cpu · 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 ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow-GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. The GatherNd TFLite operator is a key component in TensorFlow-GPU that allows gathering elements from multiple tensors based on indices. This operator is vulnerable to a division by zero error when the 'params' input tensor is empty, leading to potential crashes or incorrect results in machine learning models.
Vulnerability Detail
The vulnerability in the GatherNd TFLite operator arises from a division by zero error in the reference implementation code. When the 'params' input tensor is empty, the 'params_shape.Dims(.)' function returns zero for at least one dimension. This triggers a division by zero error, which can have various consequences depending on how the operator is used within a machine learning model. An attacker can exploit this vulnerability by crafting a malicious model that triggers the division by zero error, potentially leading to crashes, incorrect results, or even remote code execution. The vulnerability has been assigned the identifier CVE-2021-29589.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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-gpu==2.2.0rc0" -
>= 2.2.0, < 2.3.0rc02.3.0rc0pip install --upgrade "tensorflow-gpu==2.3.0rc0" -
>= 2.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-gpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-gpu==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 temporary workaround, you can modify the affected machine learning models to handle the case of an empty 'params' input tensor. One possible approach is to add a check for an empty tensor before invoking the GatherNd TFLite operator. If the 'params' tensor is empty, you can either skip the operation or provide default values to avoid triggering the division by zero error. Here's an example of how you can implement this workaround in Python:
import tensorflow as tf
params = ... # Your 'params' tensor
if tf.size(params) == 0:
# Handle the empty tensor case
...
else:
# Invoke the GatherNd TFLite operator
output = tf.gather_nd(params, indices)
Note that this workaround is not a permanent solution and should be replaced with the recommended fix as soon as possible.
Conclusion
The vulnerability in the GatherNd TFLite operator of TensorFlow-GPU can result in a division by zero error when the 'params' input tensor is empty. This can lead to crashes, incorrect results, or even remote code execution. It is crucial to upgrade to the latest version of TensorFlow-GPU or apply the corresponding fixes to mitigate the risk. Rebuilding and retesting affected machine learning models is also necessary to ensure correct behavior. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow-GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It allows developers to harness the power of GPUs to train and deploy machine learning models more efficiently.
The GatherNd TFLite operator is a component in TensorFlow-GPU that enables gathering elements from multiple tensors based on indices. It is commonly used in machine learning models for operations such as indexing and slicing.
The division by zero error in the GatherNd TFLite operator occurs when the 'params' input tensor is empty, causing the 'params_shape.Dims(.)' function to return zero for at least one dimension. This triggers the division by zero error during the execution of the operator.
The division by zero error in the GatherNd TFLite operator can lead to various consequences depending on how the operator is used within a machine learning model. These include crashes, incorrect results, and potentially even remote code execution if the vulnerability is exploited by an attacker.
To fix this vulnerability, it is recommended to upgrade TensorFlow-GPU to version 2.5.0 or higher. If you are using an affected version (2.4.2, 2.3.3, 2.2.3, or 2.1.4), you should upgrade to the corresponding fixed version. Additionally, you should rebuild and retest any machine learning models that utilize the GatherNd TFLite operator to ensure correct behavior.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.