CVE-2021-29518: TensorFlow GPU - Null Pointer Dereference in Eager Mode
Summary
CVE-2021-29518: 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
< ff70c47a396ef1e3cb73c90513da4f5cb71bebba
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-29518 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 the power of GPUs for accelerated computation. It allows users to train and run machine learning models on GPU hardware, enabling faster and more efficient processing of large datasets. However, a vulnerability has been discovered in TensorFlow GPU that can lead to a null pointer dereference in eager mode, potentially causing the application to crash or behave unpredictably.
Vulnerability Detail
In eager mode, session operations in TensorFlow GPU are invalid. However, users can still call the raw ops associated with these operations, which can trigger a null pointer dereference. The implementation of these ops dereferences the session state pointer without checking if it is valid. As a result, when called in eager mode, the ctx->session_state() function returns a null pointer, leading to undefined behavior. This vulnerability affects TensorFlow versions 2.0 and later. An attacker could potentially exploit this vulnerability to crash the application or execute arbitrary code.
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 workaround, users can switch from eager mode to graph mode in TensorFlow GPU. Graph mode does not exhibit the same vulnerability and can be used as a temporary solution until the upgrade to a fixed version is performed. To switch to graph mode, users can modify their code to use the tf.compat.v1.disable_eager_execution() function before executing any session operations.
Conclusion
The vulnerability in TensorFlow GPU can lead to a null pointer dereference in eager mode, potentially causing the application to crash or behave unpredictably. It is crucial to upgrade to TensorFlow version 2.5.0 or any subsequent version to mitigate the risk. Alternatively, switching to graph mode can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow GPU is a variant of TensorFlow that utilizes GPU hardware for accelerated computation in machine learning tasks.
Eager mode in TensorFlow allows for immediate execution of operations, providing a more interactive and intuitive programming experience.
This vulnerability affects TensorFlow GPU versions 2.0 and later when used in eager mode. It can lead to a null pointer dereference and undefined behavior.
The vulnerability can cause the application to crash or behave unpredictably. In some cases, it may also allow an attacker to execute arbitrary code.
To fix this vulnerability, it is recommended to upgrade to TensorFlow version 2.5.0 or any subsequent version. Alternatively, you can switch from eager mode to graph mode as a temporary workaround.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.