CVE-2021-29596: TensorFlow-CPU - Division by Zero Vulnerability in EmbeddingLookup Operator
Summary
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
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
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.
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.
No signup required · Results in about 60 seconds
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.42.1.4pip install --upgrade "tensorflow-cpu==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow-cpu==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow-cpu==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip 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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.