VYPR
High severityNVD Advisory· Published Aug 12, 2021· Updated Aug 4, 2024

Incomplete validation in `QuantizeV2` in TensorFlow

CVE-2021-37663

Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions due to incomplete validation in tf.raw_ops.QuantizeV2, an attacker can trigger undefined behavior via binding a reference to a null pointer or can access data outside the bounds of heap allocated arrays. The implementation has some validation but does not check that min_range and max_range both have the same non-zero number of elements. If axis is provided (i.e., not -1), then validation should check that it is a value in range for the rank of input tensor and then the lengths of min_range and max_range inputs match the axis dimension of the input tensor. We have patched the issue in GitHub commit 6da6620efad397c85493b8f8667b821403516708. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.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.3.42.3.4
tensorflowPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflowPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-cpuPyPI
< 2.3.42.3.4
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-gpuPyPI
< 2.3.42.3.4
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.12.5.1

Affected products

1

Patches

1
6da6620efad3

Secure tf.raw_ops.QuantizeV2

https://github.com/tensorflow/tensorflowLaura PakJul 28, 2021via ghsa
1 file changed · +43 0
  • tensorflow/core/kernels/quantize_op.cc+43 0 modified
    @@ -113,7 +113,50 @@ class QuantizeV2Op : public OpKernel {
     
         int num_slices = 1;
         if (axis_ > -1) {
    +      OP_REQUIRES(
    +          ctx, input.dims() > axis_,
    +          errors::InvalidArgument(
    +              "Axis is on a zero-based index, so its value must always be less "
    +              "than number of input's dims, but given axis value was ",
    +              axis_, " and input's dims was ", input.dims()));
           num_slices = input.dim_size(axis_);
    +      OP_REQUIRES(ctx, input_min_range.dims() == 1,
    +                  errors::InvalidArgument(
    +                      "If axis is specified, min_range must be a 1-D tensor "
    +                      "whose size matches the axis dimension of the input and "
    +                      "output tensors, but min_range dims are ",
    +                      input_min_range.dims()));
    +      OP_REQUIRES(ctx, input_min_range.dim_size(0) == num_slices,
    +                  errors::InvalidArgument(
    +                      "If axis is specified, min_range must be a 1-D tensor "
    +                      "whose size matches the axis dimension of the input and "
    +                      "output tensors, but min_range is a 1-D tensor of size ",
    +                      input_min_range.dim_size(0),
    +                      " and input's axis dimension is of size ", num_slices));
    +      OP_REQUIRES(ctx, input_max_range.dims() == 1,
    +                  errors::InvalidArgument(
    +                      "If axis is specified, max_range must be a 1-D tensor "
    +                      "whose size matches the axis dimension of the input and "
    +                      "output tensors, but max_range dims are ",
    +                      input_max_range.dims()));
    +      OP_REQUIRES(ctx, input_max_range.dim_size(0) == num_slices,
    +                  errors::InvalidArgument(
    +                      "If axis is specified, max_range must be a 1-D tensor "
    +                      "whose size matches the axis dimension of the input and "
    +                      "output tensors, but max_range is a 1-D tensor of size ",
    +                      input_max_range.dim_size(0),
    +                      " and input's axis dimension is of size ", num_slices));
    +    } else {
    +      OP_REQUIRES(ctx, input_min_range.NumElements() == 1,
    +                  errors::InvalidArgument(
    +                      "If axis is not specified, min_range must contain a "
    +                      "single float element, but it contains ",
    +                      input_min_range.NumElements(), " elements"));
    +      OP_REQUIRES(ctx, input_max_range.NumElements() == 1,
    +                  errors::InvalidArgument(
    +                      "If axis is not specified, max_range must contain a "
    +                      "single float element, but it contains ",
    +                      input_max_range.NumElements(), " elements"));
         }
     
         const TensorShape& minmax_shape = ctx->input(1).shape();
    

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.