CVE-2021-37647: TensorFlow-CPU - Null Pointer Dereference in SparseTensorSliceDataset
Summary
CVE-2021-37647: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu 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-gpu · 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. TensorFlow-CPU is a Python package that includes the CPU-only version of TensorFlow. It allows users to leverage the power of TensorFlow on systems without GPU support.
Vulnerability Detail
The vulnerability (CVE-2021-37647) exists in the tf.raw_ops.SparseTensorSliceDataset implementation of TensorFlow-CPU. When a user fails to supply valid arguments for a sparse tensor, the implementation can dereference a null pointer. Specifically, if the user provides empty indices while values are not empty, the code fails to handle this case and results in a null pointer dereference. This occurs when the code attempts to validate the indices by checking if they are monotonically increasing. As a result, an attacker could potentially exploit this vulnerability to cause a denial of service (null pointer dereference) or execute arbitrary code.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow-cpu==2.21.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-cpu==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow-cpu==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
As a workaround, users can ensure that both indices and values are provided for a sparse tensor. If either indices or values is empty, the vulnerability can be avoided. Here's an example of how to create a sparse tensor with non-empty indices and values:
import tensorflow as tf
indices = tf.constant([[0, 0], [1, 2]], dtype=tf.int64)
values = tf.constant([1, 2], dtype=tf.float32)
shape = tf.constant([3, 4], dtype=tf.int64)
sparse_tensor = tf.sparse.SparseTensor(indices, values, shape)
By ensuring that both indices and values are provided, the vulnerability can be mitigated.
Conclusion
The vulnerability (CVE-2021-37647) in TensorFlow-CPU's tf.raw_ops.SparseTensorSliceDataset implementation can lead to a null pointer dereference. This can result in a denial of service or potential execution of arbitrary code. Users are advised to update their TensorFlow-CPU package to one of the patched versions (TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4) and ensure that both indices and values are provided for sparse tensors. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow-cpu →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem for building and deploying machine learning models.
TensorFlow-CPU is a Python package that includes the CPU-only version of TensorFlow. It allows users to leverage the power of TensorFlow on systems without GPU support.
The vulnerability can lead to a null pointer dereference, resulting in a denial of service or potential execution of arbitrary code. An attacker could exploit this vulnerability to disrupt the availability of TensorFlow-CPU or gain unauthorized access to the system.
To fix this vulnerability, users should update their TensorFlow-CPU package to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4. Updating the package can be done by running the command: pip install --upgrade tensorflow-cpu.
Yes, a workaround is to ensure that both indices and values are provided for a sparse tensor. If either indices or values is empty, the vulnerability can be avoided.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow-cpu.