CVE-2021-29591: Stack overflow due to looping TFLite subgraph in TensorFlow

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
High
7.3

CVE-2021-29591: Stack overflow due to looping TFLite subgraph. Affects tensorflow across 4 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2

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 open-source machine learning framework that provides a wide range of tools and libraries for building and deploying machine learning models. It is widely used in various domains, including research, industry, and academia. TensorFlow allows users to define and execute computational graphs, which represent the flow of data and operations in a machine learning model. TFLite is a lightweight version of TensorFlow designed for mobile and embedded devices. It enables efficient execution of machine learning models on resource-constrained platforms.

Vulnerability Detail

The vulnerability identified as CVE-2021-29591 affects TensorFlow versions 0 to 2.1.4, 2.2.0 to 2.2.3, 2.3.0 to 2.3.3, and 2.4.0 to 2.4.2. It is caused by a stack overflow due to a looping TFLite subgraph. TFLite graphs should not have loops between nodes, but this condition was not properly checked. An attacker could craft malicious models that 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 has a CVSS score of 7.3, indicating a high severity level. The impact of this vulnerability includes denial of service (DoS) and potential remote code execution.

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.1.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow==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 known workaround for this vulnerability. It is recommended to apply the official patch or upgrade to a fixed version of TensorFlow.

Conclusion

The vulnerability CVE-2021-29591 in TensorFlow poses a high risk due to the potential for denial of service and remote code execution. Users are strongly advised to upgrade to the latest version of TensorFlow (2.5.0 or above) or apply the provided patches to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open-source machine learning framework used for building and deploying machine learning models.

TFLite is a lightweight version of TensorFlow designed for mobile and embedded devices.

The impact of this vulnerability includes denial of service (DoS) and potential remote code execution.

To fix this vulnerability, upgrade to the latest version of TensorFlow (2.5.0 or above) or apply the provided patches.

There is no known workaround for this vulnerability. It is recommended to apply the official patch or upgrade to a fixed version 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.1.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow==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