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

Division by 0 in `Conv3DBackprop*`

CVE-2021-29522

Description

TensorFlow is an end-to-end open source platform for machine learning. The tf.raw_ops.Conv3DBackprop* operations fail to validate that the input tensors are not empty. In turn, this would result in a division by 0. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/a91bb59769f19146d5a0c20060244378e878f140/tensorflow/core/kernels/conv_grad_ops_3d.cc#L430-L450) does not check that the divisor used in computing the shard size is not zero. Thus, if attacker controls the input sizes, they can trigger a denial of service via a division by zero error. 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
311403edbc98

Eliminate a division by 0 in 3D convolutions.

https://github.com/tensorflow/tensorflowMihai MaruseacApr 19, 2021via ghsa
1 file changed · +42 0
  • tensorflow/core/kernels/conv_grad_ops_3d.cc+42 0 modified
    @@ -239,6 +239,14 @@ class Conv3DBackpropInputOp : public OpKernel {
           input_shape = context->input(0).shape();
         }
     
    +    OP_REQUIRES(context, input_shape.dims() == 5,
    +                errors::InvalidArgument("input tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, filter_shape.dims() == 5,
    +        errors::InvalidArgument("filter_sizes tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, out_backprop_shape.dims() == 5,
    +        errors::InvalidArgument("out_backprop tensor must have 5 dimensions"));
         OP_REQUIRES(
             context, input_shape.dim_size(4) == filter_shape.dim_size(3),
             errors::InvalidArgument("input and filter_sizes must have the same "
    @@ -360,6 +368,14 @@ class Conv3DCustomBackpropInputOp : public OpKernel {
           input_shape = context->input(0).shape();
         }
     
    +    OP_REQUIRES(context, input_shape.dims() == 5,
    +                errors::InvalidArgument("input tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, filter_shape.dims() == 5,
    +        errors::InvalidArgument("filter_sizes tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, out_backprop_shape.dims() == 5,
    +        errors::InvalidArgument("out_backprop tensor must have 5 dimensions"));
         OP_REQUIRES(
             context, input_shape.dim_size(4) == filter_shape.dim_size(3),
             errors::InvalidArgument("input and filter_sizes must have the same "
    @@ -444,6 +460,11 @@ class Conv3DCustomBackpropInputOp : public OpKernel {
         // contraction compared to sharding and matmuls.
         const bool use_parallel_contraction = dims.batch_size == 1;
     
    +    OP_REQUIRES(
    +        context, work_unit_size > 0,
    +        errors::InvalidArgument("input, filter_sizes and out_backprop tensors "
    +                                "must all have at least 1 element"));
    +
         const size_t shard_size =
             use_parallel_contraction
                 ? 1
    @@ -724,6 +745,14 @@ class Conv3DBackpropFilterOp : public OpKernel {
           filter_shape = context->input(1).shape();
         }
     
    +    OP_REQUIRES(context, input_shape.dims() == 5,
    +                errors::InvalidArgument("input tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, filter_shape.dims() == 5,
    +        errors::InvalidArgument("filter_sizes tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, out_backprop_shape.dims() == 5,
    +        errors::InvalidArgument("out_backprop tensor must have 5 dimensions"));
         OP_REQUIRES(
             context, input_shape.dim_size(4) == filter_shape.dim_size(3),
             errors::InvalidArgument("input and filter_sizes must have the same "
    @@ -850,6 +879,14 @@ class Conv3DCustomBackpropFilterOp : public OpKernel {
           filter_shape = context->input(1).shape();
         }
     
    +    OP_REQUIRES(context, input_shape.dims() == 5,
    +                errors::InvalidArgument("input tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, filter_shape.dims() == 5,
    +        errors::InvalidArgument("filter_sizes tensor must have 5 dimensions"));
    +    OP_REQUIRES(
    +        context, out_backprop_shape.dims() == 5,
    +        errors::InvalidArgument("out_backprop tensor must have 5 dimensions"));
         OP_REQUIRES(
             context, input_shape.dim_size(4) == filter_shape.dim_size(3),
             errors::InvalidArgument("input and filter_sizes must have the same "
    @@ -936,6 +973,11 @@ class Conv3DCustomBackpropFilterOp : public OpKernel {
     
         const int64 work_unit_size = size_A + size_B + size_C;
     
    +    OP_REQUIRES(
    +        context, work_unit_size > 0,
    +        errors::InvalidArgument("input, filter_sizes and out_backprop tensors "
    +                                "must all have at least 1 element"));
    +
         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.