CVE-2021-41221: TensorFlow Heap Buffer Overflow

tensorflow Updated 02 Oct 2025

Summary

05/11/2021
Yes i
High
7.8

CVE-2021-41221: TensorFlow is an open source platform for machine learning. Affects tensorflow 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 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 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. This vulnerability affects versions of TensorFlow that utilize the Cudnn* operations. These operations are used for deep learning tasks and are implemented using the cuDNN library, which provides highly optimized GPU-accelerated primitives for deep neural networks. The vulnerability arises from a lack of validation for the ranks of certain input parameters, leading to a heap buffer overflow.

Vulnerability Detail

The vulnerability in TensorFlow's shape inference code for the Cudnn* operations allows an attacker to trigger a heap buffer overflow by providing invalid values for the input, input_h, and input_c parameters. The code assumes certain values for these parameters without proper validation, leading to the overflow. This can be exploited by an attacker to execute arbitrary code, potentially compromising the integrity and confidentiality of the affected system. The vulnerability has been assigned the identifier CVE-2021-41221 and has been reported to the TensorFlow development team.

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.4.4 2.4.4
    pip install --upgrade "tensorflow==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip install --upgrade "tensorflow==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 recommended to update to the fixed versions of TensorFlow as soon as possible.

Conclusion

The vulnerability in TensorFlow's shape inference code for the Cudnn* operations can lead to a heap buffer overflow, potentially allowing an attacker to execute arbitrary code. Users of affected versions should update to the fixed versions of TensorFlow to mitigate the risk. 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 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 bounds of a dynamically allocated buffer in the heap, potentially overwriting adjacent memory and leading to a crash or arbitrary code execution.

An attacker can exploit this vulnerability by providing specially crafted input to the affected TensorFlow operations, triggering a heap buffer overflow and potentially executing arbitrary code.

No, only versions that utilize the Cudnn* operations are affected. The vulnerability has been fixed in TensorFlow 2.7.0, TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4.

No, there is no known workaround. It is recommended to update to the fixed versions of TensorFlow.

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