CVE-2021-41213: Denial of Service Vulnerability in TensorFlow-GPU
Summary
CVE-2021-41213: TensorFlow is an open source platform for machine learning. Affects tensorflow-gpu across 5 version ranges.
< 2.4.4
>= 2.5.0, < 2.5.2
>= 2.6.0, < 2.6.1
>= 2.7.0rc0, < 2.7.0
< afac8158d43691661ad083f6dd9e56f327c1dcb7
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-41213 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 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 industries and research domains for training and inference of deep learning models.
Vulnerability Detail
The vulnerability (CVE-2021-41213) exists in the code behind the tf.function API in TensorFlow. When two tf.function decorated Python functions are mutually recursive, a deadlock can occur due to the usage of a non-reentrant Lock Python object. This vulnerability can be exploited by an attacker to cause a denial of service (DoS) by loading a model containing mutually recursive functions and invoking a recursive tf.function. Although this scenario is not frequent, it can impact users who load such models. The vulnerability has been identified and fixed in TensorFlow versions 2.7.0, 2.6.1, 2.5.2, and 2.4.4.
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.4.42.4.4pip install --upgrade "tensorflow-gpu==2.4.4" -
>= 2.5.0, < 2.5.22.5.2pip install --upgrade "tensorflow-gpu==2.5.2" -
>= 2.6.0, < 2.6.12.6.1pip install --upgrade "tensorflow-gpu==2.6.1" -
>= 2.7.0rc0, < 2.7.02.7.0pip install --upgrade "tensorflow-gpu==2.7.0"
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 you are unable to immediately update to the fixed versions, you can avoid the vulnerability by refraining from using mutually recursive tf.function decorated Python functions in your models. By restructuring your code to eliminate mutual recursion, you can mitigate the risk of encountering the deadlock issue.
Conclusion
The vulnerability (CVE-2021-41213) in TensorFlow-GPU's tf.function API can lead to a deadlock when mutually recursive functions are used. This can result in a denial of service (DoS) scenario, although it is not a common occurrence. To mitigate the risk, it is recommended to update TensorFlow-GPU to the latest fixed version or apply the provided workaround. For further assistance and support in vulnerability remediation, please reach out to DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow-GPU is a variant of TensorFlow that utilizes GPU acceleration for faster computation of machine learning models.
tf.function is an API in TensorFlow that allows users to decorate Python functions and convert them into TensorFlow graph functions for improved performance.
The vulnerability can lead to a deadlock when two mutually recursive tf.function decorated Python functions are used. This can cause a denial of service (DoS) scenario, although it is not a frequent occurrence.
To fix the vulnerability, it is recommended to update TensorFlow-GPU to the latest fixed version. Specifically, upgrading to TensorFlow-GPU version 2.7.0 or the corresponding fixed versions (2.6.1, 2.5.2, or 2.4.4) will resolve the issue.
As a workaround, if immediate updating is not possible, users can avoid the vulnerability by refraining from using mutually recursive tf.function decorated Python functions in their models.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.