CVE-2021-29581: TensorFlow - Denial of Service via Segmentation Faults

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Low
2.5

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

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-29581 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 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 is widely used in various domains, including research, industry, and academia. It offers a range of functionalities for building and training machine learning models, including support for neural networks, deep learning, and natural language processing.

Vulnerability Detail

The vulnerability (CVE-2021-29581) in TensorFlow arises from a lack of validation in the tf.raw_ops.CTCBeamSearchDecoder function. This vulnerability allows an attacker to trigger a denial of service attack by causing segmentation faults. The implementation of the function fails to detect cases when the input tensor is empty and proceeds to read data from a null buffer. This can lead to crashes and instability in the TensorFlow application. The impact of this vulnerability can range from disruption of service to potential exploitation of other vulnerabilities in the system.

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, users can add input validation checks before calling the tf.raw_ops.CTCBeamSearchDecoder function. This can involve verifying the size and content of the input tensor to ensure it is not empty or null. By implementing these checks, the risk of triggering the vulnerability can be mitigated. Here is an example of how to perform input validation in Python:

import tensorflow as tf

def validate_input(tensor):
    if tensor is None or tf.size(tensor) == 0:
        raise ValueError('Input tensor is empty or null')

# Usage
input_tensor = ...
validate_input(input_tensor)
# Call CTCBeamSearchDecoder function
...

Conclusion

The vulnerability (CVE-2021-29581) in TensorFlow's tf.raw_ops.CTCBeamSearchDecoder function can be exploited to trigger denial of service attacks. Upgrading to TensorFlow 2.5.0 or applying the backported fixes in earlier versions is recommended to mitigate the risk. Implementing input validation checks can serve as a temporary workaround. Regularly updating TensorFlow and its dependencies is crucial for maintaining a secure machine learning environment. For further support on 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 and resources for developing and deploying machine learning models.

The vulnerability allows an attacker to trigger denial of service attacks by causing segmentation faults in TensorFlow applications. This can lead to crashes and instability, potentially disrupting the service or providing an avenue for further exploitation.

To fix this vulnerability, it is recommended to upgrade to TensorFlow version 2.5.0 or any subsequent version. Alternatively, users can update to the backported fixes in TensorFlow versions 2.4.2, 2.3.3, 2.2.3, or 2.1.4. Regularly updating TensorFlow and its dependencies is crucial for maintaining security.

Yes, users can implement input validation checks before calling the vulnerable function. By verifying the size and content of the input tensor, the risk of triggering the vulnerability can be mitigated.

Yes, you can use Vulert's playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities without requiring access to the code or installation.

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