CVE-2021-29604: TensorFlow Hashtable Lookup Division by Zero Vulnerability

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29604: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 5 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2 < 5117e0851348065ed59c991562c0ec80d9193db2

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-29604 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. The TensorFlow Lite (TFLite) implementation of hashtable lookup is vulnerable to a division by zero error. This vulnerability can be exploited by an attacker who crafts a model in such a way that the values tensor's first dimension is set to zero. This vulnerability affects multiple versions of TensorFlow, including 2.1.4, 2.2.3, 2.3.3, and 2.4.2.

Vulnerability Detail

The vulnerability arises due to a division by zero error in the hashtable lookup implementation of TensorFlow Lite. When the values tensor's first dimension is set to zero, a division operation is performed, leading to a runtime error. An attacker can exploit this vulnerability by crafting a malicious model that triggers the division by zero error. The impact of this vulnerability can range from denial of service to potential information disclosure or arbitrary code execution.

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==2.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 ensure that the values tensor's first dimension is always set to a non-zero value in their models. By avoiding a zero value for the first dimension, the division by zero error can be prevented. Here is an example code snippet that demonstrates the workaround:

import tensorflow as tf

# Ensure the first dimension of `values` is non-zero
values = tf.constant([[1, 2, 3], [4, 5, 6]])

# Perform hashtable lookup
result = tf.lookup.experimental.DenseHashTable().lookup(values)

By setting values to a non-zero tensor, the vulnerability can be mitigated.

Conclusion

The division by zero vulnerability in TensorFlow's hashtable lookup implementation can be exploited by crafting a malicious model. To mitigate this vulnerability, users should update their TensorFlow installations to the patched versions once they are available. In the meantime, a temporary workaround is to ensure that the values tensor's first dimension is always set to a non-zero value. For further support on vulnerability remediation, contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem of tools and resources for developing and deploying machine learning models.

The vulnerability is a division by zero error in the hashtable lookup implementation of TensorFlow Lite. It can be exploited by crafting a model with a zero value for the first dimension of the values tensor.

The consequences of this vulnerability can range from denial of service to potential information disclosure or arbitrary code execution, depending on how it is exploited.

The vulnerability affects TensorFlow versions 2.1.4, 2.2.3, 2.3.3, and 2.4.2.

The vulnerability will be fixed in TensorFlow 2.5.0. It will also be backported to earlier versions, including 2.4.2, 2.3.3, 2.2.3, and 2.1.4. Users are advised to update their TensorFlow installations to the patched versions once they are available.

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==2.4.2"

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