CVE-2021-29597: TensorFlow TFLite: div-by-zero crash via crafted model

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

Any system loading TFLite models from untrusted or third-party sources is vulnerable to a crash or potential code execution via a single crafted model file. Patch to TensorFlow 2.5.0 immediately, or apply the cherry-picked fix for 2.1.4/2.2.3/2.3.3/2.4.2. Enforce strict model provenance controls—sign and verify all TFLite artifacts before loading.

Risk Assessment

Risk is HIGH in environments that dynamically ingest third-party or user-supplied TFLite models. The local attack vector is deceptive: in ML pipelines, 'local' includes loading a model downloaded from a registry, a federated update channel, or an internal artifact store—all reachable by a supply chain attacker. CVSS 7.8 with full C/I/A impact means exploitation may extend beyond DoS to code execution depending on heap layout at crash time. Unpatched edge and mobile deployments face the highest exposure due to frequent dynamic model updates with limited code-signing enforcement.

Affected Systems

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

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
7.8 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 1% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
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 High
I High
A High

Recommended Action

5 steps
  1. Upgrade to TensorFlow 2.5.0 or cherry-pick commit 6d36ba6 for 2.1.4/2.2.3/2.3.3/2.4.2.

  2. Enforce model signing: require cryptographic signatures on all TFLite files loaded at runtime; reject unsigned or unverified artifacts.

  3. Add input validation in any pipeline accepting externally sourced models—validate operator dimensions before graph initialization.

  4. For edge fleets, audit model update delivery channels; restrict to signed artifacts from controlled registries only.

  5. Detection: monitor TFLite inference processes for unexpected crashes or SIGFPE signals; treat repeated model-load failures as a potential indicator of artifact tampering.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Art.9 - Risk management system
ISO 42001
A.6.2 - AI system design and development A.9.3 - AI systems from third parties
NIST AI RMF
GOVERN-6.1 - Policies and procedures for AI risk MANAGE-2.2 - Mechanisms to minimize undesired AI system behaviors
OWASP LLM Top 10
LLM03 - Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2021-29597?

Any system loading TFLite models from untrusted or third-party sources is vulnerable to a crash or potential code execution via a single crafted model file. Patch to TensorFlow 2.5.0 immediately, or apply the cherry-picked fix for 2.1.4/2.2.3/2.3.3/2.4.2. Enforce strict model provenance controls—sign and verify all TFLite artifacts before loading.

Is CVE-2021-29597 actively exploited?

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

How to fix CVE-2021-29597?

1. Upgrade to TensorFlow 2.5.0 or cherry-pick commit 6d36ba6 for 2.1.4/2.2.3/2.3.3/2.4.2. 2. Enforce model signing: require cryptographic signatures on all TFLite files loaded at runtime; reject unsigned or unverified artifacts. 3. Add input validation in any pipeline accepting externally sourced models—validate operator dimensions before graph initialization. 4. For edge fleets, audit model update delivery channels; restrict to signed artifacts from controlled registries only. 5. Detection: monitor TFLite inference processes for unexpected crashes or SIGFPE signals; treat repeated model-load failures as a potential indicator of artifact tampering.

What systems are affected by CVE-2021-29597?

This vulnerability affects the following AI/ML architecture patterns: edge inference, mobile ML deployments, model serving, federated learning clients, training pipelines.

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

CVE-2021-29597 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.01%.

Technical Details

NVD Description

TensorFlow is an end-to-end open source platform for machine learning. The implementation of the `SpaceToBatchNd` TFLite operator is [vulnerable to a division by zero error](https://github.com/tensorflow/tensorflow/blob/412c7d9bb8f8a762c5b266c9e73bfa165f29aac8/tensorflow/lite/kernels/space_to_batch_nd.cc#L82-L83). An attacker can craft a model such that one dimension of the `block` input is 0. Hence, the corresponding value in `block_shape` is 0. 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 an organization's edge fleet or mobile ML deployment crafts a .tflite model file with a SpaceToBatchNd operator whose block input has a zero-valued dimension. The adversary introduces this model via a compromised model hub, a poisoned internal artifact registry, or a man-in-the-middle attack on an unprotected model update channel. When the device or server initializes the model graph, the TFLite kernel computes block_shape from the zero dimension, triggering an unguarded division by zero. The runtime crashes, causing a denial of service; on targets with exploitable heap layouts, the memory corruption at crash time may be leveraged for code execution under the local user context.

Weaknesses (CWE)

CVSS Vector

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

Timeline

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

Related Vulnerabilities