CVE-2021-37685: TensorFlow - Out-of-bounds Read Vulnerability

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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.4 2.3.4
  • >= 2.4.0, < 2.4.3 2.4.3
  • >= 2.5.0, < 2.5.1 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 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 2.3.0, < 2.3.4 2.3.4
  • >= 2.4.0, < 2.4.3 2.4.3
  • >= 2.5.0, < 2.5.1 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback