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

Heap buffer overflow in `Conv2DBackpropFilter`

CVE-2021-29540

Description

TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a heap buffer overflow to occur in Conv2DBackpropFilter. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1b0296c3b8dd9bd948f924aa8cd62f87dbb7c3da/tensorflow/core/kernels/conv_grad_filter_ops.cc#L495-L497) computes the size of the filter tensor but does not validate that it matches the number of elements in filter_sizes. Later, when reading/writing to this buffer, code uses the value computed here, instead of the number of elements in the tensor. 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
c570e2ecfc82

Fix issues in Conv2DBackpropFilter.

https://github.com/tensorflow/tensorflowMihai MaruseacApr 22, 2021via ghsa
1 file changed · +13 0
  • tensorflow/core/kernels/conv_grad_filter_ops.cc+13 0 modified
    @@ -495,6 +495,14 @@ class Conv2DCustomBackpropFilterOp : public OpKernel {
         const int filter_total_size = dims.spatial_dims[0].filter_size *
                                       dims.spatial_dims[1].filter_size *
                                       dims.in_depth;
    +    OP_REQUIRES(
    +        context,
    +        filter_total_size * dims.out_depth == filter_backprop->NumElements(),
    +        errors::InvalidArgument(
    +            "filter_size does not have enough elements, requested ",
    +            filter_total_size * dims.out_depth, ", got ",
    +            filter_backprop->NumElements()));
    +
         // The output image size is the spatial size of the output.
         const int output_image_size =
             dims.spatial_dims[0].output_size * dims.spatial_dims[1].output_size;
    @@ -518,6 +526,11 @@ class Conv2DCustomBackpropFilterOp : public OpKernel {
     
         const size_t work_unit_size = size_A + size_B + size_C;
     
    +    OP_REQUIRES(
    +        context, work_unit_size != 0,
    +        errors::InvalidArgument(
    +            "Work size for convolution would be 0, which is not acceptable"));
    +
         const size_t shard_size =
             (target_working_set_size + work_unit_size - 1) / work_unit_size;
     
    

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.