CVE-2021-37679: TensorFlow CPU - Uninitialized Memory Leak in tf.map_fn

tensorflow-cpu Updated 02 Oct 2025

Summary

12/08/2021
Yes i
Unrated
Not published

CVE-2021-37679: 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 < 4e2565483d0ffcadc719bd44893fb7f609bb5f12

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-37679 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 vulnerability described here affects the TensorFlow CPU package, which is a Python package for running TensorFlow on CPUs. This package is commonly used when GPU acceleration is not available or not required.

Vulnerability Detail

The vulnerability (CVE-2021-37679) arises from the nesting of a tf.map_fn within another tf.map_fn call when the input tensor is a RaggedTensor and no function signature is provided. In this scenario, the code assumes that the output is a fully specified tensor and fills the output buffer with uninitialized contents from the heap. As a result, the t and z outputs, which should be identical, differ. The last row of t contains data from the heap, which can be exploited to leak other memory information. The bug lies in the conversion from a Variant tensor to a RaggedTensor, where the implementation fails to check that all inner shapes match, leading to additional dimensions. This vulnerability can also result in data loss if the input tensor is manipulated. The issue has been patched in the GitHub commit 4e2565483d0ffcadc719bd44893fb7f609bb5f12 and will be included in TensorFlow 2.6.0. The fix will also be backported to TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these versions are also affected and within the supported range.

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, you can avoid nesting tf.map_fn calls with RaggedTensor inputs. Instead, consider using alternative approaches or restructuring your code to achieve the desired functionality without relying on this specific nesting pattern. Here's an example of how you can modify your code to avoid the vulnerable pattern:

# Original code
output = tf.map_fn(lambda x: tf.map_fn(lambda y: y + 1, x), input_tensor)

# Modified code
output = tf.map_fn(lambda x: x + 1, input_tensor)

Conclusion

The vulnerability (CVE-2021-37679) in TensorFlow CPU's tf.map_fn nesting with RaggedTensor inputs has been identified and addressed. It is crucial to update to the patched versions to mitigate the risk of uninitialized memory leaks and potential data loss. Follow the recommended steps provided in the 'how_to_fix' section to rectify the vulnerability. For further support on vulnerability remediation, 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 ecosystem of tools and resources for developing and deploying machine learning models.

The TensorFlow CPU package is a Python package that allows running TensorFlow on CPUs. It is commonly used when GPU acceleration is not available or not required.

The vulnerability occurs when a tf.map_fn is nested within another tf.map_fn call, and the input tensor is a RaggedTensor without a provided function signature. This leads to uninitialized memory being used to fill the output buffer, resulting in a memory leak and potential data loss.

The vulnerability can lead to uninitialized memory leaks and potential data loss. Additionally, an attacker could exploit the leaked memory information to gather sensitive data from the system.

To fix the vulnerability, update the TensorFlow CPU package to the patched versions. Follow the official TensorFlow documentation or the package manager's instructions for updating the package. Additionally, ensure that your code does not nest tf.map_fn calls with RaggedTensor inputs without providing a function signature.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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