CVE-2021-29608: Heap OOB and null pointer dereference in `RaggedTensorToTensor`
Impact Due to lack of validation in tf.rawops.RaggedTensorToTensor, an attacker can exploit an undefined behavior if input arguments are empty:
python import tensorflow as tf
shape = tf.constant([-1, -1], shape=[2], dtype=tf.int64) values = tf.constant([], shape=[0], dtype=tf.int64) defaultvalue = tf.constant(404, dtype=tf.int64) row = tf.constant([269, 404, 0, 0, 0, 0, 0], shape=[7], dtype=tf.int64) rows = [row] types = ['ROWSPLITS']
tf.rawops.RaggedTensorToTensor( shape=shape, values=values, defaultvalue=defaultvalue, rowpartitiontensors=rows, rowpartitiontypes=types)
The implementation only checks that one of the tensors is not empty, but does not check for the other ones.
There are multiple DCHECK validations to prevent heap OOB, but these are no-op in release builds, hence they don't prevent anything.
Patches We have patched the issue in GitHub commit b761c9b652af2107cfbc33efd19be0ce41daa33e followed by GitHub commit f94ef358bb3e91d517446454edff6535bcfe8e4a and GitHub commit c4d7afb6a5986b04505aca4466ae1951686c80f6.
The fix will be included in TensorFlow 2.5.0. We will also cherrypick these commits on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.
For more information Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.
Attribution This vulnerability has been reported by Yakun Zhang and Ying Wang of Baidu X-Team.
Other sources
TensorFlow is an end-to-end open source platform for machine learning. Due to lack of validation in tf.rawops.RaggedTensorToTensor, an attacker can exploit an undefined behavior if input arguments are empty. The implementation(https://github.com/tensorflow/tensorflow/blob/656e7673b14acd7835dc778867f84916c6d1cac2/tensorflow/core/kernels/raggedtensortotensorop.cc#L356-L360) only checks that one of the tensors is not empty, but does not check for the other ones. There are multiple DCHECK validations to prevent heap OOB, but these are no-op in release builds, hence they don't prevent anything. The fix will be included in TensorFlow 2.5.0. We will also cherrypick these commits on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2021-29608?
CVE-2021-29608 is considered a high-severity vulnerability due to the potential for exploitation leading to undefined behavior.
How do I fix CVE-2021-29608?
To fix CVE-2021-29608, upgrade to TensorFlow version 2.4.2 or later.
Which versions of TensorFlow are affected by CVE-2021-29608?
CVE-2021-29608 affects TensorFlow versions prior to 2.1.4, between 2.2.0 and 2.2.3, between 2.3.0 and 2.3.3, and between 2.4.0 and 2.4.2.
Is CVE-2021-29608 related to input validation?
Yes, CVE-2021-29608 is due to a lack of input validation in the tf.raw_ops.RaggedTensorToTensor function.
What types of attacks can exploit CVE-2021-29608?
Attackers could exploit CVE-2021-29608 by providing empty input arguments to the vulnerable function, leading to undefined behavior.