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

Heap OOB access in `Dilation2DBackpropInput`

CVE-2021-29566

Description

TensorFlow is an end-to-end open source platform for machine learning. An attacker can write outside the bounds of heap allocated arrays by passing invalid arguments to tf.raw_ops.Dilation2DBackpropInput. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/afd954e65f15aea4d438d0a219136fc4a63a573d/tensorflow/core/kernels/dilation_ops.cc#L321-L322) does not validate before writing to the output array. The values for h_out and w_out are guaranteed to be in range for out_backprop (as they are loop indices bounded by the size of the array). However, there are no similar guarantees relating h_in_max/w_in_max and in_backprop. 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
3f6fe4dfef6f

Add missing validations in dillation ops.

https://github.com/tensorflow/tensorflowMihai MaruseacMay 5, 2021via ghsa
1 file changed · +11 4
  • tensorflow/core/kernels/dilation_ops.cc+11 4 modified
    @@ -130,6 +130,7 @@ class DilationOp : public OpKernel {
         ParseSizes(context, strides_, rates_, padding_, &stride_rows, &stride_cols,
                    &rate_rows, &rate_cols, &pad_top, &pad_left, &out_rows,
                    &out_cols);
    +    if (!context->status().ok()) return;
     
         // Output tensor is of the following dimensions:
         // [ batch, out_rows, out_cols, depth ]
    @@ -229,6 +230,7 @@ class DilationBackpropInputOp : public OpKernel {
         ParseSizes(context, strides_, rates_, padding_, &stride_rows, &stride_cols,
                    &rate_rows, &rate_cols, &pad_top, &pad_left, &out_rows,
                    &out_cols);
    +    if (!context->status().ok()) return;
     
         // Verify that the incoming gradient tensor has the expected size
         // [ batch, out_rows, out_cols, depth ]
    @@ -318,8 +320,10 @@ struct DilationBackpropInput<CPUDevice, T> {
                     }
                   }
                 }
    -            in_backprop(b, h_in_max, w_in_max, d) +=
    -                out_backprop(b, h_out, w_out, d);
    +            if (h_in_max < input_rows && w_in_max < input_cols) {
    +              in_backprop(b, h_in_max, w_in_max, d) +=
    +                  out_backprop(b, h_out, w_out, d);
    +            }
               }
             }
           }
    @@ -349,6 +353,7 @@ class DilationBackpropFilterOp : public OpKernel {
         ParseSizes(context, strides_, rates_, padding_, &stride_rows, &stride_cols,
                    &rate_rows, &rate_cols, &pad_top, &pad_left, &out_rows,
                    &out_cols);
    +    if (!context->status().ok()) return;
     
         // Verify that the incoming gradient tensor has the expected size
         // [ batch, out_rows, out_cols, depth ]
    @@ -438,8 +443,10 @@ struct DilationBackpropFilter<CPUDevice, T> {
                     }
                   }
                 }
    -            filter_backprop(h_max, w_max, d) +=
    -                out_backprop(b, h_out, w_out, d);
    +            if (h_max < filter_rows && w_max < filter_cols) {
    +              filter_backprop(h_max, w_max, d) +=
    +                  out_backprop(b, h_out, w_out, d);
    +            }
               }
             }
           }
    

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

7

News mentions

0

No linked articles in our index yet.