Headline
CVE-2022-35969: Add security vulnerability test for raw_ops.Conv2DBackpropInput · tensorflow/tensorflow@50156d5
TensorFlow is an open source platform for machine learning. The implementation of Conv2DBackpropInput
requires input_sizes
to be 4-dimensional. Otherwise, it gives a CHECK
failure which can be used to trigger a denial of service attack. We have patched the issue in GitHub commit 50156d547b9a1da0144d7babe665cf690305b33c. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.
@@ -32,6 +32,7 @@ from tensorflow.python.layers import convolutional from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops @@ -1319,7 +1320,7 @@ def _RunAndVerifyBackpropInputDilation(self, input_sizes, filter_sizes, x2 = self._CreateNumpyTensor(filter_sizes) default_dilations = (dilations[0] == 1 and dilations[1] == 1) if default_dilations or use_gpu: with self.cached_session(use_gpu=use_gpu) as sess: with self.cached_session(use_gpu=use_gpu): if data_format == "NCHW": input_sizes = test_util.NHWCToNCHW(input_sizes) t1 = constant_op.constant(x1, shape=input_sizes) @@ -1365,7 +1366,7 @@ def _RunAndVerifyBackpropFilterDilation(self, input_sizes, filter_sizes, x2 = self._CreateNumpyTensor(filter_sizes) default_dilations = (dilations[0] == 1 and dilations[1] == 1) if default_dilations or use_gpu: with self.cached_session(use_gpu=use_gpu) as sess: with self.cached_session(use_gpu=use_gpu): if data_format == "NCHW": input_sizes = test_util.NHWCToNCHW(input_sizes) t1 = constant_op.constant(x1, shape=input_sizes) @@ -2628,6 +2629,27 @@ def testOpEdgeCases(self): strides=[1, 1, 1, 1], padding=[[0, 0], [-1, 0], [0, 0], [0, 0]]))
def testConv2DBackpropInputInvalidOutBackpropRaiseError(self): with self.assertRaises((ValueError, errors_impl.InvalidArgumentError)): with self.cached_session(): input_sizes = constant_op.constant([65534, 65534], shape=[2], dtype=dtypes.int32) filters = constant_op.constant( 0.159749106, shape=[3, 3, 2, 2], dtype=dtypes.float32) out_backprop = constant_op.constant(0, shape=[], dtype=dtypes.float32) t = gen_nn_ops.conv2d_backprop_input( input_sizes=input_sizes, filter=filters, out_backprop=out_backprop, strides=[1, 1, 1, 1], padding="SAME", use_cudnn_on_gpu=True, explicit_paddings=[], data_format="NHWC", dilations=[1, 1, 1, 1]) self.evaluate(t)
@test_util.run_all_without_tensor_float_32(“Avoid TF32 conv on GPU”) class DepthwiseConv2DTest(test.TestCase): @@ -2655,7 +2677,7 @@ def _VerifyValues(self, tensor_in_sizes, filter_in_sizes, stride, padding, # numbers from 1. x1 = [f * 1.0 for f in range(1, total_size_1 + 1)] x2 = [f * 1.0 for f in range(1, total_size_2 + 1)] with self.cached_session() as sess: with self.cached_session(): t1 = constant_op.constant(x1, shape=tensor_in_sizes) t1.set_shape(tensor_in_sizes) t2 = constant_op.constant(x2, shape=filter_in_sizes) @@ -2926,7 +2948,7 @@ def _CompareFwdConv2D(self, tensor_in_sizes, filter_in_sizes, conv_strides, x1 = np.random.rand(*tensor_in_sizes).astype(np.float32) x2 = np.random.rand(*filter_in_sizes).astype(np.float32)
with self.cached_session(use_gpu=False) as sess: with self.cached_session(use_gpu=False): t1 = constant_op.constant(x1, shape=tensor_in_sizes) t2 = constant_op.constant(x2, shape=filter_in_sizes) strides = [1] + conv_strides + [1]
Related news
### Impact The implementation of `Conv2DBackpropInput` requires `input_sizes` to be 4-dimensional. Otherwise, it gives a `CHECK` failure which can be used to trigger a denial of service attack: ```python import tensorflow as tf strides = [1, 1, 1, 1] padding = "SAME" use_cudnn_on_gpu = True explicit_paddings = [] data_format = "NHWC" dilations = [1, 1, 1, 1] input_sizes = tf.constant([65534,65534], shape=[2], dtype=tf.int32) filter = tf.constant(0.159749106, shape=[3,3,2,2], dtype=tf.float32) out_backprop = tf.constant(0, shape=[], dtype=tf.float32) tf.raw_ops.Conv2DBackpropInput(input_sizes=input_sizes, filter=filter, out_backprop=out_backprop, strides=strides, padding=padding, use_cudnn_on_gpu=use_cudnn_on_gpu, explicit_paddings=explicit_paddings, data_format=data_format, dilations=dilations) ``` ### Patches We have patched the issue in GitHub commit [50156d547b9a1da0144d7babe665cf690305b33c](https://github.com/tensorflow/tensorflow/commit/50156d547b9a1da0144d7babe665cf690305b33c)....