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

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29596: 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 < 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 providing CPU support for TensorFlow. It allows users to run TensorFlow models on CPUs without the need for specialized hardware. The package is widely used in various industries and research fields for machine learning tasks.

Vulnerability Detail

The vulnerability identified as CVE-2021-29596 affects the EmbeddingLookup TFLite operator in TensorFlow-CPU. This operator is responsible for looking up embeddings in a tensor. The vulnerability arises from a division by zero error in the implementation of the operator. An attacker can exploit this vulnerability by crafting a model in which the first dimension of the 'value' input is set to 0. When the vulnerable operator processes this input, a division by zero occurs, leading to a potential crash or undefined behavior. The impact of this vulnerability can range from denial of service to potential 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 workaround, users can manually check and ensure that the first dimension of the 'value' input in their models is not set to 0. By validating the input data, users can mitigate the risk of encountering the division by zero error. Here is an example code snippet that demonstrates the validation:

import tensorflow as tf

value = ...  # Input tensor

if value.shape[0] == 0:
    raise ValueError('Invalid input: first dimension cannot be 0')

# Rest of the code

Conclusion

In conclusion, the division by zero vulnerability in the EmbeddingLookup operator of TensorFlow-CPU can be mitigated by updating the package to version 2.5.0 or later. Users should also ensure that the first dimension of the 'value' input in their models is not set to 0. 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 open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models. It is widely used in various industries and research fields.

TensorFlow-CPU is a specific package that provides CPU support for TensorFlow. It allows users to run TensorFlow models on CPUs without the need for specialized hardware.

The EmbeddingLookup operator is responsible for looking up embeddings in a tensor. It is commonly used in machine learning models that involve embedding layers.

An attacker can exploit this vulnerability by crafting a model in which the first dimension of the 'value' input is set to 0. When the vulnerable operator processes this input, a division by zero occurs, potentially leading to a crash or undefined behavior.

To fix this vulnerability, users of TensorFlow-CPU should update their package to version 2.5.0 or later, which includes the necessary fix to prevent the division by zero error.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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