CVE-2021-37687: Heap OOB in TFLite's Gather* implementations in TensorFlow
Summary
CVE-2021-37687: Heap OOB in TFLite's Gather* implementations. Affects tensorflow across 3 version ranges.
< 2.3.4
>= 2.4.0, < 2.4.3
>= 2.5.0, < 2.5.1
Fixed in 2.3.4, 2.4.3 or 2.5.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-37687 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and community resources for building and deploying machine learning models. TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. TFLite includes various kernel implementations, including Gather and GatherNd, which are used for gathering elements from tensors based on indices. These implementations had a vulnerability that allowed an attacker to read arbitrary data from the heap by crafting a model with negative values in the indices parameter.
Vulnerability Detail
The vulnerability in TFLite's Gather and GatherNd implementations arises from the lack of support for negative indices and the absence of proper checks for this situation. An attacker can exploit this vulnerability by carefully constructing a model with negative values in the indices parameter. By doing so, they can read arbitrary data from the heap, potentially exposing sensitive information. The vulnerability has a CVSS score of 5.5, indicating a moderate severity level.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.0"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 2.3.42.3.4pip install --upgrade "tensorflow==2.3.4" -
>= 2.4.0, < 2.4.32.4.3pip install --upgrade "tensorflow==2.4.3" -
>= 2.5.0, < 2.5.12.5.1pip install --upgrade "tensorflow==2.5.1"
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
There is no specific workaround mentioned for this vulnerability. However, users can mitigate the risk by ensuring that they do not use negative indices in the indices parameter of the Gather and GatherNd operations in TFLite.
Conclusion
The vulnerability in TFLite's Gather and GatherNd implementations in TensorFlow allows an attacker to read arbitrary data from the heap by using negative indices. This can lead to potential exposure of sensitive information. It is recommended to update to the latest patched version of TensorFlow to mitigate the vulnerability. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides tools and libraries for building and deploying machine learning models.
TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. It includes various kernel implementations for efficient execution on resource-constrained platforms.
Gather and GatherNd are operations in TFLite that allow gathering elements from tensors based on indices. They are commonly used in machine learning models for tasks like indexing and slicing tensors.
An attacker can exploit this vulnerability by crafting a model with negative values in the indices parameter of the Gather or GatherNd operations. This allows them to read arbitrary data from the heap, potentially exposing sensitive information.
The vulnerability has a CVSS score of 5.5, indicating a moderate severity level.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.