CVE-2021-37647: TensorFlow GPU - Null Pointer Dereference in SparseTensorSliceDataset
Summary
CVE-2021-37647: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-gpu across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< 02cc160e29d20631de3859c6653184e3f876b9d7
Fixed in 2.3.4 or 2.4.3, depending 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-37647 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 for building and deploying machine learning models. The TensorFlow GPU package, available on PyPI, is specifically designed to leverage GPU acceleration for faster training and inference. This vulnerability affects versions 2.3.0 to 2.3.3, 2.4.0 to 2.4.2, and 2.5.0 to 2.5.0 of the TensorFlow GPU package.
Vulnerability Detail
The vulnerability in TensorFlow GPU arises when the tf.raw_ops.SparseTensorSliceDataset function is called without providing valid arguments for a sparse tensor. Specifically, if the indices argument is empty while the values argument is not, the implementation fails to handle this scenario correctly. As a result, a null pointer dereference occurs, leading to a crash or potential code execution. This vulnerability can be exploited by an attacker who can supply malicious input to trigger the vulnerable code path.
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.3.0, < 2.3.42.3.4pip install --upgrade "tensorflow-gpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-gpu==2.4.3"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If immediate package update is not possible, a temporary workaround is to avoid calling the tf.raw_ops.SparseTensorSliceDataset function with an empty indices argument while providing a non-empty values argument. Developers can add a check in their code to ensure that both indices and values are either both empty or both non-empty before calling the function. Here's an example of a possible workaround:
import tensorflow as tf
def create_sparse_tensor(indices, values):
if indices and values:
dataset = tf.raw_ops.SparseTensorSliceDataset(indices, values)
# Rest of the code
else:
# Handle the case when either indices or values is empty
# Error handling or alternative logic
Conclusion
The vulnerability in TensorFlow GPU (CVE-2021-37647) allows for a null pointer dereference when certain arguments are not properly validated in the tf.raw_ops.SparseTensorSliceDataset function. This can be exploited by an attacker to cause a crash or potentially execute arbitrary code. To mitigate this vulnerability, users should update their TensorFlow GPU package to version 2.3.4, 2.4.3, 2.5.1, or later. Alternatively, a temporary workaround can be implemented by ensuring that both indices and values are either both empty or both non-empty before calling the vulnerable function. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-gpu →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem for building and deploying machine learning models. It offers a wide range of tools and libraries for tasks such as data preprocessing, model training, and model serving.
The TensorFlow GPU package is a specific variant of TensorFlow that is optimized to leverage GPU acceleration for faster training and inference. It is designed to take advantage of the parallel processing capabilities of GPUs to speed up machine learning computations.
The vulnerability in TensorFlow GPU can be exploited by an attacker to cause a crash or potentially execute arbitrary code. This can lead to a variety of security risks, including unauthorized access to sensitive data, denial of service, or the ability to take control of the affected system.
No, not all versions of TensorFlow GPU are affected. The vulnerability exists in versions 2.3.0 to 2.3.3, 2.4.0 to 2.4.2, and 2.5.0 to 2.5.0. It has been fixed in versions 2.3.4, 2.4.3, and 2.5.1, and later versions are not affected.
Users can protect themselves from this vulnerability by updating their TensorFlow GPU package to a fixed version (2.3.4, 2.4.3, 2.5.1, or later). It is also recommended to follow best practices for secure coding and input validation to minimize the risk of exploitation.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-gpu.