CVE-2021-37685: TensorFlow Lite: OOB read leaks heap memory in expand_dims
MEDIUMA low-privilege local attacker can trigger a heap out-of-bounds read in TFLite's expand_dims kernel by passing a large negative axis value, potentially leaking heap memory contents including model data or process secrets. Patch immediately to TF 2.6.0 or apply backports to 2.5.1/2.4.3/2.3.4. Risk is highest in shared ML infrastructure or edge deployments that execute untrusted TFLite models.
Risk Assessment
Medium risk (CVSS 5.5). Local attack vector limits broad exposure, but low attack complexity and no user interaction required means exploitation is straightforward once local access is obtained. In multi-tenant ML training environments or model serving platforms processing user-supplied TFLite models, the confidentiality impact is material. Not in CISA KEV; no active exploitation reported. Severity is bounded by local-only vector.
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.6.0 or apply backport patches to TF 2.5.1, 2.4.3, or 2.3.4 (commit d94ffe08a65400f898241c0374e9edc6fa8ed257).
-
Audit all TFLite model sources — implement allowlisting and cryptographic verification of .tflite files before execution.
-
Run TFLite inference in sandboxed, least-privilege processes to limit blast radius of any memory disclosure.
-
Enable memory-safety tooling (ASAN/MSAN) in CI/CD pipelines to catch similar OOB issues before production.
-
Monitor for anomalous model loading from untrusted or unexpected sources in ML serving logs.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-37685?
A low-privilege local attacker can trigger a heap out-of-bounds read in TFLite's expand_dims kernel by passing a large negative axis value, potentially leaking heap memory contents including model data or process secrets. Patch immediately to TF 2.6.0 or apply backports to 2.5.1/2.4.3/2.3.4. Risk is highest in shared ML infrastructure or edge deployments that execute untrusted TFLite models.
Is CVE-2021-37685 actively exploited?
No confirmed active exploitation of CVE-2021-37685 has been reported, but organizations should still patch proactively.
How to fix CVE-2021-37685?
1. Upgrade to TensorFlow 2.6.0 or apply backport patches to TF 2.5.1, 2.4.3, or 2.3.4 (commit d94ffe08a65400f898241c0374e9edc6fa8ed257). 2. Audit all TFLite model sources — implement allowlisting and cryptographic verification of .tflite files before execution. 3. Run TFLite inference in sandboxed, least-privilege processes to limit blast radius of any memory disclosure. 4. Enable memory-safety tooling (ASAN/MSAN) in CI/CD pipelines to catch similar OOB issues before production. 5. Monitor for anomalous model loading from untrusted or unexpected sources in ML serving logs.
What systems are affected by CVE-2021-37685?
This vulnerability affects the following AI/ML architecture patterns: model serving, training pipelines, edge/IoT AI deployments, mobile ML inference.
What is the CVSS score for CVE-2021-37685?
CVE-2021-37685 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.04%.
Technical Details
NVD Description
TensorFlow is an end-to-end open source platform for machine learning. In affected versions TFLite's [`expand_dims.cc`](https://github.com/tensorflow/tensorflow/blob/149562d49faa709ea80df1d99fc41d005b81082a/tensorflow/lite/kernels/expand_dims.cc#L36-L50) contains a vulnerability which allows reading one element outside of bounds of heap allocated data. If `axis` is a large negative value (e.g., `-100000`), then after the first `if` it would still be negative. The check following the `if` statement will pass and the `for` loop would read one element before the start of `input_dims.data` (when `i = 0`). We have patched the issue in GitHub commit d94ffe08a65400f898241c0374e9edc6fa8ed257. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Exploitation Scenario
An attacker with local access to a system running a vulnerable TFLite inference service crafts a malicious .tflite model in which the expand_dims operator is configured with a large negative axis value (e.g., -100000). When the model is loaded and executed for inference, the unvalidated axis value bypasses the bounds check — the first conditional leaves it negative, the subsequent check passes incorrectly, and the for loop reads one element before the start of the heap-allocated input_dims buffer. This leaks a memory value from the preceding heap chunk, potentially exposing sensitive runtime data. In a shared ML serving environment where multiple tenants submit models for inference, this becomes a cross-tenant information disclosure primitive.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N References
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