CVE-2022-35988 (published 2022-09-16T22:15Z)

TensorFlow is an open source platform for machine learning. When `tf.linalg.matrix_rank` receives an empty input `a`, the GPU kernel gives a `CHECK` fail that can be used to trigger a denial of service attack. We have patched the issue in GitHub commit c55b476aa0e0bd4ee99d0f3ad18d9d706cd1260a. 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: Antonio Sanchez
author_date: 2022-07-20 12:59:24-07:00
msg: Fix empty batch issue in svd.

If there are zero batches, the GPU kernel previously failed with a `work_element_count > 0`
check failure.  In the zero batch case, there is no output, so simply return.

PiperOrigin-RevId: 462210670
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: svd_op_gpu.cu.cc
change_type: ModificationType.MODIFY
diff: @@ -395,6 +395,12 @@ class SvdOpGpu : public AsyncOpKernel {
     OP_REQUIRES_OK_ASYNC(context, context->allocate_output(2, shapeV, &outputV),
                          done);
 
+    // If there are zero batches, we are done.
+    if (shapeRaw.num_elements() == 0) {
+      done();
+      return;
+    }
+
     if (n == 0 || m == 0) {
       if (n == m || !compute_uv_ || !full_matrices_) {
         // S, U, and V are all empty. Nothing to do.

programming_language: C++
filename: svd_op_test.py
change_type: ModificationType.MODIFY
diff: @@ -108,6 +108,14 @@ class SvdOpTest(test.TestCase):
     for i in range(0, len(val), 2):
       self.assertAllEqual(val[i], val[i + 1])
 
+  @test_util.run_in_graph_and_eager_modes(use_gpu=True)
+  def testEmptyBatches(self):
+    matrices = constant_op.constant(1.0, shape=[0, 2, 2])
+    s, u, v = self.evaluate(linalg_ops.svd(matrices))
+    self.assertAllEqual(s, np.zeros([0, 2]))
+    self.assertAllEqual(u, np.zeros([0, 2, 2]))
+    self.assertAllEqual(v, np.zeros([0, 2, 2]))
+
 
 def _GetSvdOpTest(dtype_, shape_, use_static_shape_, compute_uv_,
                   full_matrices_):

programming_language: Python