CVE-2021-41215: TensorFlow-GPU - Null Pointer Dereference in DeserializeSparse

tensorflow-gpu Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Unrated
Not published

CVE-2021-41215: 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 < d3738dd70f1c9ceb547258cbb82d853da8771850

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-41215 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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 GPU acceleration for faster computation. It is widely used in various industries for training and inference of deep learning models.

Vulnerability Detail

The vulnerability identified as CVE-2021-41215 affects TensorFlow-GPU. Specifically, the shape inference code for the DeserializeSparse function can trigger a null pointer dereference. This occurs because the shape inference function assumes that the serialize_sparse tensor is a tensor with positive rank and a last dimension of 3. However, if the tensor does not meet these criteria, a null pointer dereference can occur. 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.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.4 2.4.4
    pip install --upgrade "tensorflow-gpu==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow-gpu==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow-gpu==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip 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

As a temporary workaround, users can modify the shape inference code in their local installation of TensorFlow-GPU to handle tensors with varying ranks and dimensions. Here is an example of how the code can be modified:

# Original code
if tensor.rank > 0 and tensor.shape[-1] == 3:
    # Shape inference logic

# Modified code
if tensor.rank > 0:
    if tensor.shape[-1] == 3:
        # Shape inference logic
    else:
        # Handle tensors with dimensions other than 3
else:
    # Handle tensors with rank 0

Please note that this is a temporary workaround and it is strongly recommended to apply the official patches by upgrading to the fixed versions of TensorFlow-GPU.

Conclusion

In conclusion, the vulnerability CVE-2021-41215 in TensorFlow-GPU can lead to a null pointer dereference in the shape inference code for DeserializeSparse. It is crucial to upgrade to the fixed versions (2.7.0, 2.6.1, 2.5.2, or 2.4.4) or apply the temporary workaround to mitigate the risk. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow-GPU is a variant of TensorFlow that utilizes GPU acceleration for faster computation. It is commonly used in machine learning applications for training and inference of deep learning models.

This vulnerability can lead to a null pointer dereference in the shape inference code for DeserializeSparse in TensorFlow-GPU. It can potentially result in a denial of service (DoS) condition or allow an attacker to execute arbitrary code.

The vulnerability affects TensorFlow-GPU versions 2.4.4, 2.5.2, 2.6.1, and 2.7.0rc0. It is recommended to upgrade to the fixed versions (2.4.4, 2.5.2, 2.6.1, or 2.7.0) to mitigate the vulnerability.

To fix this vulnerability, it is recommended to upgrade to the latest available version of TensorFlow-GPU (2.7.0, 2.6.1, 2.5.2, or 2.4.4). The official patches address the null pointer dereference issue in the shape inference code for DeserializeSparse.

Yes, as a temporary workaround, users can modify the shape inference code in their local installation of TensorFlow-GPU to handle tensors with varying ranks and dimensions. However, it is strongly advised to apply the official patches by upgrading to the fixed versions.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-gpu.

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.4 2.4.4
    pip install --upgrade "tensorflow-gpu==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow-gpu==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow-gpu==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip 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 →

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