Headline
CVE-2022-21737: Fix check-fail when bincount ops are passed invalid values. · tensorflow/tensorflow@7019ce4
Tensorflow is an Open Source Machine Learning Framework. The implementation of *Bincount
operations allows malicious users to cause denial of service by passing in arguments which would trigger a CHECK
-fail. There are several conditions that the input arguments must satisfy. Some are not caught during shape inference and others are not caught during kernel implementation. This results in CHECK
failures later when the output tensors get allocated. The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.
@@ -344,6 +344,14 @@ def test_invalid_rank(self):
gen_math_ops.dense_bincount(
input=[[[1, 2, 3], [0, 3, 2]]], weights=[], size=10))
@test_util.run_in_graph_and_eager_modes
def test_size_is_not_scalar(self): # b/206619828
with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError),
“Shape must be rank 0 but is rank 1”):
self.evaluate(
gen_math_ops.dense_bincount(
input=[0], size=[1, 1], weights=[3], binary_output=False))
class SparseBincountOpTest(test_util.TensorFlowTestCase,
parameterized.TestCase):
@@ -511,6 +519,19 @@ def test_sparse_bincount_col_reduce_binary(self, dtype):
weights=[],
binary_output=True)))
@test_util.run_in_graph_and_eager_modes
def test_size_is_not_scalar(self): # b/206619828
with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError),
“Shape must be rank 0 but is rank 1”):
self.evaluate(
gen_math_ops.sparse_bincount(
indices=[[0], [1]],
values=[0, 0],
dense_shape=[1, 1],
size=[1, 1],
weights=[0, 0],
binary_output=False))
class RaggedBincountOpTest(test_util.TensorFlowTestCase,
parameterized.TestCase):
@@ -650,6 +671,19 @@ def test_ragged_bincount_binary_np_with_weights(self, dtype):
size=size,
binary_output=True)))
@test_util.run_in_graph_and_eager_modes
def test_size_is_not_scalar(self): # b/206619828
with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError),
“Shape must be rank 0 but is rank 1”):
self.evaluate(
gen_math_ops.ragged_bincount(
splits=[0, 0, 1],
values=[1],
size=[1, 1],
weights=[0, 0, 0],
binary_output=False,
name=None))
if __name__ == "__main__":
googletest.main()