CVE-2021-29581: TensorFlow - Denial of Service via Segmentation Faults
Summary
CVE-2021-29581: Segfault in CTCBeamSearchDecoder. 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
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
- tensorflow-gpu · 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 community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow is widely used in various domains, including computer vision, natural language processing, and reinforcement learning. This vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2, and it can lead to denial of service through segmentation faults.
Vulnerability Detail
The vulnerability exists in the tf.raw_ops.CTCBeamSearchDecoder function of TensorFlow. Due to a lack of validation, an attacker can trigger a denial of service by exploiting segmentation faults. The implementation fails to detect cases when the input tensor is empty and proceeds to read data from a null buffer. This can result in crashes and instability of the TensorFlow application. The impact of this vulnerability can range from disruption of machine learning processes to potential data corruption or loss.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 2.1.42.1.4 -
>= 2.2.0, < 2.2.32.2.3 -
>= 2.3.0, < 2.3.32.3.3 -
>= 2.4.0, < 2.4.22.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 invoking the tf.raw_ops.CTCBeamSearchDecoder function. By ensuring that the input tensor is not empty, the vulnerability can be mitigated. Here is an example of how to perform the input validation in Python:
import tensorflow as tf
def safe_ctc_beam_search_decoder(inputs):
if tf.size(inputs) == 0:
raise ValueError('Input tensor cannot be empty')
else:
return tf.raw_ops.CTCBeamSearchDecoder(inputs)
Conclusion
The vulnerability in TensorFlow's tf.raw_ops.CTCBeamSearchDecoder function can be exploited to trigger denial of service through segmentation faults. Upgrading to TensorFlow 2.5.0 or applying the backported fixes in earlier versions is recommended to address this vulnerability. Additionally, users can implement input validation checks as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem of tools and libraries.
This vulnerability can lead to denial of service through segmentation faults, potentially disrupting machine learning processes and causing data corruption or loss.
Versions of TensorFlow ranging from 0 to 2.4.2 are affected by this vulnerability.
To fix this vulnerability, it is recommended to upgrade to TensorFlow 2.5.0 or any subsequent fixed versions. Alternatively, you can update to one of the backported fixes in TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4.
Yes, a workaround is available. Users can add input validation checks before invoking the vulnerable function to mitigate the issue.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.