CVE-2021-29604: Vulnerability in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2021-29604: Division by zero in TFLite's implementation of hashtable lookup. 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

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 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 community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow is widely used in various domains, including computer vision, natural language processing, and deep learning. However, a vulnerability has been discovered in the TFLite implementation of hashtable lookup.

Vulnerability Detail

The vulnerability in TensorFlow's TFLite implementation of hashtable lookup arises from a division by zero error. Specifically, the issue can be triggered when a crafted model is used, causing the values's first dimension to be zero. This division by zero error can lead to unexpected behavior or crashes in the application using TensorFlow. The vulnerability has been assigned the identifier CVE-2021-29604 and has a severity rating of Medium.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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 avoid the vulnerability by ensuring that the values tensor's first dimension is not zero when using the TFLite hashtable lookup functionality. This can be achieved by validating the input data and handling cases where the first dimension is zero separately. Here is an example code snippet demonstrating the workaround:

import tensorflow as tf

# Validate the input data
if values.shape[0] == 0:
    # Handle the case where the first dimension is zero
    # ... (add your custom logic here)
else:
    # Perform the hashtable lookup
    result = tf.lookup.experimental.DenseHashTable.lookup(table, keys, values)

By explicitly checking and handling the case where the first dimension is zero, the vulnerability can be mitigated.

Conclusion

In conclusion, a vulnerability has been identified in TensorFlow's TFLite implementation of hashtable lookup. This vulnerability can be triggered by a crafted model, causing a division by zero error. The issue will be addressed in upcoming versions of TensorFlow, and users are advised to update to the fixed versions to ensure the security of their applications. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning, providing tools and libraries for building and deploying machine learning models.

TFLite is a lightweight version of TensorFlow designed for mobile and embedded devices.

The vulnerability arises from a division by zero error when a crafted model is used, causing the values's first dimension to be zero.

The vulnerability can lead to unexpected behavior or crashes in applications using TensorFlow's TFLite hashtable lookup functionality.

The vulnerability will be fixed in TensorFlow 2.5.0. Users are advised to update to the fixed versions once they are released.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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