CVE-2021-29596: TensorFlow TFLite: div-by-zero in EmbeddingLookup op
HIGH PoC AVAILABLEAny 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 |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
5 steps-
Upgrade to TensorFlow 2.5.0 or apply cherrypick patches to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.
-
Enforce model provenance: only load models from cryptographically signed, internal registries.
-
Add pre-execution model validation that checks tensor shapes and rejects any tensor with zero in the first dimension before the TFLite interpreter runs.
-
Isolate TFLite inference in sandboxed processes (seccomp, containers) so a crash cannot escalate.
-
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:
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 References
- github.com/tensorflow/tensorflow/commit/f61c57bd425878be108ec787f4d96390579fb83e Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-4vrf-ff7v-hpgr 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-2020-15208 9.8 TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow CVE-2019-16778 9.8 TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflow CVE-2022-23587 9.8 TensorFlow: integer overflow in Grappler enables RCE
Same package: tensorflow
AI Threat Alert