CVE-2021-29619: Segfault in tf.raw_ops.SparseCountSparseOutput in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
Low
2.5

CVE-2021-29619: Segfault in tf.raw_ops.SparseCountSparseOutput. Affects tensorflow across 4 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2

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-29619 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 open-source machine learning framework widely used for building and training various models. It provides a comprehensive ecosystem for developing and deploying machine learning applications. TensorFlow includes the tf.raw_ops.SparseCountSparseOutput function, which is used for counting the number of non-zero elements in a sparse tensor. However, a vulnerability has been discovered in this function that can lead to a segmentation fault when invalid arguments are passed.

Vulnerability Detail

The vulnerability (CVE-2021-29619) arises from the improper handling of invalid arguments in the tf.raw_ops.SparseCountSparseOutput function. When fuzzing or providing malformed inputs, this can trigger a segfault, causing the application to crash. An attacker could potentially exploit this vulnerability to disrupt the functioning of TensorFlow applications or execute arbitrary code.

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 workaround, if updating TensorFlow is not immediately feasible, you can avoid using the tf.raw_ops.SparseCountSparseOutput function in your code. By replacing it with alternative methods or avoiding the specific functionality it provides, you can reduce the risk of encountering this vulnerability.

Conclusion

In conclusion, the vulnerability (CVE-2021-29619) in TensorFlow's tf.raw_ops.SparseCountSparseOutput function can lead to a segfault when invalid arguments are passed. It is crucial to update to the patched versions of TensorFlow (2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4) to mitigate this vulnerability. Alternatively, you can avoid using the vulnerable function until the update is feasible. If you have any further questions or need assistance with vulnerability remediation, please reach out to DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

The vulnerability can result in a segfault, causing the application to crash. This can disrupt the normal functioning of TensorFlow applications and potentially be exploited by attackers to execute arbitrary code.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your Pipfile.lock and Vulert will analyze it for any open-source vulnerabilities, including this one.

No, not all versions of TensorFlow are affected. The vulnerability exists in TensorFlow versions 2.1.4 and above. It has been fixed in TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4.

Yes, the CVSS score for this vulnerability is 2.5, indicating a low severity level.

You can refer to TensorFlow's security guide available at https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md for more information on their security model and how to report issues or ask questions.

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