CVE-2021-29593: TensorFlow TFLite: div-by-zero via crafted model file

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

Any system that loads externally-supplied or user-provided TFLite models is at risk of crash or potential code execution (CVSS C:H/I:H/A:H). Patch TensorFlow to 2.5.0+ or the respective cherry-pick release for your branch. Audit model ingestion pipelines to ensure only trusted, validated models are loaded.

What is the risk?

HIGH for ML inference services that accept external TFLite models. Local attack vector limits internet-exposed risk, but model-as-input threat is common in MLOps pipelines where models are downloaded from registries, shared over internal tools, or supplied by third parties. Trivial to exploit: attacker only needs to craft a model with a zero-dimension block input. CVSS 7.8 with full CIA impact suggests potential memory corruption beyond a clean crash.

What systems are affected?

Package Ecosystem Vulnerable Range Patched
TensorFlow pip No patch
195.8K OpenSSF 7.1 3.7K dependents Pushed 2d ago 4% patched ~1372d to patch Full package profile →

Do you use TensorFlow? You're affected.

How severe is it?

CVSS 3.1
7.8 / 10
EPSS
0.2%
chance of exploitation in 30 days
Higher than 10% 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, VulnCheck KEV, CISA SSVC, EPSS, Metasploit, Exploit-DB, trickest/cve, Nuclei templates, and inthewild.io exploitation reports.

What is the 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

What should I do?

5 steps
  1. Patch: upgrade to TensorFlow 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your branch.

  2. Model validation: enforce a model allow-list or hash verification before loading any TFLite file.

  3. Sandboxing: run TFLite inference in a sandboxed process (seccomp, gVisor, container with no-new-privileges) to contain blast radius.

  4. Detection: monitor for SIGFPE / divide-by-zero signals in inference processes; unexpected crashes in model serving workers should trigger incident response.

  5. Supply chain: audit third-party model sources; prefer signed model artifacts.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.6.2 - AI system lifecycle security A.9.3 - AI system security testing
NIST AI RMF
GOVERN 6.1 - Policies for third-party AI risk MANAGE 2.4 - Residual risks and response
OWASP LLM Top 10
LLM05:2025 - Improper Output Handling / Insecure Plugin Design

Frequently Asked Questions

What is CVE-2021-29593?

Any system that loads externally-supplied or user-provided TFLite models is at risk of crash or potential code execution (CVSS C:H/I:H/A:H). Patch TensorFlow to 2.5.0+ or the respective cherry-pick release for your branch. Audit model ingestion pipelines to ensure only trusted, validated models are loaded.

Is CVE-2021-29593 actively exploited?

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

How to fix CVE-2021-29593?

1. Patch: upgrade to TensorFlow 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your branch. 2. Model validation: enforce a model allow-list or hash verification before loading any TFLite file. 3. Sandboxing: run TFLite inference in a sandboxed process (seccomp, gVisor, container with no-new-privileges) to contain blast radius. 4. Detection: monitor for SIGFPE / divide-by-zero signals in inference processes; unexpected crashes in model serving workers should trigger incident response. 5. Supply chain: audit third-party model sources; prefer signed model artifacts.

What systems are affected by CVE-2021-29593?

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

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

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

What is the AI security impact?

Affected AI Architectures

model servingedge inferencemobile ML deploymenttraining pipelines

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0011 User Execution
AML.T0011.000 Unsafe AI Artifacts
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Article 15
ISO 42001: A.6.2, A.9.3
NIST AI RMF: GOVERN 6.1, MANAGE 2.4
OWASP LLM Top 10: LLM05:2025

What are the technical details?

Original Advisory

TensorFlow is an end-to-end open source platform for machine learning. The implementation of the `BatchToSpaceNd` TFLite operator is vulnerable to a division by zero error(https://github.com/tensorflow/tensorflow/blob/b5ed552fe55895aee8bd8b191f744a069957d18d/tensorflow/lite/kernels/batch_to_space_nd.cc#L81-L82). 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 ML inference API or MLOps pipeline crafts a minimal TFLite flatbuffer where the BatchToSpaceNd op has a block tensor with at least one zero dimension. They submit this model through a model upload endpoint, a shared model registry, or via a compromised model dependency. When the inference runtime processes the model, block_shape[i] = 0 triggers a division by zero at kernels/batch_to_space_nd.cc:81-82. Depending on platform and ASAN state, this crashes the inference worker (DoS) or, on unprotected targets, may allow heap/stack exploitation consistent with the CVSS C:H/I:H/A:H rating. In a model-serving SaaS context, a single crafted model could take down a shared inference worker affecting all tenants.

Weaknesses (CWE)

CWE-369 — Divide By Zero: The product divides a value by zero.

Source: MITRE CWE corpus.

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