CVE-2021-37685: TensorFlow - Out-of-bounds Read Vulnerability
Summary
CVE-2021-37685: Heap OOB in TensorFlow Lite. Affects tensorflow across 3 version ranges.
>= 2.3.0, < 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 · PyPI
- tensorflow · PyPI
- 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 resources for developing and deploying machine learning models. TensorFlow is widely used in various industries and research domains for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that could potentially lead to an out-of-bounds read.
Vulnerability Detail
The vulnerability exists in TFLite's expand_dims.cc file. When a large negative value is provided as the axis parameter, the code fails to properly handle it. As a result, the subsequent check passes and a for loop reads one element before the start of the heap-allocated input_dims.data array. This can lead to the disclosure of sensitive information or a crash. The vulnerability has been assigned CVE-2021-37685 and has a CVSSv3 score of 7.5 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 2.3.0, < 2.3.42.3.4 -
>= 2.4.0, < 2.4.32.4.3 -
>= 2.5.0, < 2.5.12.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 workaround, users can avoid passing large negative values as the axis parameter in TFLite's expand_dims function. By ensuring that the axis value is within a valid range, the vulnerability can be mitigated. Here is an example of how to check and adjust the axis value:
if axis < 0:
axis = max(axis, -len(input_dims) - 1)
Conclusion
In conclusion, TensorFlow is affected by an out-of-bounds read vulnerability in TFLite's expand_dims.cc file. This vulnerability can be mitigated by updating to TensorFlow 2.6.0 or applying the provided patch. Backported fixes are also available for older versions. Regularly updating TensorFlow is crucial to ensure the security of machine learning applications. For further support on 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 and libraries for developing and deploying machine learning models.
The vulnerability allows for an out-of-bounds read, which can lead to the disclosure of sensitive information or a crash of the application using TensorFlow.
To fix this vulnerability, update TensorFlow to version 2.6.0 or apply the provided patch. Backported fixes are also available for versions 2.5.1, 2.4.3, and 2.3.4.
Yes, you can avoid passing large negative values as the axis parameter in TFLite's expand_dims function to mitigate the vulnerability.
You can obtain the updated versions of TensorFlow from the official TensorFlow GitHub repository or through package managers.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.