CVE-2021-37655: Heap OOB in tensorflow
Summary
CVE-2021-37655: Heap OOB in ResourceScatterUpdate. 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-37655 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 widely used for developing and training machine learning models. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning applications. TensorFlow allows users to create and manipulate tensors, which are multi-dimensional arrays, as the fundamental data structure for computations. However, a vulnerability has been discovered in TensorFlow that could lead to a heap out-of-bounds (OOB) read.
Vulnerability Detail
The vulnerability, identified as CVE-2021-37655, resides in the ResourceScatterUpdate function of TensorFlow. By providing invalid arguments to this function, an attacker can trigger a read from outside the bounds of heap allocated data. Specifically, the implementation of ResourceScatterUpdate fails to properly validate the relationship between the shapes of the indices and updates tensors. Instead of checking that the shape of indices is a prefix of the shape of updates to allow for broadcasting, the code only verifies that the number of elements in these tensors are in a divisibility relationship. This incomplete validation can be exploited by an attacker to read sensitive data or cause a denial-of-service (DoS) condition.
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
As a temporary workaround, users can ensure that the indices tensor has a shape that is a prefix of the updates tensor's shape. This can be achieved by reshaping or padding the indices tensor to match the required shape. However, it is strongly recommended to apply the official patch as soon as possible.
Conclusion
The vulnerability in TensorFlow (CVE-2021-37655) exposes users to the risk of heap out-of-bounds reads. It is crucial to update to the patched versions of TensorFlow (2.6.0, 2.5.1, 2.4.3, or 2.3.4) to mitigate this vulnerability. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework used for developing and training machine learning models.
The vulnerability allows an attacker to read data from outside the bounds of heap allocated memory, potentially leading to information disclosure or a DoS condition.
To fix the vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.6.0, TensorFlow 2.5.1, TensorFlow 2.4.3, or TensorFlow 2.3.4.
As a temporary workaround, ensure that the indices tensor has a shape that is a prefix of the updates tensor's shape.
This vulnerability was reported by members of the Aivul Team from Qihoo 360.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.