CVE-2021-29586: TFLite: div-by-zero in pooling crashes inference engine
HIGH PoC AVAILABLEA crafted TFLite model with stride=0 in pooling layers crashes the inference runtime via division by zero. Any pipeline that loads externally-supplied or untrusted TFLite models is exposed to denial of service. Patch to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 immediately and enforce model provenance controls to block untrusted model loading.
Risk Assessment
CVSS 7.8 High with local attack vector and low complexity. Risk is lower in isolated dev environments but escalates sharply in any system exposing model upload or inference capabilities — MLaaS platforms, edge device management, and mobile app update pipelines all become practical DoS vectors requiring only a crafted model file. No active exploitation observed; not in CISA KEV. Patch urgency is moderate given 2021 publication date — if still unpatched, treat as critical.
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 to TensorFlow 2.5.0 or apply cherry-picked fixes in 2.4.2, 2.3.3, 2.2.3, 2.1.4.
-
Add model validation gates: reject TFLite models with stride values ≤ 0 before inference execution.
-
Run TFLite inference in isolated containers or sandboxes to contain crash blast radius.
-
Audit CI/CD pipelines that execute model inference during build or test phases.
-
Detection: monitor for abnormal process terminations in inference services and alert on unexpected stride parameter values in model metadata.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29586?
A crafted TFLite model with stride=0 in pooling layers crashes the inference runtime via division by zero. Any pipeline that loads externally-supplied or untrusted TFLite models is exposed to denial of service. Patch to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 immediately and enforce model provenance controls to block untrusted model loading.
Is CVE-2021-29586 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29586, increasing the risk of exploitation.
How to fix CVE-2021-29586?
1. Patch to TensorFlow 2.5.0 or apply cherry-picked fixes in 2.4.2, 2.3.3, 2.2.3, 2.1.4. 2. Add model validation gates: reject TFLite models with stride values ≤ 0 before inference execution. 3. Run TFLite inference in isolated containers or sandboxes to contain crash blast radius. 4. Audit CI/CD pipelines that execute model inference during build or test phases. 5. Detection: monitor for abnormal process terminations in inference services and alert on unexpected stride parameter values in model metadata.
What systems are affected by CVE-2021-29586?
This vulnerability affects the following AI/ML architecture patterns: model serving, edge/mobile inference, training pipelines, CI/CD model validation.
What is the CVSS score for CVE-2021-29586?
CVE-2021-29586 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. Optimized pooling implementations in TFLite fail to check that the stride arguments are not 0 before calling `ComputePaddingHeightWidth`(https://github.com/tensorflow/tensorflow/blob/3f24ccd932546416ec906a02ddd183b48a1d2c83/tensorflow/lite/kernels/pooling.cc#L90). Since users can craft special models which will have `params->stride_{height,width}` be zero, this will result in a division by zero. 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 pipeline crafts a TFLite model file with a Max Pooling layer where stride_height=0. The file is submitted via a model upload endpoint, injected into an automated retraining pipeline, or bundled into a malicious model repository contribution. When the TFLite runtime loads and executes the model, ComputePaddingHeightWidth performs integer division by stride_height (0), triggering a hard crash. In high-availability inference services or edge device fleets, repeated submission causes sustained availability degradation or full service outage at negligible attacker cost.
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/5f7975d09eac0f10ed8a17dbb6f5964977725adc Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-26j7-6w8w-7922 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