CVE-2021-37659: TensorFlow - Undefined Behavior via Null Pointer Reference in Binary Cwise Operations

tensorflow Updated 02 Oct 2025

Summary

12/08/2021
Yes i
High
7.3

CVE-2021-37659: 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 < 93f428fd1768df147171ed674fee1fc5ab8309ec

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-37659 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 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 is widely used in various domains, including research, industry, and academia. It offers extensive support for deep learning algorithms and enables efficient computation on both CPUs and GPUs. However, a vulnerability has been discovered in TensorFlow that can lead to undefined behavior and potential security risks.

Vulnerability Detail

The vulnerability (CVE-2021-37659) in TensorFlow arises from a flaw in the implementation of binary cwise operations. These operations involve element-wise computations between two input tensors. The vulnerability specifically affects binary cwise operations that do not require broadcasting, such as gradients of binary cwise operations. The implementation assumes that the two input tensors have the same number of elements but fails to check this condition. As a result, when the eigen functor executes, it triggers heap out-of-bounds reads and undefined behavior by binding to a null pointer. 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 consider implementing input validation checks in their code to ensure that the two input tensors provided to binary cwise operations have the same number of elements. By explicitly validating the input tensors, the risk of triggering the vulnerability can be mitigated. Here is an example of how input validation can be performed in Python:

import tensorflow as tf

def binary_cwise_op(tensor1, tensor2):
    if tensor1.shape != tensor2.shape:
        raise ValueError('Input tensors must have the same shape')
    # Perform binary cwise operation
    ...

Conclusion

The vulnerability (CVE-2021-37659) in TensorFlow poses a risk of undefined behavior and potential security issues due to a flaw in the implementation of binary cwise operations. Users are advised to update their TensorFlow installations to the latest patched versions and consider implementing input validation checks in their code. Vulnerability monitoring tools like Vulert can also be utilized to receive real-time alerts and ensure the security of TensorFlow-based applications. 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 of tools and resources for developing and deploying machine learning models.

A binary cwise operation in TensorFlow refers to an element-wise computation between two input tensors. It applies a specific operation to each corresponding pair of elements from the input tensors.

The vulnerability in TensorFlow arises from a flaw in the implementation of binary cwise operations. It fails to check if the two input tensors have the same number of elements, leading to undefined behavior and potential security risks.

The vulnerability in TensorFlow can result in undefined behavior, including heap out-of-bounds reads and potential execution of arbitrary code. This can lead to a denial-of-service (DoS) condition or other security risks.

To mitigate this vulnerability, it is recommended to update to the latest patched version of TensorFlow (2.6.0 or later). Additionally, implementing input validation checks in your code can help mitigate the risk of triggering the vulnerability.

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