Source
ghsa
### Impact The implementation of [`tf.raw_ops.SparseTensorDenseAdd`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/sparse_tensor_dense_add_op.cc) does not fully validate the input arguments: ```python import tensorflow as tf a_indices = tf.constant(0, shape=[17, 2], dtype=tf.int64) a_values = tf.constant([], shape=[0], dtype=tf.float32) a_shape = tf.constant([6, 12], shape=[2], dtype=tf.int64) b = tf.constant(-0.223668531, shape=[6, 12], dtype=tf.float32) tf.raw_ops.SparseTensorDenseAdd( a_indices=a_indices, a_values=a_values, a_shape=a_shape, b=b) ``` In this case, a reference gets bound to a `nullptr` during kernel execution. This is UB. ### Patches We have patched the issue in GitHub commit [11ced8467eccad9c7cb94867708be8fa5c66c730](https://github.com/tensorflow/tensorflow/commit/11ced8467eccad9c7cb94867708be8fa5c66c730). The fix will be included in TensorFlow 2.9.0. We will also cherrypick this commit on Te...
### Impact There is a potential for segfault / denial of service in TensorFlow by calling `tf.compat.v1.*` ops which don't yet have support for quantized types (added after migration to TF 2.x): ```python import numpy as np import tensorflow as tf tf.compat.v1.placeholder_with_default(input=np.array([2]),shape=tf.constant(dtype=tf.qint8, value=np.array([1]))) ``` In these scenarios, since the kernel is missing, a [`nullptr` value is passed](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/python/eager/pywrap_tfe_src.cc#L480-L482) to [`ParseDimensionValue`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/python/eager/pywrap_tfe_src.cc#L296-L320) for the `py_value` argument. Then, this is dereferenced, resulting in segfault. ### Patches We have patched the issue in GitHub commit [237822b59fc504dda2c564787f5d3ad9c4aa62d9](https://github.com/tensorflow/tensorflow/commit/237822b59fc504dda2...
### Impact The implementation of [`tf.raw_ops.UnsortedSegmentJoin`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/unsorted_segment_join_op.cc#L83-L148) does not fully validate the input arguments. This results in a `CHECK`-failure which can be used to trigger a denial of service attack: ```python import tensorflow as tf tf.strings.unsorted_segment_join( inputs=['123'], segment_ids=[0], num_segments=-1) ``` The code assumes `num_segments` is a positive scalar but there is no validation: ```cc const Tensor& num_segments_tensor = context->input(2); auto num_segments = num_segments_tensor.scalar<NUM_SEGMENTS_TYPE>()(); // ... Tensor* output_tensor = nullptr; TensorShape output_shape = GetOutputShape(input_shape, segment_id_shape, num_segments); ``` Since this value is used to allocate the output tensor, a negative value would result in a `CHECK`-failure (assertion failure), as per [TFSA-2021-198](https://github...
### Impact The implementation of `tf.raw_ops.SpaceToBatchND` (in all backends such as XLA and handwritten kernels) is vulnerable to an integer overflow: ```python import tensorflow as tf input = tf.constant(-3.5e+35, shape=[10,19,22], dtype=tf.float32) block_shape = tf.constant(-1879048192, shape=[2], dtype=tf.int64) paddings = tf.constant(0, shape=[2,2], dtype=tf.int32) tf.raw_ops.SpaceToBatchND(input=input, block_shape=block_shape, paddings=paddings) ``` The result of this integer overflow is used to allocate the output tensor, hence we get a denial of service via a `CHECK`-failure (assertion failure), as in [TFSA-2021-198](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/security/advisory/tfsa-2021-198.md). ### Patches We have patched the issue in GitHub commit [acd56b8bcb72b163c834ae4f18469047b001fadf](https://github.com/tensorflow/tensorflow/commit/acd56b8bcb72b163c834ae4f18469047b001fadf). The fix will be included in TensorFlow 2.9.0. We will also cherrypick...
### Impact The implementation of [`tf.ragged.constant`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/python/ops/ragged/ragged_factory_ops.py#L146-L239) does not fully validate the input arguments. This results in a denial of service by consuming all available memory: ```python import tensorflow as tf tf.ragged.constant(pylist=[],ragged_rank=8968073515812833920) ``` ### Patches We have patched the issue in GitHub commit [bd4d5583ff9c8df26d47a23e508208844297310e](https://github.com/tensorflow/tensorflow/commit/bd4d5583ff9c8df26d47a23e508208844297310e). The fix will be included in TensorFlow 2.9.0. We will also cherrypick this commit on TensorFlow 2.8.1, TensorFlow 2.7.2, and TensorFlow 2.6.4, as these are also affected and still in supported range. ### For more information Please consult [our security guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how...
### Impact The implementation of [`tf.raw_ops.QuantizedConv2D`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/quantized_conv_ops.cc) does not fully validate the input arguments: ```python import tensorflow as tf input = tf.constant(1, shape=[1, 2, 3, 3], dtype=tf.quint8) filter = tf.constant(1, shape=[1, 2, 3, 3], dtype=tf.quint8) # bad args min_input = tf.constant([], shape=[0], dtype=tf.float32) max_input = tf.constant(0, shape=[], dtype=tf.float32) min_filter = tf.constant(0, shape=[], dtype=tf.float32) max_filter = tf.constant(0, shape=[], dtype=tf.float32) tf.raw_ops.QuantizedConv2D( input=input, filter=filter, min_input=min_input, max_input=max_input, min_filter=min_filter, max_filter=max_filter, strides=[1, 1, 1, 1], padding="SAME") ``` In this case, references get bound to `nullptr` for each argument that is empty (in the example, all arguments in the `bad args` section). ### Patches We have...
### Impact The implementation of [`tf.raw_ops.LSTMBlockCell`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/rnn/lstm_ops.cc) does not fully validate the input arguments. This results in a `CHECK`-failure which can be used to trigger a denial of service attack: ```python import tensorflow as tf tf.raw_ops.LSTMBlockCell( x=tf.constant(0.837607, shape=[28,29], dtype=tf.float32), cs_prev=tf.constant(0, shape=[28,17], dtype=tf.float32), h_prev=tf.constant(0.592631638, shape=[28,17], dtype=tf.float32), w=tf.constant(0.887386262, shape=[46,68], dtype=tf.float32), wci=tf.constant(0, shape=[], dtype=tf.float32), wcf=tf.constant(0, shape=[17], dtype=tf.float32), wco=tf.constant(0.592631638, shape=[28,17], dtype=tf.float32), b=tf.constant(0.75259006, shape=[68], dtype=tf.float32), forget_bias=1, cell_clip=0, use_peephole=False) ``` The code does not validate the ranks of any of the arguments to this API call...
### Impact The implementation of [`tf.raw_ops.LoadAndRemapMatrix`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/load_and_remap_matrix_op.cc#L70-L98) does not fully validate the input arguments. This results in a `CHECK`-failure which can be used to trigger a denial of service attack: ```python import tensorflow as tf ckpt_path = tf.constant( "/tmp/warm_starting_util_test5kl2a3pc/tmpph76tep2/model-0", shape=[], dtype=tf.string) old_tensor_name = tf.constant( "/tmp/warm_starting_util_test5kl2a3pc/tmpph76tep2/model-0", shape=[], dtype=tf.string) row_remapping = tf.constant(0, shape=[], dtype=tf.int64) col_remapping = tf.constant(3, shape=[3], dtype=tf.int64) initializing_values = tf.constant([], shape=[0, 1], dtype=tf.float32) tf.raw_ops.LoadAndRemapMatrix( ckpt_path=ckpt_path, old_tensor_name=old_tensor_name, row_remapping=row_remapping, col_remapping=col_remapping, initializing_values=initializing_va...
### Impact The implementation of [`tf.raw_ops.SparseTensorToCSRSparseMatrix`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/sparse/sparse_tensor_to_csr_sparse_matrix_op.cc#L65-L119) does not fully validate the input arguments. This results in a `CHECK`-failure which can be used to trigger a denial of service attack: ```python import tensorflow as tf indices = tf.constant(53, shape=[3], dtype=tf.int64) values = tf.constant(0.554979503, shape=[218650], dtype=tf.float32) dense_shape = tf.constant(53, shape=[3], dtype=tf.int64) tf.raw_ops.SparseTensorToCSRSparseMatrix( indices=indices, values=values, dense_shape=dense_shape) ``` The code assumes `dense_shape` is a vector and `indices` is a matrix (as part of requirements for sparse tensors) but there is no validation for this: ```cc const Tensor& indices = ctx->input(0); const Tensor& values = ctx->input(1); const Tensor& dense_shape = ctx->input(...
### Impact The implementation of [`tf.raw_ops.UnsortedSegmentJoin`](https://github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/unsorted_segment_join_op.cc#L92-L95) does not fully validate the input arguments. This results in a `CHECK`-failure which can be used to trigger a denial of service attack: ```python import tensorflow as tf tf.raw_ops.UnsortedSegmentJoin( inputs=tf.constant("this", shape=[12], dtype=tf.string), segment_ids=tf.constant(0, shape=[12], dtype=tf.int64), num_segments=tf.constant(0, shape=[12], dtype=tf.int64)) ``` The code assumes `num_segments` is a scalar but there is no validation for this before accessing its value: ```cc const Tensor& num_segments_tensor = context->input(2); OP_REQUIRES(context, num_segments_tensor.NumElements() != 0, errors::InvalidArgument("Number of segments cannot be empty.")); auto num_segments = num_segments_tensor.scalar<NUM_SEGMENTS_TYPE>()(); ``` ### Patches...