CVE-2021-29581: TensorFlow-gpu - Denial of Service via Segmentation Faults
Summary
CVE-2021-29581: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu 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
- tensorflow · Bitnami
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
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.
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-gpu is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is widely used in various domains, including research, industry, and academia.
Vulnerability Detail
The vulnerability (CVE-2021-29581) exists in the tf.raw_ops.CTCBeamSearchDecoder function of TensorFlow-gpu. It arises due to a lack of validation, allowing an attacker to trigger a denial of service (DoS) attack by causing segmentation faults. The vulnerable implementation fails to detect cases when the input tensor is empty, leading to an attempt to read data from a null buffer. This can result in crashes and instability of the TensorFlow-gpu application. The issue has been identified and fixed in TensorFlow 2.5.0. However, earlier versions, including TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4, are also affected.
How To Fix
Latest published version: 2.12.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-gpu==2.12.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-gpu==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow-gpu==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow-gpu==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow-gpu==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 avoid the vulnerability by implementing input validation in their own code before invoking the tf.raw_ops.CTCBeamSearchDecoder function. This can be done by checking if the input tensor is empty or null before passing it to the function. Here's an example of how to perform this validation in Python:
import tensorflow as tf
def decode_ctc_beam_search(input_tensor):
if input_tensor is None or len(input_tensor) == 0:
raise ValueError('Input tensor is empty or null')
else:
return tf.raw_ops.CTCBeamSearchDecoder(input_tensor)
By incorporating this validation step, the application can prevent the vulnerability from being exploited.
Conclusion
In conclusion, the vulnerability (CVE-2021-29581) in TensorFlow-gpu's tf.raw_ops.CTCBeamSearchDecoder function can be exploited to trigger denial of service attacks. It is crucial to update TensorFlow-gpu to version 2.5.0 or later to fix the vulnerability. In the meantime, implementing input validation in the application code can serve as a temporary workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow-gpu is a variant of TensorFlow that utilizes GPU acceleration for faster computation. It is commonly used in machine learning applications that require high-performance computing.
The vulnerability allows an attacker to trigger denial of service attacks by causing segmentation faults in TensorFlow-gpu applications. This can lead to crashes and instability, potentially disrupting the functioning of machine learning models.
The vulnerability affects TensorFlow-gpu versions 2.1.4 and later, including TensorFlow-gpu 2.4.2, TensorFlow-gpu 2.3.3, TensorFlow-gpu 2.2.3, and TensorFlow-gpu 2.1.4.
Yes, the vulnerability has been fixed in TensorFlow-gpu 2.5.0. It is recommended to update to this version or later to mitigate the risk of exploitation.
Yes, a temporary workaround is to implement input validation in the application code before invoking the vulnerable function. By checking if the input tensor is empty or null, the application can prevent the vulnerability from being exploited.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.