CVE-2021-29609: TensorFlow Incomplete Validation in SparseAdd

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Moderate
5.3

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

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.

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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive set of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. It supports both deep learning and traditional machine learning algorithms, making it a versatile framework for developing and training models. However, TensorFlow is susceptible to vulnerabilities that can be exploited by attackers to compromise the integrity and security of machine learning applications.

Vulnerability Detail

The vulnerability identified as CVE-2021-29609 in TensorFlow involves incomplete validation in the SparseAdd function. This vulnerability allows attackers to exploit undefined behavior, such as dereferencing null pointers, and write outside the bounds of heap allocated data. The SparseAdd function is responsible for adding two sparse tensors, but it fails to validate that the tensors are not empty or that 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. As a result, the code assumptions are abused, leading to potential security breaches and unauthorized access to sensitive information. The impact of this vulnerability can be severe, as it can compromise the confidentiality, integrity, and availability of machine learning models and their associated data.

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 implement their own validation checks before invoking the SparseAdd function. This can involve verifying that the tensors are not empty and that the second dimension of *_indices matches the size of the corresponding *_shape. By adding these additional checks, users can mitigate the risk of exploitation until the official fix is applied.

Conclusion

The vulnerability in TensorFlow (CVE-2021-29609) exposes a critical flaw in the SparseAdd function, allowing attackers to exploit undefined behavior and write outside the bounds of heap allocated data. This can lead to severe security breaches and compromise the integrity and availability of machine learning models. It is crucial for users to update their TensorFlow installations to the latest patched version and apply the necessary fixes. For further support and assistance in 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, libraries, and resources for building and deploying machine learning models.

This vulnerability allows attackers to exploit undefined behavior and write outside the bounds of heap allocated data. It can lead to security breaches, unauthorized access, and compromise the confidentiality, integrity, and availability of machine learning models and their associated data.

The vulnerability affects TensorFlow versions 2.1.4 and above, including TensorFlow 2.2.3, TensorFlow 2.3.3, TensorFlow 2.4.2, and TensorFlow 2.5.0 (prior to the fix).

The vulnerability will be fixed in TensorFlow 2.5.0. Users are advised to update their TensorFlow installations to the latest patched version as soon as it becomes available. Backported fixes will also be provided for TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4.

As a temporary workaround, users can implement their own validation checks before using the SparseAdd function. This involves verifying that the tensors are not empty and that the second dimension of *_indices matches the size of the corresponding *_shape.

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