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

TensorFlow is an open source platform for machine learning. If `LRNGrad` is given an `output_image` input tensor that is not 4-D, it results in a `CHECK` fail that can be used to trigger a denial of service attack. We have patched the issue in GitHub commit bd90b3efab4ec958b228cd7cfe9125be1c0cf255. 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: Sagun Bajra
author_date: 2022-07-13 09:46:48-07:00
msg: Fix security vulnerability with LRNGradOp

PiperOrigin-RevId: 460738938
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: lrn_op.cc
change_type: ModificationType.MODIFY
diff: @@ -668,7 +668,8 @@ class LRNGradOp : public OpKernel {
         in_image.dim_size(0) == batch && in_image.dim_size(1) == rows &&
             in_image.dim_size(2) == cols && in_image.dim_size(3) == depth &&
             out_image.dim_size(0) == batch && out_image.dim_size(1) == rows &&
-            out_image.dim_size(2) == cols && out_image.dim_size(3) == depth,
+            out_image.dim_size(2) == cols && out_image.dim_size(3) == depth &&
+            out_image.dims() == 4,
         errors::InvalidArgument(
             "input_grads, input_image, and out_image should have the same "
             "shape"));

programming_language: C++
filename: lrn_op_test.py
change_type: ModificationType.MODIFY
diff: @@ -20,11 +20,13 @@ import numpy as np
 
 from tensorflow.python.framework import constant_op
 from tensorflow.python.framework import dtypes
+from tensorflow.python.framework import errors_impl
 from tensorflow.python.framework import test_util
 from tensorflow.python.ops import array_ops
 from tensorflow.python.ops import gradient_checker
 from tensorflow.python.ops import gradients_impl
 from tensorflow.python.ops import nn
+from tensorflow.python.ops import random_ops
 import tensorflow.python.ops.nn_grad  # pylint: disable=unused-import
 from tensorflow.python.platform import test
 
@@ -111,6 +113,41 @@ class LRNOpTest(test.TestCase):
     self.assertAllClose(r, expected)
     self.assertShapeEqual(expected, grad)
 
+  @test_util.run_in_graph_and_eager_modes
+  def testIncompatibleInputAndOutputImageShapes(self):
+    depth_radius = 1
+    bias = 1.59018219
+    alpha = 0.117728651
+    beta = 0.404427052
+    input_grads = random_ops.random_uniform(
+        shape=[4, 4, 4, 4],
+        minval=-10000,
+        maxval=10000,
+        dtype=dtypes.float32,
+        seed=-2033)
+    input_image = random_ops.random_uniform(
+        shape=[4, 4, 4, 4],
+        minval=-10000,
+        maxval=10000,
+        dtype=dtypes.float32,
+        seed=-2033)
+    invalid_output_image = random_ops.random_uniform(
+        shape=[4, 4, 4, 4, 4, 4],
+        minval=-10000,
+        maxval=10000,
+        dtype=dtypes.float32,
+        seed=-2033)
+    with self.assertRaises((ValueError, errors_impl.InvalidArgumentError)):
+      self.evaluate(
+          nn.lrn_grad(
+              input_grads=input_grads,
+              input_image=input_image,
+              output_image=invalid_output_image,
+              depth_radius=depth_radius,
+              bias=bias,
+              alpha=alpha,
+              beta=beta))
+
   def _RunAndVerifyGradients(self, dtype):
     with self.cached_session():
       # random shape

programming_language: Python