CVE-2021-37658: TensorFlow GPU - Null Pointer Dereference in MatrixSetDiagV* Operations

tensorflow-gpu Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Unrated
Not published

CVE-2021-37658: 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 < ff8894044dfae5568ecbf2ed514c1a37dc394f1b

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-37658 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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 GPU acceleration for faster computation. It is commonly used in scenarios where large-scale machine learning tasks require high-performance computing capabilities.

Vulnerability Detail

The vulnerability (CVE-2021-37658) exists in TensorFlow GPU versions 2.3.0 to 2.4.3, 2.5.0 to 2.5.1, and 2.6.0 (upcoming). It stems from incomplete validation in the tf.raw_ops.MatrixSetDiagV* operations. The implementation fails to properly check the number of elements in the tensor k, leading to undefined behavior when binding a reference to a null pointer. If k is an empty tensor, code that accesses its first element will encounter an error. This vulnerability can be exploited by an attacker to cause unexpected program behavior, potentially leading to crashes, data corruption, or unauthorized access to sensitive information.

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

As a temporary workaround, users can manually check the tensor k for emptiness before passing it to the tf.raw_ops.MatrixSetDiagV* operations. Here is an example of how to perform this check in Python:

import tensorflow as tf

# Check if tensor k is empty
if tf.size(k) == 0:
    # Handle empty tensor case
    ...
else:
    # Perform MatrixSetDiagV* operations
    ...

By explicitly checking for an empty tensor, the code can avoid triggering the null pointer dereference.

Conclusion

In conclusion, the vulnerability (CVE-2021-37658) in TensorFlow GPU versions 2.3.0 to 2.4.3, 2.5.0 to 2.5.1, and 2.6.0 (upcoming) can lead to undefined behavior due to a null pointer dereference in the tf.raw_ops.MatrixSetDiagV* operations. Users should update their TensorFlow GPU installations to the patched versions and follow the recommended steps to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-gpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models. It is widely used in various domains, including research, industry, and academia.

TensorFlow GPU is a variant of TensorFlow that leverages GPU acceleration for faster computation. It is specifically designed to take advantage of the parallel processing capabilities of GPUs, making it suitable for large-scale machine learning tasks that require high-performance computing.

The vulnerability in TensorFlow GPU can be exploited by an attacker to cause undefined behavior, potentially leading to crashes, data corruption, or unauthorized access to sensitive information. It is important for users to update their installations to the patched versions to mitigate the risk.

No, only TensorFlow GPU versions 2.3.0 to 2.4.3, 2.5.0 to 2.5.1, and 2.6.0 (upcoming) are affected by this vulnerability. Users of other versions are not impacted and do not need to take any action.

Users are advised to update their TensorFlow GPU installations to one of the patched versions: TensorFlow 2.3.4, TensorFlow 2.4.3, TensorFlow 2.5.1, or TensorFlow 2.6.0. This will ensure that the vulnerability is addressed and the system is protected against potential exploits.

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

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