CVE-2021-29605: TensorFlow TFLite Integer Overflow Vulnerability

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Moderate
7.1

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

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

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-29605 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 end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. TFLite allows developers to run machine learning models on resource-constrained platforms. However, a vulnerability has been discovered in the TFLite code that handles the allocation of TFLiteIntArray objects.

Vulnerability Detail

The TFLite code for allocating TFLiteIntArrays is vulnerable to an integer overflow issue. This vulnerability arises due to an unchecked multiplication operation that can result in an overflow of the int datatype. An attacker can exploit this vulnerability by crafting a malicious model that triggers the overflow, leading to an invalid value being passed to the malloc function. As a result, the ret->size pointer dereferences an invalid memory location, potentially leading to a crash or arbitrary code execution. This vulnerability affects TensorFlow versions 2.1.4 and above, including TensorFlow 2.5.0.

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

As a temporary workaround, developers can manually apply the patch provided by the TensorFlow team to fix the integer overflow issue. The patch involves modifying the common.c file in the TFLite codebase. Here is the modified code snippet:

// Original code
int size = count * sizeof(int);

// Patched code
int64_t size64 = (int64_t)count * sizeof(int);
if (size64 > INT_MAX) {
  // Handle the overflow case
  // ... (allocate memory using a different approach)
} else {
  int size = (int)size64;
  // ... (allocate memory using the original approach)
}

Conclusion

In conclusion, a vulnerability has been identified in TensorFlow Lite (TFLite) that allows an attacker to trigger an integer overflow, potentially leading to crashes or arbitrary code execution. The TensorFlow team has released patches to address this vulnerability, and it is crucial for users to update their TensorFlow installations to the latest versions. For further assistance or support 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 a comprehensive set of tools and libraries for building and deploying machine learning models.

TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for running machine learning models on resource-constrained devices such as mobile phones and embedded systems.

The vulnerability occurs due to an unchecked multiplication operation in the TFLite code that can result in an overflow of the int datatype.

Exploiting this vulnerability can lead to crashes or arbitrary code execution, potentially allowing an attacker to gain unauthorized access or control over the affected system.

To fix this vulnerability, it is recommended to upgrade to the latest available version of TensorFlow (2.5.0 or above). Alternatively, you can apply the provided patch manually to mitigate the issue temporarily.

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