CVE-2021-41221: TensorFlow GPU - Heap Buffer Overflow in Cudnn* Operations
Summary
CVE-2021-41221: 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
< af5fcebb37c8b5d71c237f4e59c6477015c78ce6
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-41221 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 the power of GPUs for accelerated computation. It allows users to train and run machine learning models on GPU devices, enabling faster and more efficient processing of large datasets. However, a vulnerability has been discovered in TensorFlow GPU that can lead to a heap buffer overflow in the shape inference code for the Cudnn* operations.
Vulnerability Detail
The vulnerability in TensorFlow GPU arises due to the lack of validation for the ranks of the input, input_h, and input_c parameters in the shape inference code for the Cudnn* operations. This allows an attacker to trick the code into accessing invalid memory, resulting in a heap buffer overflow. The code assumes certain values for the ranks of these parameters, but does not verify them, leading to the vulnerability. An attacker could exploit this vulnerability to execute arbitrary code, cause a denial of service, or potentially gain unauthorized access to sensitive information. The vulnerability affects versions of TensorFlow GPU prior to 2.7.0.
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
There is no known workaround for this vulnerability. It is recommended to apply the fix by upgrading to a patched version of TensorFlow GPU.
Conclusion
The vulnerability in TensorFlow GPU (CVE-2021-41221) is a heap buffer overflow in the shape inference code for the Cudnn* operations. It can be exploited by an attacker to execute arbitrary code, cause a denial of service, or potentially gain unauthorized access to sensitive information. To mitigate this vulnerability, it is recommended to upgrade to a patched version of TensorFlow GPU, such as version 2.7.0 or later. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow GPU is a variant of TensorFlow that utilizes GPU devices for accelerated machine learning computations. It allows for faster training and inference of machine learning models by leveraging the parallel processing capabilities of GPUs.
Cudnn* operations in TensorFlow refer to the operations that utilize the cuDNN library, which is a GPU-accelerated deep neural network library. These operations provide optimized implementations of common deep learning primitives, such as convolutions and pooling, for efficient execution on GPUs.
A heap buffer overflow is a type of memory corruption vulnerability where a program writes data beyond the bounds of a dynamically allocated buffer in the heap. This can lead to memory corruption, crashes, and potentially allow an attacker to execute arbitrary code or gain unauthorized access to sensitive information.
This vulnerability could allow an attacker to execute arbitrary code, cause a denial of service, or potentially gain unauthorized access to sensitive information. The impact depends on the context in which TensorFlow GPU is deployed and the privileges of the user running the vulnerable code.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your TensorFlow GPU installation is affected by this vulnerability. The Vulert Playground allows you to analyze your Pipfile.lock and provides real-time monitoring and alerts for open-source vulnerabilities in your software.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.