CVE-2021-29609: TensorFlow-CPU Incomplete Validation in SparseAdd
Summary
CVE-2021-29609: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 6 version ranges.
< 2.1.4
>= 2.2.0, < 2.2.3
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
< 6fd02f44810754ae7481838b6a67c5df7f909ca3
< 41727ff06111117bdf86b37db198217fd7a143cc
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-29609 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 running TensorFlow on CPUs. It is widely used in various industries and research domains for machine learning tasks.
Vulnerability Detail
The vulnerability (CVE-2021-29609) in TensorFlow-CPU resides in the SparseAdd function. This function is responsible for adding two sparse tensors together. However, the implementation of SparseAdd lacks proper validation for the input tensors, allowing attackers to exploit undefined behavior and write outside the bounds of heap allocated data. Specifically, the validation does not check if the tensors are empty or if the second dimension of *_indices matches the size of the corresponding *_shape. This oversight enables attackers to send tensor triples that represent invalid sparse tensors, bypassing the existing validation checks and potentially leading to code execution or memory corruption. The vulnerability affects multiple versions of TensorFlow-CPU, including 2.1.4, 2.2.3, 2.3.3, and 2.4.2.
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 temporary workaround, users can consider implementing their own validation checks before using the SparseAdd function. This can involve verifying that the input tensors are not empty and that the dimensions of the *_indices match the corresponding *_shape. By performing these checks, users can mitigate the risk of exploitation until the official fix is applied.
Conclusion
The vulnerability in TensorFlow-CPU's SparseAdd function exposes users to the risk of code execution and memory corruption. It is crucial to update to the latest version of TensorFlow-CPU as soon as the fix is released. In the meantime, implementing custom validation checks can serve as a temporary workaround. 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.
TensorFlow-CPU is a specific package that focuses on running TensorFlow on CPUs. It is widely used in various industries and research domains for machine learning tasks.
This vulnerability allows attackers to exploit undefined behavior and write outside the bounds of heap allocated data. It can potentially lead to code execution or memory corruption, posing a significant security risk.
The vulnerability affects TensorFlow-CPU versions 2.1.4, 2.2.3, 2.3.3, and 2.4.2. These versions do not properly validate the input tensors in the SparseAdd function.
The vulnerability will be fixed in TensorFlow 2.5.0. It is recommended to update to the latest version of TensorFlow-CPU once the fix becomes available. Backported fixes will also be provided for older versions.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.