CVE-2021-29604: TFLite: DoS via division by zero in hashtable lookup
MEDIUM PoC AVAILABLEAn adversary can craft a malicious .tflite model file with a zero-dimension values tensor to crash TensorFlow Lite's inference process. Primary risk is in deployments that load models from external or untrusted sources — mobile apps, edge devices, or model-serving APIs accepting user-submitted models. Patch to TF 2.5.0 (or backports to 2.4.2/2.3.3/2.2.3/2.1.4) and enforce model provenance controls immediately.
What is the risk?
Medium risk (CVSS 5.5, local vector). Exploitation is straightforward — crafting a malformed .tflite model requires only basic TFLite knowledge, making this trivially reproducible. Impact is limited to availability (availability:high, no confidentiality or integrity impact per CVSS vector). Exposure is highest where external model files are ingested at runtime; internal-only, signed model pipelines reduce risk significantly. Not in CISA KEV; no evidence of active exploitation in the wild.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| TensorFlow | pip | — | No patch |
Do you use TensorFlow? You're affected.
How severe is it?
What is the attack surface?
What should I do?
5 steps-
Patch: upgrade to TensorFlow 2.5.0 or apply backports to 2.4.2, 2.3.3, 2.2.3, or 2.1.4 (commit 5117e08).
-
Model provenance: enforce cryptographic signing and verification of all .tflite model files before loading; reject unsigned or unrecognized models.
-
Input validation: add pre-load schema checks validating that tensor dimensions are non-zero before invoking TFLite kernels.
-
Isolation: run TFLite inference in sandboxed processes so a crash does not affect the broader application or service availability.
-
Detection: monitor for abnormal inference process terminations or crash dumps referencing hashtable_lookup.cc; correlate with recent model file changes or downloads.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29604?
An adversary can craft a malicious .tflite model file with a zero-dimension values tensor to crash TensorFlow Lite's inference process. Primary risk is in deployments that load models from external or untrusted sources — mobile apps, edge devices, or model-serving APIs accepting user-submitted models. Patch to TF 2.5.0 (or backports to 2.4.2/2.3.3/2.2.3/2.1.4) and enforce model provenance controls immediately.
Is CVE-2021-29604 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29604, increasing the risk of exploitation.
How to fix CVE-2021-29604?
1. Patch: upgrade to TensorFlow 2.5.0 or apply backports to 2.4.2, 2.3.3, 2.2.3, or 2.1.4 (commit 5117e08). 2. Model provenance: enforce cryptographic signing and verification of all .tflite model files before loading; reject unsigned or unrecognized models. 3. Input validation: add pre-load schema checks validating that tensor dimensions are non-zero before invoking TFLite kernels. 4. Isolation: run TFLite inference in sandboxed processes so a crash does not affect the broader application or service availability. 5. Detection: monitor for abnormal inference process terminations or crash dumps referencing hashtable_lookup.cc; correlate with recent model file changes or downloads.
What systems are affected by CVE-2021-29604?
This vulnerability affects the following AI/ML architecture patterns: edge inference, model serving, mobile ML deployment, on-device AI pipelines.
What is the CVSS score for CVE-2021-29604?
CVE-2021-29604 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.19%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0011.000 Unsafe AI Artifacts AML.T0029 Denial of AI Service Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an end-to-end open source platform for machine learning. The TFLite implementation of hashtable lookup is vulnerable to a division by zero error(https://github.com/tensorflow/tensorflow/blob/1a8e885b864c818198a5b2c0cbbeca5a1e833bc8/tensorflow/lite/kernels/hashtable_lookup.cc#L114-L115) An attacker can craft a model such that `values`'s first dimension would be 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 with write access to a model distribution channel — a compromised model update CDN, a model marketplace listing, or an OTA update endpoint for an edge device fleet — publishes a crafted .tflite model where the hashtable lookup values tensor has a first dimension of 0. When target devices pull and execute the model during normal inference, the division-by-zero in the TFLite kernel crashes the inference engine. For a fleet of smart cameras or industrial IoT devices running TFLite, this constitutes a scalable, remotely-triggered DoS against AI inference capability with no code execution required beyond model delivery.
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:N/I:N/A:H References
- github.com/tensorflow/tensorflow/commit/5117e0851348065ed59c991562c0ec80d9193db2 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-8rm6-75mf-7r7r Exploit Patch 3rd Party
Timeline
Related Vulnerabilities
CVE-2020-15196 9.9 TensorFlow: heap OOB read in sparse/ragged count ops
Same package: tensorflow CVE-2020-15205 9.8 TensorFlow: heap overflow in StringNGrams, ASLR bypass
Same package: tensorflow CVE-2019-16778 9.8 TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflow CVE-2020-15208 9.8 TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow CVE-2022-23587 9.8 TensorFlow: integer overflow in Grappler enables RCE
Same package: tensorflow