CVE-2021-29596: TensorFlow TFLite: div-by-zero in EmbeddingLookup op

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

Any TensorFlow deployment running TFLite inference with externally-supplied or user-controlled models is at risk of crash or code execution via a crafted model file. Patch to TF 2.5.0 (or cherrypick for 2.1.4–2.4.x branches) immediately and restrict model loading to signed, trusted sources. If your pipeline ingests third-party TFLite models—federated learning nodes, model marketplaces, CI/CD model tests—treat this as high priority.

Risk Assessment

CVSS 7.8 with local attack vector and low complexity/privileges understates real-world risk for ML pipelines. The 'local' vector assumes direct system access, but any service that loads and runs TFLite models from external input (APIs, uploads, S3 buckets) effectively elevates this to a network-reachable vector. Full C/I/A compromise scores reflect that a divide-by-zero in native TFLite C++ code can lead to exploitable crash state on some platforms, not just a clean DoS.

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 apply cherrypick patches to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.

  2. Enforce model provenance: only load models from cryptographically signed, internal registries.

  3. Add pre-execution model validation that checks tensor shapes and rejects any tensor with zero in the first dimension before the TFLite interpreter runs.

  4. Isolate TFLite inference in sandboxed processes (seccomp, containers) so a crash cannot escalate.

  5. Audit CI/CD pipelines and model-testing automation that runs arbitrary model files from PRs or external repos.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
6.1.2 - AI risk assessment 8.4 - AI system operation and monitoring
NIST AI RMF
MANAGE 2.4 - Mechanisms to detect and address AI system failure MAP 5.1 - Likelihood and magnitude of risks identified

Frequently Asked Questions

What is CVE-2021-29596?

Any TensorFlow deployment running TFLite inference with externally-supplied or user-controlled models is at risk of crash or code execution via a crafted model file. Patch to TF 2.5.0 (or cherrypick for 2.1.4–2.4.x branches) immediately and restrict model loading to signed, trusted sources. If your pipeline ingests third-party TFLite models—federated learning nodes, model marketplaces, CI/CD model tests—treat this as high priority.

Is CVE-2021-29596 actively exploited?

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

How to fix CVE-2021-29596?

1. Upgrade to TensorFlow 2.5.0 or apply cherrypick patches to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4. 2. Enforce model provenance: only load models from cryptographically signed, internal registries. 3. Add pre-execution model validation that checks tensor shapes and rejects any tensor with zero in the first dimension before the TFLite interpreter runs. 4. Isolate TFLite inference in sandboxed processes (seccomp, containers) so a crash cannot escalate. 5. Audit CI/CD pipelines and model-testing automation that runs arbitrary model files from PRs or external repos.

What systems are affected by CVE-2021-29596?

This vulnerability affects the following AI/ML architecture patterns: TFLite edge inference, model serving, training pipelines, federated learning nodes, CI/CD model validation.

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

CVE-2021-29596 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 `EmbeddingLookup` TFLite operator is vulnerable to a division by zero error(https://github.com/tensorflow/tensorflow/blob/e4b29809543b250bc9b19678ec4776299dd569ba/tensorflow/lite/kernels/embedding_lookup.cc#L73-L74). An attacker can craft a model such that the first dimension of the `value` input 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 attacker targeting a company running a TFLite-based image classification microservice crafts a malicious .tflite file where the EmbeddingLookup operator's value tensor is shaped [0, N]. They submit it through a model-upload endpoint or inject it into an S3 bucket read by the inference pipeline. When the service loads and executes the model for warmup or inference, the division by zero in embedding_lookup.cc:73-74 crashes the TFLite runtime. On Linux with ASLR disabled or in containers without crash isolation, this can be leveraged for code execution with the service account's privileges—providing initial foothold in the ML inference environment.

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