CVE-2021-29596: TensorFlow - Division by Zero Error in EmbeddingLookup Operator

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Low
2.5

CVE-2021-29596: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow 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 < f61c57bd425878be108ec787f4d96390579fb83e

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-29596 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 EmbeddingLookup operator is a key component in TensorFlow that allows efficient lookup of embeddings in a model. However, a vulnerability has been discovered in the implementation of this operator, which can lead to a division by zero error.

Vulnerability Detail

The vulnerability in the EmbeddingLookup TFLite operator arises from a division by zero error. An attacker can exploit this vulnerability by crafting a model in such a way that the first dimension of the value input is set to 0. This triggers the division by zero error, potentially leading to a crash or other unintended behavior. The vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2, 2.3.3, 2.2.3, and 2.1.4. The TensorFlow team has addressed this issue and the fix will be included in TensorFlow 2.5.0.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow==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==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow==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 first dimension of the value input in their models is not set to 0. By avoiding this specific configuration, the division by zero error can be mitigated. Here is an example of how to modify the value input to avoid the vulnerability:

import tensorflow as tf

# Load the model
model = tf.keras.models.load_model('model.h5')

# Modify the value input
value = tf.constant([[1, 2, 3]])  # Ensure the first dimension is not 0

# Perform the embedding lookup
result = model.layers[0](value)

Conclusion

The vulnerability in the EmbeddingLookup TFLite operator has been addressed by the TensorFlow team. Users are advised to update their TensorFlow installation to version 2.5.0 or one of the fixed versions within the supported range. By applying the recommended fix, the division by zero error can be mitigated. 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 that provides a comprehensive set of tools and resources for developing and deploying machine learning models.

The EmbeddingLookup operator is a component in TensorFlow that allows efficient lookup of embeddings in a model. It is commonly used in natural language processing and recommendation systems.

An attacker can exploit this vulnerability by crafting a model in such a way that the first dimension of the value input is set to 0. This triggers a division by zero error, potentially leading to a crash or other unintended behavior.

The vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2, 2.3.3, 2.2.3, and 2.1.4. TensorFlow versions 2.5.0 and above are not affected.

To fix this vulnerability, it is recommended to update TensorFlow to version 2.5.0 once it is released. Alternatively, users can update to TensorFlow 2.4.2, 2.3.3, 2.2.3, or 2.1.4, which include the fix.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

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