CVE-2021-41221: TensorFlow Heap Buffer Overflow

tensorflow-cpu Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Unrated
Not published

CVE-2021-41221: TensorFlow is an open source platform for machine learning. Affects tensorflow-cpu across 5 version ranges.

< 2.4.4 >= 2.5.0, < 2.5.2 >= 2.6.0, < 2.6.1 >= 2.7.0rc0, < 2.7.0 < af5fcebb37c8b5d71c237f4e59c6477015c78ce6

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-41221 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

TensorFlow is an 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 industries and research domains for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that can lead to a heap buffer overflow.

Vulnerability Detail

The vulnerability in TensorFlow lies in the shape inference code for the Cudnn* operations. This code can be tricked into accessing invalid memory, resulting in a heap buffer overflow. The issue arises due to the lack of validation for the ranks of the input, input_h, and input_c parameters. The code assumes certain values for these ranks, but they are not properly checked. As a result, an attacker can exploit this vulnerability to execute arbitrary code or cause a denial of service. The impact of this vulnerability can be severe, potentially leading to unauthorized access, data leakage, or system compromise.

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.4.4 2.4.4
    pip install --upgrade "tensorflow-cpu==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow-cpu==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow-cpu==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip install --upgrade "tensorflow-cpu==2.7.0"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

There is no known workaround for this vulnerability. It is essential to apply the provided patches or update to the latest version of TensorFlow to address the issue.

Conclusion

The vulnerability in TensorFlow's shape inference code for Cudnn* operations can lead to a heap buffer overflow, potentially enabling arbitrary code execution or causing a denial of service. It is recommended to update to the latest patched version of TensorFlow to mitigate the risk. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides tools and libraries for developing and deploying machine learning models.

A heap buffer overflow is a type of vulnerability where a program writes data beyond the allocated memory buffer in the heap. This can lead to memory corruption, crashes, or the execution of arbitrary code.

An attacker can exploit this vulnerability by crafting malicious input that triggers the shape inference code for the Cudnn* operations in TensorFlow. By providing invalid values for the ranks of the input, input_h, and input_c parameters, the attacker can cause a heap buffer overflow and potentially execute arbitrary code.

This vulnerability can have severe consequences, including unauthorized access, data leakage, or system compromise. An attacker who successfully exploits this vulnerability can gain control over the affected system and perform malicious actions.

To protect your system, it is crucial to update to the latest patched version of TensorFlow. Make sure to regularly check for updates and apply them promptly. Additionally, follow secure coding practices and avoid processing untrusted input.

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.4.4 2.4.4
    pip install --upgrade "tensorflow-cpu==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow-cpu==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow-cpu==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip install --upgrade "tensorflow-cpu==2.7.0"

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