CVE-2022-35992 (published 2022-09-16T23:15Z)

TensorFlow is an open source platform for machine learning. When `TensorListFromTensor` receives an `element_shape` of a rank greater than one, it gives a `CHECK` fail that can trigger a denial of service attack. We have patched the issue in GitHub commit 3db59a042a38f4338aa207922fa2f476e000a6ee. 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.

CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)

Weakness information:
cwe_id: CWE-617
cwe_name: Reachable Assertion
description: The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.
extended_description: 
            While assertion is good for catching logic errors and reducing the chances of reaching more serious vulnerability conditions, it can still lead to a denial of service.
            For example, if a server handles multiple simultaneous connections, and an assert() occurs in one single connection that causes all other connections to be dropped, this is a reachable assertion that leads to a denial of service.
         
         

Fix information:
repo_url: https://github.com/tensorflow/tensorflow
commit_details: repo_url: https://github.com/tensorflow/tensorflow
author: A. Unique TensorFlower
author_date: 2022-07-21 14:14:59-07:00
msg: Check for element_shape in TensorListFromTensor

PiperOrigin-RevId: 462468167
repository: repo_url: https://github.com/tensorflow/tensorflow
repo_name: tensorflow/tensorflow
description: An Open Source Machine Learning Framework for Everyone
repo_language: C++
owner: tensorflow
file_changes: filename: list_kernels.h
change_type: ModificationType.MODIFY
diff: @@ -769,6 +769,11 @@ class TensorListFromTensor : public OpKernel {
     attr.set_on_host(true);
     OP_REQUIRES_OK(c, c->allocate_output(0, {}, &output_tensor, attr));
     PartialTensorShape element_shape;
+    OP_REQUIRES(
+        c, !TensorShapeUtils::IsMatrixOrHigher(c->input(1).shape()),
+        errors::InvalidArgument(
+            "TensorListFromTensor: element_shape must be at most rank 1 but ",
+            "has the shape of ", c->input(1).shape().DebugString()));
     OP_REQUIRES_OK(c, TensorShapeFromTensor(c->input(1), &element_shape));
     TensorList output_list;
     const Tensor& t = c->input(0);

programming_language: C++
filename: list_ops_test.py
change_type: ModificationType.MODIFY
diff: @@ -584,6 +584,17 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase):
     self.assertAllEqual(e, 1.0)
     self.assertAllEqual(list_ops.tensor_list_length(l), 0)
 
+  def testTensorListFromTensorFailsWhenElementShapeIsNotVector(self):
+    t = constant_op.constant([1.0, 2.0])
+    # In Eager mode, InvalidArgumentError is generated by the Compute function.
+    # In graph mode, ValueError is generated by the shape function.
+    with self.assertRaisesRegex(
+        (errors.InvalidArgumentError, ValueError),
+        "must be at most rank 1"):
+      # Wrong element_shape. Should be at most rank 1.
+      l = list_ops.tensor_list_from_tensor(t, element_shape=[[1]])
+      self.evaluate(l)
+
   @test_util.run_gpu_only
   def testFromTensorGPU(self):
     with context.device("gpu:0"):

programming_language: Python