VYPR
Critical severityNVD Advisory· Published Mar 24, 2023· Updated Feb 19, 2025

TensorFlow vulnerable to heap out-of-buffer read in the QuantizeAndDequantize operation

CVE-2023-25668

Description

TensorFlow is an open source platform for machine learning. Attackers using Tensorflow prior to 2.12.0 or 2.11.1 can access heap memory which is not in the control of user, leading to a crash or remote code execution. The fix will be included in TensorFlow version 2.12.0 and will also cherrypick this commit on TensorFlow version 2.11.1.

Affected packages

Versions sourced from the GitHub Security Advisory.

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

Affected products

1

Patches

1
7b174a0f2e40

Fix asan issue with QuantizeAndDequantizeV2/V3/V4/V4Grad shape inference functions.

https://github.com/tensorflow/tensorflowSagun BajraNov 9, 2022via ghsa
2 files changed · +82 0
  • tensorflow/core/ops/array_ops.cc+16 0 modified
    @@ -2879,6 +2879,10 @@ REGISTER_OP("QuantizeAndDequantizeV2")
                                            axis);
           } else if (axis != -1) {
             ShapeHandle input;
    +        if (axis >= kint32max) {
    +          return errors::InvalidArgument(
    +              "Axis cannot be >= kint32max value, got ", axis);
    +        }
             TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input));
             DimensionHandle depth;
             TF_RETURN_IF_ERROR(
    @@ -2914,6 +2918,10 @@ REGISTER_OP("QuantizeAndDequantizeV4")
                                            axis);
           } else if (axis != -1) {
             ShapeHandle input;
    +        if (axis >= kint32max) {
    +          return errors::InvalidArgument(
    +              "Axis cannot be >= kint32max value, got ", axis);
    +        }
             TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input));
             DimensionHandle depth;
             TF_RETURN_IF_ERROR(
    @@ -2945,6 +2953,10 @@ REGISTER_OP("QuantizeAndDequantizeV4Grad")
                                            axis);
           } else if (axis != -1) {
             ShapeHandle input;
    +        if (axis >= kint32max) {
    +          return errors::InvalidArgument(
    +              "Axis cannot be >= kint32max value, got ", axis);
    +        }
             TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input));
             DimensionHandle depth;
             TF_RETURN_IF_ERROR(
    @@ -2981,6 +2993,10 @@ REGISTER_OP("QuantizeAndDequantizeV3")
                                            axis);
           } else if (axis != -1) {
             ShapeHandle input;
    +        if (axis >= kint32max) {
    +          return errors::InvalidArgument(
    +              "Axis cannot be >= kint32max value, got ", axis);
    +        }
             TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input));
             DimensionHandle depth;
             TF_RETURN_IF_ERROR(
    
  • tensorflow/python/kernel_tests/array_ops/array_ops_test.py+66 0 modified
    @@ -1856,6 +1856,72 @@ def testOutOfBoundAxis(self):
                   max_range=input_max,
                   axis=2**31 - 1))
     
    +  @test_util.run_v2_only
    +  def testInvalidAxis(self):
    +
    +    @def_function.function
    +    def test_quantize_and_dequantize_v2():
    +      gen_array_ops.quantize_and_dequantize_v2(
    +          input=[2.5],
    +          input_min=[1.0],
    +          input_max=[10.0],
    +          signed_input=True,
    +          num_bits=1,
    +          range_given=True,
    +          round_mode="HALF_TO_EVEN",
    +          narrow_range=True,
    +          axis=0x7fffffff)
    +
    +    @def_function.function
    +    def test_quantize_and_dequantize_v3():
    +      gen_array_ops.quantize_and_dequantize_v3(
    +          input=[2.5],
    +          input_min=[1.0],
    +          input_max=[10.0],
    +          num_bits=1,
    +          signed_input=True,
    +          range_given=True,
    +          narrow_range=True,
    +          axis=0x7fffffff)
    +
    +    @def_function.function
    +    def test_quantize_and_dequantize_v4():
    +      gen_array_ops.quantize_and_dequantize_v4(
    +          input=[2.5],
    +          input_min=[1.0],
    +          input_max=[10.0],
    +          signed_input=True,
    +          num_bits=1,
    +          range_given=True,
    +          round_mode="HALF_TO_EVEN",
    +          narrow_range=True,
    +          axis=0x7fffffff)
    +
    +    @def_function.function
    +    def test_quantize_and_dequantize_v4_grad():
    +      gen_array_ops.quantize_and_dequantize_v4_grad(
    +          gradients=[2.5],
    +          input=[2.5],
    +          input_min=[1.0],
    +          input_max=[10.0],
    +          axis=0x7fffffff)
    +
    +    with self.assertRaisesRegex(
    +        ValueError, "Axis cannot be >= kint32max value, got 2147483647"):
    +      test_quantize_and_dequantize_v2()
    +
    +    with self.assertRaisesRegex(
    +        ValueError, "Axis cannot be >= kint32max value, got 2147483647"):
    +      test_quantize_and_dequantize_v3()
    +
    +    with self.assertRaisesRegex(
    +        ValueError, "Axis cannot be >= kint32max value, got 2147483647"):
    +      test_quantize_and_dequantize_v4()
    +
    +    with self.assertRaisesRegex(
    +        ValueError, "Axis cannot be >= kint32max value, got 2147483647"):
    +      test_quantize_and_dequantize_v4_grad()
    +
     
     @test_util.run_all_in_graph_and_eager_modes
     class SortedSearchTest(test_util.TensorFlowTestCase):
    

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

4

News mentions

0

No linked articles in our index yet.