MISFIRE

Browse / AI Framework and Platform Flaws / CVE-2021-29592

Null pointer dereference in TFLite's `Reshape` operator

CVE-2021-29592 ยท 2021-05-21 moderate

Class
AI Framework and Platform Flaws (filed by a model that read the source)
Technique
Denial of service
Affected
tensorflow-cpu, tensorflow (PyPI)
Gets past
Earlier patch
CVSS
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
EPSS
0.2% chance of exploitation in 30 days

How it works, in short

A reshape input with no data buffer, supplied as a 1-D shape tensor, slips past an earlier null check and is dereferenced. (Our summary, written by a model. The source text is below.)

Details

Impact

The fix for CVE-2020-15209 missed the case when the target shape of Reshape operator is given by the elements of a 1-D tensor. As such, the fix for the vulnerability allowed passing a null-buffer-backed tensor with a 1D shape:

if (tensor->data.raw == nullptr && tensor->bytes > 0) {
  if (registration.builtin_code == kTfLiteBuiltinReshape && i == 1) {
    // In general, having a tensor here with no buffer will be an error.
    // However, for the reshape operator, the second input tensor is only
    // used for the shape, not for the data. Thus, null buffer is ok.
    continue;
  } else {
    // In all other cases, we need to return an error as otherwise we will
    // trigger a null pointer dereference (likely).
    ReportError("Input tensor %d lacks data", tensor_index);
    return kTfLiteError;
  }
}

Patches

We have patched the issue in GitHub commit f8378920345f4f4604202d4ab15ef64b2aceaa16.

The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.

For more information

Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.

Attribution

This vulnerability has been reported by members of the Aivul Team from Qihoo 360.

References

Source: GitHub Advisory Database, used under CC BY 4.0.