CVE-2021-29589: TensorFlow-CPU - Division by Zero Vulnerability

tensorflow-cpu 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-cpu 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 Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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-CPU is a specific package that focuses on running TensorFlow on CPUs. It is widely used in various industries for machine learning tasks.

Vulnerability Detail

The reference implementation of the GatherNd TFLite operator in TensorFlow-CPU is vulnerable to a division by zero error. This vulnerability can be exploited by an attacker by crafting a model with an empty tensor as the params input. When params_shape.Dims(.) is zero in at least one dimension, a division by zero occurs. This vulnerability can lead to a crash or unexpected behavior of the TensorFlow-CPU application. The issue has been identified and a fix will be included in TensorFlow 2.5.0. Additionally, the fix will be backported to TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4, as these versions are also affected and still within the supported range.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==2.21.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-cpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-cpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-cpu==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, users can check if their input tensor is empty before passing it to the GatherNd TFLite operator. By ensuring that the params input is not empty, the division by zero error can be avoided. Here is an example code snippet demonstrating the workaround:

import tensorflow as tf

params = tf.constant([])  # Check if params is empty
if tf.size(params) > 0:
    # Perform the TFLite operation
    result = tf.raw_ops.GatherNd(params)
else:
    # Handle the empty case
    result = tf.constant([])

Conclusion

The division by zero vulnerability in TensorFlow-CPU's GatherNd TFLite operator can be mitigated by updating to the patched versions or by applying the temporary workaround. It is crucial for users to promptly update their TensorFlow-CPU installations to ensure the security and stability of their machine learning applications. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

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-CPU is a specific package that focuses on running TensorFlow on CPUs. It is widely used in various industries for machine learning tasks.

GatherNd is a TensorFlow Lite (TFLite) operator that performs a gather operation on N-dimensional tensors. It is commonly used in machine learning models for indexing and gathering values from tensors.

An attacker can exploit this vulnerability by crafting a model with an empty tensor as the params input. When params_shape.Dims(.) is zero in at least one dimension, a division by zero occurs, leading to a crash or unexpected behavior of the TensorFlow-CPU application.

To fix this vulnerability, it is recommended to update TensorFlow-CPU to version 2.5.0 once it is released. For users on affected versions, the fix can be obtained by updating to the respective patched versions: TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

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