CVE-2021-29605: TFLite: integer overflow DoS via crafted model file

MEDIUM PoC AVAILABLE
Published May 14, 2021
CISO Take

Patch TensorFlow Lite to 2.5.0 or apply available backports (2.4.2/2.3.3/2.2.3/2.1.4) immediately if you run any TFLite-based inference—mobile, edge, or server-side. An attacker who can deliver a crafted model file can crash your inference runtime on demand. Impact is pure availability disruption; no RCE or data exfiltration risk, but sustained DoS is trivially achievable post-delivery.

Risk Assessment

Medium risk overall. The local attack vector and requirement to control the loaded model file limit opportunistic exploitation. However, organizations loading TFLite models from external sources, model registries, or allowing user-supplied models face elevated risk. Low attack complexity means any adversary achieving model file delivery can reliably trigger the crash. Not in CISA KEV; no active exploitation reported as of advisory date. Severity increases significantly in high-availability inference services where uptime is business-critical.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed today 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
5.5 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 2% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Moderate
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

Attack Surface

AV AC PR UI S C I A
AV Local
AC Low
PR Low
UI None
S Unchanged
C None
I None
A High

Recommended Action

5 steps
  1. Patch: upgrade to TF 2.5.0 or cherry-pick backports to 2.4.2, 2.3.3, 2.2.3, or 2.1.4.

  2. Model integrity: enforce cryptographic signatures or hashes on all TFLite model files before loading—reject unsigned or unverified models.

  3. Input validation: sanitize model files from untrusted or external sources before passing to the TFLite runtime.

  4. Process isolation: run TFLite inference in a sandboxed process to contain crashes and limit blast radius.

  5. Detection: alert on unexpected inference process crashes or abnormal exit codes in AI serving infrastructure as indicators of attempted exploitation.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.8.2 - AI system design and development
NIST AI RMF
MANAGE-2.2 - Risk treatments for AI risks
OWASP LLM Top 10
LLM05:2023 - Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2021-29605?

Patch TensorFlow Lite to 2.5.0 or apply available backports (2.4.2/2.3.3/2.2.3/2.1.4) immediately if you run any TFLite-based inference—mobile, edge, or server-side. An attacker who can deliver a crafted model file can crash your inference runtime on demand. Impact is pure availability disruption; no RCE or data exfiltration risk, but sustained DoS is trivially achievable post-delivery.

Is CVE-2021-29605 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2021-29605, increasing the risk of exploitation.

How to fix CVE-2021-29605?

1. Patch: upgrade to TF 2.5.0 or cherry-pick backports to 2.4.2, 2.3.3, 2.2.3, or 2.1.4. 2. Model integrity: enforce cryptographic signatures or hashes on all TFLite model files before loading—reject unsigned or unverified models. 3. Input validation: sanitize model files from untrusted or external sources before passing to the TFLite runtime. 4. Process isolation: run TFLite inference in a sandboxed process to contain crashes and limit blast radius. 5. Detection: alert on unexpected inference process crashes or abnormal exit codes in AI serving infrastructure as indicators of attempted exploitation.

What systems are affected by CVE-2021-29605?

This vulnerability affects the following AI/ML architecture patterns: model serving, edge AI deployments, mobile AI applications, on-device inference.

What is the CVSS score for CVE-2021-29605?

CVE-2021-29605 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.01%.

Technical Details

NVD Description

TensorFlow is an end-to-end open source platform for machine learning. The TFLite code for allocating `TFLiteIntArray`s is vulnerable to an integer overflow issue(https://github.com/tensorflow/tensorflow/blob/4ceffae632721e52bf3501b736e4fe9d1221cdfa/tensorflow/lite/c/common.c#L24-L27). An attacker can craft a model such that the `size` multiplier is so large that the return value overflows the `int` datatype and becomes negative. In turn, this results in invalid value being given to `malloc`(https://github.com/tensorflow/tensorflow/blob/4ceffae632721e52bf3501b736e4fe9d1221cdfa/tensorflow/lite/c/common.c#L47-L52). In this case, `ret->size` would dereference an invalid pointer. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.

Exploitation Scenario

An adversary targeting a TFLite-powered application crafts a malicious .tflite model file where the TFLiteIntArray size parameter is set large enough to overflow an int, producing a negative result. The attacker delivers this via a compromised model update server, a supply chain attack on the model repository, or by directly uploading it to an application accepting user-provided models. When the victim runtime loads the file, malloc receives a negative size, allocates an invalid memory region, and the subsequent ret->size dereference crashes the inference process. In a high-availability AI inference service, repeated delivery achieves sustained denial of service with minimal attacker effort after initial file delivery.

Weaknesses (CWE)

CVSS Vector

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Timeline

Published
May 14, 2021
Last Modified
November 21, 2024
First Seen
May 14, 2021

Related Vulnerabilities