CVE-2021-37685: TensorFlow - Out-of-Bounds Read in TFLite's expand_dims.cc
Summary
CVE-2021-37685: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
< d94ffe08a65400f898241c0374e9edc6fa8ed257
Fixed in 2.3.4 or 2.4.3, 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-37685 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 end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices. TFLite's expand_dims.cc is a kernel file responsible for expanding dimensions in a tensor. This vulnerability affects versions of TensorFlow and TFLite.
Vulnerability Detail
The vulnerability in TFLite's expand_dims.cc allows for an out-of-bounds read when a large negative value is passed as the axis parameter. If axis is a value like -100000, it remains negative after the first check in the code. The subsequent check will pass, and the for loop will read one element before the start of the input_dims.data array. This can lead to the disclosure of sensitive information or a crash. The issue has been patched in the GitHub commit d94ffe08a65400f898241c0374e9edc6fa8ed257 and will be included in TensorFlow 2.6.0. The fix will also be backported to TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4.
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.0, < 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"
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 known workaround for this vulnerability. It is recommended to apply the official fix or update to a patched version of TensorFlow as soon as possible.
Conclusion
The vulnerability in TFLite's expand_dims.cc can result in an out-of-bounds read, potentially leading to the disclosure of sensitive information or a crash. It is crucial to update TensorFlow to the patched versions or apply the provided fixes to mitigate the risk. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides tools, libraries, and resources for building and deploying machine learning models.
TensorFlow Lite (TFLite) is a lightweight version of TensorFlow designed for mobile and embedded devices.
This vulnerability can lead to the disclosure of sensitive information or a crash of the affected TensorFlow or TFLite application.
To fix the vulnerability, update TensorFlow to version 2.6.0 or apply the backported fixes for TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4.
There is no known workaround for this vulnerability. It is recommended to apply the official fix or update to a patched version of TensorFlow.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.