VYPR
Moderate severityNVD Advisory· Published May 14, 2021· Updated Aug 3, 2024

Null pointer dereference in TFLite's `Reshape` operator

CVE-2021-29592

Description

TensorFlow is an end-to-end open source platform for machine learning. The fix for CVE-2020-15209(https://cve.mitre.org/cgi-bin/cvename.cgi?name=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(https://github.com/tensorflow/tensorflow/blob/9c1dc920d8ffb4893d6c9d27d1f039607b326743/tensorflow/lite/core/subgraph.cc#L1062-L1074) allowed passing a null-buffer-backed tensor with a 1D shape. 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.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 2.1.42.1.4
tensorflowPyPI
>= 2.2.0, < 2.2.32.2.3
tensorflowPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflowPyPI
>= 2.4.0, < 2.4.22.4.2
tensorflow-cpuPyPI
< 2.1.42.1.4
tensorflow-cpuPyPI
>= 2.2.0, < 2.2.32.2.3
tensorflow-cpuPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.22.4.2
tensorflow-gpuPyPI
< 2.1.42.1.4
tensorflow-gpuPyPI
>= 2.2.0, < 2.2.32.2.3
tensorflow-gpuPyPI
>= 2.3.0, < 2.3.32.3.3
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.22.4.2

Affected products

1

Patches

1
f8378920345f

Prevent a null pointer dereference in TFLite.

https://github.com/tensorflow/tensorflowMihai MaruseacApr 28, 2021via ghsa
1 file changed · +10 3
  • tensorflow/lite/core/subgraph.cc+10 3 modified
    @@ -1060,10 +1060,17 @@ TfLiteStatus Subgraph::Invoke() {
             TF_LITE_ENSURE_STATUS(EnsureTensorDataIsReadable(tensor_index));
           }
           if (tensor->data.raw == nullptr && tensor->bytes > 0) {
    -        if (registration.builtin_code == kTfLiteBuiltinReshape && i == 1) {
    +        if (registration.builtin_code == kTfLiteBuiltinReshape && i == 1 &&
    +            tensor->dims->size != 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.
    +          // However, for the reshape operator, the second input tensor is
    +          // sometimes only used for the shape, not for the data. Thus, null
    +          // buffer is ok in this situation.
    +          // The situation where null buffer is not ok for reshape operator is
    +          // only when there are 2 inputs given to the node and the one
    +          // corresponding to the shape (i == 1) is a vector that contains all
    +          // dimensions. See `GetOutputShape()` function in
    +          // `tensorflow/lite/kernels/reshape.cc`
               continue;
             } else {
               // In all other cases, we need to return an error as otherwise we will
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

8

News mentions

0

No linked articles in our index yet.