CVE-2023-25661: Insufficient Information (NVD-CWE-noinfo)
value: TensorFlow is an Open Source Machine Learning Framework. In versions prior to 2.11.1 a malicious invalid input crashes a tensorflow model (Check Failed) and can be used to trigger a denial of service attack. A proof of concept can be constructed with the `Convolution3DTranspose` function. This Convolution3DTranspose layer is a very common API in modern neural networks. The ML models containing such vulnerable components could be deployed in ML applications or as cloud services. This failure could be potentially used to trigger a denial of service attack on ML cloud services. An attacker must have privilege to provide input to a `Convolution3DTranspose` call. This issue has been patched and users are advised to upgrade to version 2.11.1. There are no known workarounds for this vulnerability.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
CVSS v3 base score: 6.5
Published: 2023-03-27T20:15Z
Repository: https://github.com/tensorflow/tensorflow
Language: Python
Files changed: tensorflow/core/kernels/conv_grad_ops_3d.cc, tensorflow/python/kernel_tests/nn_ops/conv3d_transpose_test.py
Commit date: 2022-11-08 11:21:27 -0800
Commit message: Fix nn.conv3d_transpose security vulnerability with illegal input shape

PiperOrigin-RevId: 487000656

Diff: diff --git a/tensorflow/core/kernels/conv_grad_ops_3d.cc b/tensorflow/core/kernels/conv_grad_ops_3d.cc
index 562ef538a22f8..89773d1f662ac 100644
--- a/tensorflow/core/kernels/conv_grad_ops_3d.cc
+++ b/tensorflow/core/kernels/conv_grad_ops_3d.cc
@@ -1320,10 +1320,15 @@ class Conv3DBackpropInputOp<GPUDevice, T> : public OpKernel {
                                 /*explicit_paddings=*/{}, data_format_, &dims));
 
     Tensor* in_backprop;
     OP_REQUIRES_OK(context,
                    context->allocate_output(0, input_shape, &in_backprop));
+    for (std::size_t i = 0; i < input_shape.dims(); ++i) {
+      if (input_shape.dim_size(i) == 0) {
+        return;
+      }
+    }
 
     auto* stream = context->op_device_context()->stream();
     OP_REQUIRES(context, stream, errors::Internal("No GPU stream available."));
 
     bool is_grouped_convolution = filter_shape.dim_size(3) != dims.in_depth;
diff --git a/tensorflow/python/kernel_tests/nn_ops/conv3d_transpose_test.py b/tensorflow/python/kernel_tests/nn_ops/conv3d_transpose_test.py
index 1e683808296af..6d185bb76463e 100644
--- a/tensorflow/python/kernel_tests/nn_ops/conv3d_transpose_test.py
+++ b/tensorflow/python/kernel_tests/nn_ops/conv3d_transpose_test.py
@@ -124,11 +124,11 @@ class Conv3DTransposeTest(test.TestCase):
     strides = [1, 1, 2, 2, 2]
     np.random.seed(1)
     x_value = np.random.random_sample(x_shape).astype(np.float64)
     f_value = np.random.random_sample(f_shape).astype(np.float64)
     nn_ops.conv3d_transpose(
-        x_value, f_value, y_shape, strides, data_format='NCDHW')
+        x_value, f_value, y_shape, strides, data_format="NCDHW")
 
   def testConv3DTransposeOutputShapeType(self):
     # Test case for GitHub issue 18887
     for dtype in [dtypes.int32, dtypes.int64]:
       with self.cached_session():
@@ -216,8 +216,22 @@ class Conv3DTransposeTest(test.TestCase):
                                                     output, y_shape)
     print("conv3d_transpose gradient err = %g " % err)
     err_tolerance = 0.00055
     self.assertLess(err, err_tolerance)
 
+  def testConv3DTransposeZeroShapeDoNotRaiseError(self):
+    with self.cached_session():
+      x_value = np.zeros([10, 0, 2, 3, 3])
+      f_value = np.ones((3, 3, 3, 3, 3))
+      y_shape = np.stack([10, 0, 2, 3, 3])
+      output = nn_ops.conv3d_transpose(
+          x_value,
+          f_value,
+          y_shape,
+          strides=(1, 1, 1),
+          data_format="NDHWC",
+          padding="SAME",
+      )
+      _ = self.evaluate(output)
 
 if __name__ == "__main__":
   test.main()

Vulnerable code:         x_value, f_value, y_shape, strides, data_format='NCDHW')
Fixed code:     for (std::size_t i = 0; i < input_shape.dims(); ++i) {
      if (input_shape.dim_size(i) == 0) {
        return;
      }
    }
        x_value, f_value, y_shape, strides, data_format="NCDHW")
  def testConv3DTransposeZeroShapeDoNotRaiseError(self):
    with self.cached_session():
      x_value = np.zeros([10, 0, 2, 3, 3])
      f_value = np.ones((3, 3, 3, 3, 3))
      y_shape = np.stack([10, 0, 2, 3, 3])
      output = nn_ops.conv3d_transpose(
          x_value,
          f_value,
          y_shape,
          strides=(1, 1, 1),
          data_format="NDHWC",
          padding="SAME",
      )
      _ = self.evaluate(output)