CVE-2021-29589: TensorFlow-GPU - Division by Zero Error in GatherNd TFLite Operator

tensorflow-gpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-gpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-gpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

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.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-gpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-gpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-gpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback