CVE-2021-37659: TensorFlow CPU - Null Pointer Dereference in Binary Cwise Operations

tensorflow-cpu Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Unrated
Not published

CVE-2021-37659: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu 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. The TensorFlow CPU package, available on PyPI, is a specific distribution of TensorFlow optimized for CPU-based systems.

Vulnerability Detail

The vulnerability identified as CVE-2021-37659 affects the TensorFlow CPU package. It arises from a flaw in the implementation of binary cwise operations, specifically when computing gradients. The implementation assumes that the two input tensors have the same number of elements but fails to validate this condition. As a result, when the eigen functor executes, it triggers out-of-bounds heap reads and undefined behavior by binding to a null pointer. This vulnerability can be exploited by an attacker to cause undefined behavior and potentially lead to a denial-of-service (DoS) condition or arbitrary code execution.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==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-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-cpu==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 manually validate the sizes of the input tensors before performing binary cwise operations. This can be achieved by comparing the shapes or dimensions of the tensors and ensuring they have the same number of elements. Here's an example code snippet demonstrating the workaround:

import tensorflow as tf

def safe_binary_cwise_op(a, b):
    if tf.size(a) != tf.size(b):
        raise ValueError('Input tensors must have the same number of elements')
    return tf.add(a, b)

By explicitly checking the sizes, the risk of triggering the null pointer dereference is mitigated.

Conclusion

In conclusion, the CVE-2021-37659 vulnerability in the TensorFlow CPU package exposes a null pointer dereference issue in binary cwise operations. This flaw can be exploited by an attacker to cause undefined behavior and potentially lead to a DoS condition or arbitrary code execution. The TensorFlow development team has addressed this vulnerability with patches in specific versions of TensorFlow. Users are advised to update their TensorFlow CPU package and implement the recommended workaround to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

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.

The TensorFlow CPU package is a specific distribution of TensorFlow optimized for CPU-based systems. It allows users to leverage the power of TensorFlow on machines without dedicated GPUs.

A null pointer dereference occurs when a program attempts to access or manipulate memory through a null pointer, which does not point to a valid memory location. This can lead to crashes, undefined behavior, and potential security vulnerabilities.

Binary cwise operations in TensorFlow refer to element-wise operations performed on two input tensors of the same shape. Examples include addition, subtraction, multiplication, and division of corresponding elements in the tensors.

To protect your application from this vulnerability, it is recommended to update the TensorFlow CPU package to the patched versions once they are available. Additionally, you can implement the provided workaround to manually validate the sizes of input tensors before performing binary cwise operations.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

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