CVE-2021-37658: Reference binding to nullptr in MatrixSetDiagV* ops in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
Moderate
7.1

CVE-2021-37658: Reference binding to nullptr in MatrixSetDiagV* ops. Affects tensorflow across 3 version ranges.

< 2.3.4 >= 2.4.0, < 2.4.3 >= 2.5.0, < 2.5.1

Fixed in 2.3.4, 2.4.3 or 2.5.1, 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 Devnack Your last release was probably never penetration tested 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 open-source machine learning framework widely used for building and training various deep learning models. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning applications. However, a vulnerability has been identified in TensorFlow that affects the MatrixSetDiagV* operations.

Vulnerability Detail

The vulnerability (CVE-2021-37658) in TensorFlow's MatrixSetDiagV* operations allows an attacker to cause undefined behavior by binding a reference to a null pointer. This vulnerability arises due to incomplete validation of the 'k' tensor, which is used to access elements in the code. If the 'k' tensor is empty, the code accessing its first element will result in undefined behavior. An attacker can exploit this vulnerability to potentially execute arbitrary code or cause a denial-of-service (DoS) condition.

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.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"
  • >= 2.5.0, < 2.5.1 2.5.1
    pip install --upgrade "tensorflow==2.5.1"

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 avoid using the vulnerable MatrixSetDiagV* operations until they have updated their TensorFlow installation to a patched version. It is recommended to review the codebase and identify any usage of these operations and replace them with alternative approaches or wait for the patch to be applied.

Conclusion

The vulnerability in TensorFlow's MatrixSetDiagV* operations poses a risk of undefined behavior and potential code execution or DoS attacks. It is crucial to update TensorFlow to the latest patched version to mitigate this vulnerability. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

The vulnerability allows an attacker to cause undefined behavior, potentially leading to arbitrary code execution or a denial-of-service (DoS) condition.

The vulnerability affects TensorFlow versions 2.3.4, 2.4.0 to 2.4.3, 2.5.0 to 2.5.1, and 2.6.0.

There are no known exploits for this vulnerability at the time of this advisory.

Yes, the CVSS score for this vulnerability is 7.1, indicating a high severity level.

For more information, you can refer to the TensorFlow security guide and the GitHub commit mentioned in the vulnerability details section.

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.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"
  • >= 2.5.0, < 2.5.1 2.5.1
    pip install --upgrade "tensorflow==2.5.1"

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