Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. tensorflow-gpu
  4. ›
  5. CVE-2021-37685

CVE-2021-37685: Heap OOB in TFLite

August 25, 2021 (updated November 13, 2024)

TFLite’s expand_dims.cc contains a vulnerability which allows reading one element outside of bounds of heap allocated data:

if (axis < 0) {
axis = input_dims.size + 1 + axis;
}
TF_LITE_ENSURE(context, axis <= input_dims.size);

TfLiteIntArray* output_dims = TfLiteIntArrayCreate(input_dims.size + 1);
for (int i = 0; i < output_dims->size; ++i) {
if (i < axis) {
output_dims->data[i] = input_dims.data[i];
} else if (i == axis) {
output_dims->data[i] = 1;
} else {
output_dims->data[i] = input_dims.data[i - 1];
}
}

If axis is a large negative value (e.g., -100000), then after the first if it would still be negative. The check following the if statement will pass and the for loop would read one element before the start of input_dims.data (when i = 0).

References

  • github.com/advisories/GHSA-c545-c4f9-rf6v
  • github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-598.yaml
  • github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-796.yaml
  • github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-307.yaml
  • github.com/tensorflow/tensorflow
  • github.com/tensorflow/tensorflow/blob/149562d49faa709ea80df1d99fc41d005b81082a/tensorflow/lite/kernels/expand_dims.cc
  • github.com/tensorflow/tensorflow/commit/d94ffe08a65400f898241c0374e9edc6fa8ed257
  • github.com/tensorflow/tensorflow/security/advisories/GHSA-c545-c4f9-rf6v
  • nvd.nist.gov/vuln/detail/CVE-2021-37685

Code Behaviors & Features

Detect and mitigate CVE-2021-37685 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 2.3.4, all versions starting from 2.4.0 before 2.4.3, all versions starting from 2.5.0 before 2.5.1, version 2.5.0

Fixed versions

  • 2.3.4
  • 2.4.3
  • 2.5.1

Solution

Upgrade to versions 2.3.4, 2.4.3, 2.5.1 or above.

Impact 5.5 MEDIUM

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Learn more about CVSS

Weakness

  • CWE-125: Out-of-bounds Read

Source file

pypi/tensorflow-gpu/CVE-2021-37685.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:02 +0000.