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

CHECK-fail in DrawBoundingBoxes

CVE-2021-29533

Description

TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a denial of service via a CHECK failure by passing an empty image to tf.raw_ops.DrawBoundingBoxes. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/ea34a18dc3f5c8d80a40ccca1404f343b5d55f91/tensorflow/core/kernels/image/draw_bounding_box_op.cc#L148-L165) uses CHECK_* assertions instead of OP_REQUIRES to validate user controlled inputs. Whereas OP_REQUIRES allows returning an error condition back to the user, the CHECK_* macros result in a crash if the condition is false, similar to assert. In this case, height is 0 from the images input. This results in max_box_row_clamp being negative and the assertion being falsified, followed by aborting program execution. 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
b432a38fe0e1

Fix overflow CHECK issue with `tf.raw_ops.DrawBoundingBoxes`.

https://github.com/tensorflow/tensorflowAmit PatankarApr 21, 2021via ghsa
1 file changed · +36 12
  • tensorflow/core/kernels/image/draw_bounding_box_op.cc+36 12 modified
    @@ -147,22 +147,46 @@ class DrawBoundingBoxesOp : public OpKernel {
     
             // At this point, {min,max}_box_{row,col}_clamp are inside the
             // image.
    -        CHECK_GE(min_box_row_clamp, 0);
    -        CHECK_GE(max_box_row_clamp, 0);
    -        CHECK_LT(min_box_row_clamp, height);
    -        CHECK_LT(max_box_row_clamp, height);
    -        CHECK_GE(min_box_col_clamp, 0);
    -        CHECK_GE(max_box_col_clamp, 0);
    -        CHECK_LT(min_box_col_clamp, width);
    -        CHECK_LT(max_box_col_clamp, width);
    +        OP_REQUIRES(
    +            context, min_box_row_clamp >= 0,
    +            errors::InvalidArgument("Min box row clamp is less than 0."));
    +        OP_REQUIRES(
    +            context, max_box_row_clamp >= 0,
    +            errors::InvalidArgument("Max box row clamp is less than 0."));
    +        OP_REQUIRES(context, min_box_row_clamp <= height,
    +                    errors::InvalidArgument(
    +                        "Min box row clamp is greater than height."));
    +        OP_REQUIRES(context, max_box_row_clamp <= height,
    +                    errors::InvalidArgument(
    +                        "Max box row clamp is greater than height."));
    +
    +        OP_REQUIRES(
    +            context, min_box_col_clamp >= 0,
    +            errors::InvalidArgument("Min box col clamp is less than 0."));
    +        OP_REQUIRES(
    +            context, max_box_col_clamp >= 0,
    +            errors::InvalidArgument("Max box col clamp is less than 0."));
    +        OP_REQUIRES(context, min_box_col_clamp <= width,
    +                    errors::InvalidArgument(
    +                        "Min box col clamp is greater than width."));
    +        OP_REQUIRES(context, max_box_col_clamp <= width,
    +                    errors::InvalidArgument(
    +                        "Max box col clamp is greater than width."));
     
             // At this point, the min_box_row and min_box_col are either
             // in the image or above/left of it, and max_box_row and
             // max_box_col are either in the image or below/right or it.
    -        CHECK_LT(min_box_row, height);
    -        CHECK_GE(max_box_row, 0);
    -        CHECK_LT(min_box_col, width);
    -        CHECK_GE(max_box_col, 0);
    +
    +        OP_REQUIRES(
    +            context, min_box_row <= height,
    +            errors::InvalidArgument("Min box row is greater than height."));
    +        OP_REQUIRES(context, max_box_row >= 0,
    +                    errors::InvalidArgument("Max box row is less than 0."));
    +        OP_REQUIRES(
    +            context, min_box_col <= width,
    +            errors::InvalidArgument("Min box col is greater than width."));
    +        OP_REQUIRES(context, max_box_col >= 0,
    +                    errors::InvalidArgument("Max box col is less than 0."));
     
             // Draw top line.
             if (min_box_row >= 0) {
    

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.