{"id":"CVE-2021-29591","published":"2021-05-14T19:22:29Z","modified":"2024-08-03T22:11:06Z","title":"Stack overflow due to looping TFLite subgraph","vendor":"tensorflow","product":"tensorflow","tier":"tail","description":{"text":"TensorFlow is an end-to-end open source platform for machine learning. TFlite graphs must not have loops between nodes. However, this condition was not checked and an attacker could craft models that would result in infinite loop during evaluation. In certain cases, the infinite loop would be replaced by stack overflow due to too many recursive calls. For example, the `While` implementation(https://github.com/tensorflow/tensorflow/blob/106d8f4fb89335a2c52d7c895b7a7485465ca8d9/tensorflow/lite/kernels/while.cc) could be tricked into a scneario where both the body and the loop subgraphs are the same. Evaluating one of the subgraphs means calling the `Eval` function for the other and this quickly exhaust all stack space. 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. Please consult our security guide(https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how to contact us with issues and questions.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.3,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00262,"percentile":0.18391,"provenance":"source"},"cwes":[{"id":"CWE-835","name":"Loop with Unreachable Exit Condition"}],"references":[{"url":"https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cwv3-863g-39vx","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/tensorflow/tensorflow/commit/9c1dc920d8ffb4893d6c9d27d1f039607b326743","tags":["x_refsource_MISC"]},{"url":"https://github.com/tensorflow/tensorflow/commit/c6173f5fe66cdbab74f4f869311fe6aae2ba35f4","tags":["x_refsource_MISC"]}],"priority":{"score":8.8,"factors":[{"name":"EPSS percentile","points":3.68},{"name":"CVSS severity","points":5.11}]},"vendorSlug":"tensorflow","affectedVersions":[{"vendor":"tensorflow","product":"tensorflow","versions":["< 2.1.4",">= 2.2.0, < 2.2.3",">= 2.3.0, < 2.3.3",">= 2.4.0, < 2.4.2"]}],"affected":[{"ecosystem":"PyPI","package":"tensorflow","vulnerableRanges":["<2.1.4",">=2.2.0, <2.2.3",">=2.3.0, <2.3.3",">=2.4.0, <2.4.2"],"patched":["2.1.4","2.2.3","2.3.3","2.4.2"],"from":["GHSA-cwv3-863g-39vx","PYSEC-2021-228"],"provenance":"source"},{"ecosystem":"PyPI","package":"tensorflow-cpu","vulnerableRanges":["<2.1.4",">=2.2.0, <2.2.3",">=2.3.0, <2.3.3",">=2.4.0, <2.4.2"],"patched":["2.1.4","2.2.3","2.3.3","2.4.2"],"from":["GHSA-cwv3-863g-39vx","PYSEC-2021-519"],"provenance":"source"},{"ecosystem":"PyPI","package":"tensorflow-gpu","vulnerableRanges":["<2.1.4",">=2.2.0, <2.2.3",">=2.3.0, <2.3.3",">=2.4.0, <2.4.2"],"patched":["2.1.4","2.2.3","2.3.3","2.4.2"],"from":["GHSA-cwv3-863g-39vx","PYSEC-2021-717"],"provenance":"source"}],"summary":{"text":"The flaw is in TensorFlow's TFLite runtime, where graphs containing loops between nodes are not rejected, so the While kernel can be made to evaluate a body and loop subgraph that are the same. An attacker who can supply a crafted TFLite model with local access and low privileges, and who can get that model loaded and evaluated, can trigger an infinite loop or unbounded recursion that exhausts stack space, causing a denial of service.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:07:47Z"},"euvd":{"id":"EUVD-2021-0332","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-tensorflow-cve-2020-15209","parents":[{"from":"CVE-2020-15209","to":"CVE-2021-29591","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["tensorflow/lite/BUILD","tensorflow/lite/core/subgraph.cc"],"commits":["https://github.com/tensorflow/tensorflow/commit/0b5662bc2be13a8c8f044d925d87fb6e56247cd8","https://github.com/tensorflow/tensorflow/commit/9c1dc920d8ffb4893d6c9d27d1f039607b326743","https://github.com/tensorflow/tensorflow/commit/c6173f5fe66cdbab74f4f869311fe6aae2ba35f4"],"basis":"shared function","functions":["cc_test"]}]},{"from":"CVE-2020-15210","to":"CVE-2021-29591","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["tensorflow/lite/BUILD","tensorflow/lite/core/subgraph.cc","tensorflow/lite/core/subgraph.h"],"commits":["https://github.com/tensorflow/tensorflow/commit/d58c96946b2880991d63d1dacacb32f0a4dfa453","https://github.com/tensorflow/tensorflow/commit/094329d0dcb8290bed2b1ee420934971f422c86d","https://github.com/tensorflow/tensorflow/commit/9c1dc920d8ffb4893d6c9d27d1f039607b326743","https://github.com/tensorflow/tensorflow/commit/c6173f5fe66cdbab74f4f869311fe6aae2ba35f4"],"basis":"shared function","functions":["Subgraph","cc_test"]}]}]}}