CVE-2021-37643: Null Pointer Dereference in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

25/08/2021
Yes i
High
7.7

CVE-2021-37643: Null pointer dereference in MatrixDiagPartOp. 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-37643 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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

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 open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in TensorFlow that can lead to a null pointer dereference.

Vulnerability Detail

The vulnerability, identified as CVE-2021-37643, affects the MatrixDiagPartOp function in TensorFlow. When a user fails to provide a valid padding value to this function, it triggers a null pointer dereference if the input is empty or produces invalid behavior by ignoring all values after the first. This vulnerability can be exploited to cause a denial-of-service condition or potentially execute arbitrary code. The issue arises from the implementation of the function, which reads the first value from a tensor buffer without checking if the tensor has any values to read from.

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

If immediate updating is not possible, a temporary workaround is to avoid using the MatrixDiagPartOp function with invalid padding values. Users should ensure that valid padding values are provided to prevent triggering the null pointer dereference. Here is an example of how to use the function with valid padding values:

import tensorflow as tf

tf.raw_ops.MatrixDiagPartV2(
  input=tf.ones(2, dtype=tf.int32),
  k=tf.ones(2, dtype=tf.int32),
  padding_value=0)

Conclusion

The vulnerability in TensorFlow, identified as CVE-2021-37643, can lead to a null pointer dereference and potentially result in a denial-of-service condition or code execution. It is crucial for users to update their TensorFlow installation to the patched versions (2.6.0, 2.5.1, 2.4.3, or 2.3.4) to mitigate this vulnerability. If immediate updating is not possible, users should ensure valid padding values are provided to the MatrixDiagPartOp function. For further support or assistance, please contact the TensorFlow team through their official channels.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

The vulnerability can lead to a null pointer dereference, resulting in a denial-of-service condition or potential code execution. It is important to update TensorFlow to the patched versions to mitigate this risk.

The vulnerability affects TensorFlow versions 2.3.4, 2.4.3, 2.5.0, and 2.5.1. Users of these versions should update to the patched versions.

There are no known public exploits for this vulnerability at the time of this report. However, it is advisable to update TensorFlow to the patched versions to prevent potential exploitation.

Yes, this vulnerability can be exploited remotely if an attacker can provide malicious input to the vulnerable function. It is crucial to update TensorFlow to the patched versions to mitigate this risk.

For further assistance or questions regarding this vulnerability, you can contact the TensorFlow team through their official channels. Please refer to the TensorFlow project's security guide for more information on how to contact them.

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