CVE-2021-37647: TensorFlow - Null Pointer Dereference in SparseTensorSliceDataset

tensorflow Updated 02 Oct 2025

Summary

12/08/2021
Yes i
High
7.7

CVE-2021-37647: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow 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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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 includes various functionalities and APIs for handling data, training models, and serving predictions. The package is widely used in both research and production environments.

Vulnerability Detail

The vulnerability (CVE-2021-37647) in TensorFlow arises when a user fails to supply valid arguments for a sparse tensor in the tf.raw_ops.SparseTensorSliceDataset function. The implementation of this function does not properly handle the case when either the indices or values argument is provided for an empty sparse tensor while the other is not. This oversight leads to a null pointer dereference in the code. Specifically, if the indices provided by the user is empty, the C++ code attempts to access the dimension size of the empty std::vector, resulting in a null pointer dereference. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) condition or potentially execute arbitrary code.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow==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.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==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 valid arguments are provided for sparse tensors when using the tf.raw_ops.SparseTensorSliceDataset function. This involves verifying that both the indices and values arguments are non-empty and properly formatted. Here is an example of how to check and handle empty sparse tensors in Python:

import tensorflow as tf

# Example code to handle empty sparse tensors
indices = []
values = []

if indices and values:
    dataset = tf.raw_ops.SparseTensorSliceDataset(indices, values)
    # Rest of the code
else:
    # Handle empty sparse tensor case
    # Rest of the code

By performing this check, the null pointer dereference can be avoided.

Conclusion

In conclusion, the vulnerability (CVE-2021-37647) in TensorFlow can be mitigated by updating to the patched versions or by implementing the provided workaround. It is crucial for users to promptly address this vulnerability to prevent potential exploitation. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem for building and deploying machine learning models.

This vulnerability in TensorFlow can lead to a null pointer dereference, which can result in a denial-of-service (DoS) condition or potential execution of arbitrary code.

To fix this vulnerability, users should update their TensorFlow installations to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4.

Yes, users can ensure that valid arguments are provided for sparse tensors when using the tf.raw_ops.SparseTensorSliceDataset function. By checking that both the indices and values arguments are non-empty and properly formatted, the null pointer dereference can be avoided.

For more information about this vulnerability, you can refer to the official TensorFlow documentation, security advisories, or the GitHub repository.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow==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.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback