CVE-2021-37647: Null pointer dereference in `SparseTensorSliceDataset` in TensorFlow
Impact When a user does not supply arguments that determine a valid sparse tensor, tf.rawops.SparseTensorSliceDataset implementation can be made to dereference a null pointer:
python import tensorflow as tf
tf.rawops.SparseTensorSliceDataset( indices=[[],[],[]], values=[1,2,3], denseshape=[3,3]) The implementation has some argument validation but fails to consider the case when either indices or values are provided for an empty sparse tensor when the other is not.
If indices is empty (as in the example above), then code that performs validation (i.e., checking that the indices are monotonically increasing) results in a null pointer dereference:
cc for (int64t i = 0; i < indices->dimsize(0); ++i) { int64t nextbatchindex = indices->matrix<int64>()(i, 0); ... }
If indices as provided by the user is empty, then indices in the C++ code above is backed by an empty std::vector, hence calling indices->dimsize(0) results in null pointer dereferencing (same as calling std::vector::at() on an empty vector).
Patches We have patched the issue in GitHub commit 02cc160e29d20631de3859c6653184e3f876b9d7.
The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.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 members of the Aivul Team from Qihoo 360.
Other sources
TensorFlow is an end-to-end open source platform for machine learning. When a user does not supply arguments that determine a valid sparse tensor, tf.rawops.SparseTensorSliceDataset implementation can be made to dereference a null pointer. The implementation has some argument validation but fails to consider the case when either indices or values are provided for an empty sparse tensor when the other is not. If indices is empty, then code that performs validation (i.e., checking that the indices are monotonically increasing) results in a null pointer dereference. If indices as provided by the user is empty, then indices in the C++ code above is backed by an empty std::vector, hence calling indices->dimsize(0) results in null pointer dereferencing (same as calling std::vector::at() on an empty vector). We have patched the issue in GitHub commit 02cc160e29d20631de3859c6653184e3f876b9d7. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.6.0Patch 02cc160e29d20631de3859c6653184e3f876b9d7 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.5.1Patch 02cc160e29d20631de3859c6653184e3f876b9d7 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.4.3Patch 02cc160e29d20631de3859c6653184e3f876b9d7 - Upgrade
Upgrade
tensorflowto a version that resolves this vulnerability.Fixed in 2.3.4Patch 02cc160e29d20631de3859c6653184e3f876b9d7
Event History
Frequently Asked Questions
What is the severity of CVE-2021-37647?
CVE-2021-37647 is classified as a high severity vulnerability due to its potential to cause a null pointer dereference.
How do I fix CVE-2021-37647?
To fix CVE-2021-37647, update TensorFlow to versions 2.3.4, 2.4.3, or 2.5.1 or later.
Which TensorFlow versions are affected by CVE-2021-37647?
CVE-2021-37647 affects TensorFlow versions from 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and 2.5.0.
What component is vulnerable in CVE-2021-37647?
The vulnerability in CVE-2021-37647 resides in the tf.raw_ops.SparseTensorSliceDataset implementation.
Can CVE-2021-37647 be exploited in production environments?
Yes, CVE-2021-37647 can potentially be exploited in production environments if proper input validations are not enforced.