VYPR
High severityNVD Advisory· Published Oct 21, 2020· Updated Aug 4, 2024

Segfault in Tensorflow

CVE-2020-15265

Description

In Tensorflow before version 2.4.0, an attacker can pass an invalid axis value to tf.quantization.quantize_and_dequantize. This results in accessing a dimension outside the rank of the input tensor in the C++ kernel implementation. However, dim_size only does a DCHECK to validate the argument and then uses it to access the corresponding element of an array. Since in normal builds, DCHECK-like macros are no-ops, this results in segfault and access out of bounds of the array. The issue is patched in eccb7ec454e6617738554a255d77f08e60ee0808 and TensorFlow 2.4.0 will be released containing the patch. TensorFlow nightly packages after this commit will also have the issue resolved.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 2.4.02.4.0
tensorflow-cpuPyPI
< 2.4.02.4.0
tensorflow-gpuPyPI
< 2.4.02.4.0

Affected products

1

Patches

1
eccb7ec454e6

Prevent segfault in `quantize_and_dequantize`

https://github.com/tensorflow/tensorflowMihai MaruseacOct 20, 2020via ghsa
2 files changed · +20 0
  • tensorflow/core/kernels/quantize_and_dequantize_op.cc+4 0 modified
    @@ -71,6 +71,10 @@ class QuantizeAndDequantizeV2Op : public OpKernel {
     
       void Compute(OpKernelContext* ctx) override {
         const Tensor& input = ctx->input(0);
    +    OP_REQUIRES(
    +        ctx, (axis_ == -1 || axis_ < input.shape().dims()),
    +        errors::InvalidArgument("Shape must be at least rank ", axis_ + 1,
    +                                " but is rank ", input.shape().dims()));
         const int depth = (axis_ == -1) ? 1 : input.dim_size(axis_);
         Tensor input_min_tensor;
         Tensor input_max_tensor;
    
  • tensorflow/python/kernel_tests/array_ops_test.py+16 0 modified
    @@ -1628,6 +1628,22 @@ def testAxis(self):
                       axis=(axis - 4)))
               self.assertAllClose(fake_quantized, expected)
     
    +  def testBadAxis(self):
    +    input_tensor = [2.5, 2.5]
    +    input_min = [0, 0]
    +    input_max = [1, 1]
    +    error_message_pattern = "Shape must be at least rank 11 but is rank 1"
    +    # TODO(b/171260356): Eager mode and graph mode throw different error types
    +    error = errors.InvalidArgumentError if context.executing_eagerly(
    +    ) else ValueError
    +    with self.assertRaisesRegex(error, error_message_pattern):
    +      self.evaluate(
    +          array_ops.quantize_and_dequantize_v2(
    +              input=input_tensor,
    +              input_min=input_min,
    +              input_max=input_max,
    +              axis=10))
    +
       def testQuantizeDequantizeGrad(self):
         shape = (2, 2)
         max_threshold = 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

8

News mentions

0

No linked articles in our index yet.