CVE-2021-29591: TensorFlow CPU - Infinite Loop and Stack Overflow Vulnerability

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29591: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 6 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2 < 9c1dc920d8ffb4893d6c9d27d1f039607b326743 < c6173f5fe66cdbab74f4f869311fe6aae2ba35f4

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-29591 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 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 CPU is a specific package that focuses on running TensorFlow on CPUs. It is widely used in various industries and applications for machine learning tasks.

Vulnerability Detail

The vulnerability identified as CVE-2021-29591 affects TensorFlow CPU. TFlite graphs in TensorFlow must not have loops between nodes. However, this condition was not properly checked, allowing an attacker to craft malicious models that would result in an infinite loop during evaluation. In certain cases, the infinite loop could lead to a stack overflow due to excessive recursive calls. The vulnerability specifically affects the While implementation in TensorFlow. By tricking the implementation into a scenario where both the body and loop subgraphs are the same, an attacker can exhaust the stack space by repeatedly calling the Eval function. This vulnerability can have severe consequences, including denial of service (DoS) attacks and potential remote 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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==2.4.2"

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 specific workaround provided for this vulnerability. However, users can mitigate the risk by ensuring they are using the latest patched version of TensorFlow CPU.

Conclusion

The vulnerability identified as CVE-2021-29591 in TensorFlow CPU can lead to an infinite loop and stack overflow, potentially resulting in denial of service (DoS) attacks or remote code execution. It is crucial for users of TensorFlow CPU to update to the latest patched version, which includes the fix for this vulnerability. By keeping the software up to date, users can ensure the security and stability of their machine learning applications. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

TensorFlow CPU is a package that allows running TensorFlow on CPUs. It provides optimized CPU support for machine learning tasks.

The vulnerability can lead to an infinite loop during evaluation of TFlite graphs, potentially resulting in a denial of service (DoS) or remote code execution.

The vulnerability affects TensorFlow CPU versions 2.1.4 and above, including versions 2.2.3, 2.3.3, and 2.4.2.

There are no known public exploits for this vulnerability at the time of this report. However, it is important to apply the necessary patches and updates to mitigate the risk.

Users can update TensorFlow CPU by following the recommended upgrade process provided by the TensorFlow team. This typically involves updating the package using package managers like pip or conda.

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.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==2.4.2"

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