CVE-2021-29593: TensorFlow TFLite: div-by-zero via crafted model file
HIGH PoC AVAILABLEAny 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.
Risk Assessment
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.
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-
Patch: upgrade to TensorFlow 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your branch.
-
Model validation: enforce a model allow-list or hash verification before loading any TFLite file.
-
Sandboxing: run TFLite inference in a sandboxed process (seccomp, gVisor, container with no-new-privileges) to contain blast radius.
-
Detection: monitor for SIGFPE / divide-by-zero signals in inference processes; unexpected crashes in model serving workers should trigger incident response.
-
Supply chain: audit third-party model sources; prefer signed model artifacts.
Classification
Compliance Impact
This CVE is relevant to:
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.01%.
Technical Details
NVD Description
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)
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/2c74674348a4708ced58ad6eb1b23354df8ee044 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-cfx7-2xpc-8w4h 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