CVE-2021-37647: Null pointer dereference in `SparseTensorSliceDataset` in TensorFlow

Published Aug 12, 2021
·
Updated

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

15 affected componentsFixes available
pip/tensorflow-gpu=2.5.0
2.5.1
pip/tensorflow-gpu>=2.4.0<2.4.3
2.4.3
pip/tensorflow-gpu<2.3.4
2.3.4
pip/tensorflow-cpu=2.5.0
2.5.1
pip/tensorflow-cpu>=2.4.0<2.4.3
2.4.3
pip/tensorflow-cpu<2.3.4
2.3.4
pip/tensorflow=2.5.0
2.5.1
pip/tensorflow>=2.4.0<2.4.3
2.4.3
pip/tensorflow<2.3.4
2.3.4
Google TensorFlow>=2.3.0<2.3.4
Google TensorFlow>=2.4.0<2.4.3
Google TensorFlow=2.5.0
Google TensorFlow=2.6.0-rc0
Google TensorFlow=2.6.0-rc1
Google TensorFlow=2.6.0-rc2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/tensorflow-gpu to a version that resolves this vulnerability.

    Fixed in 2.5.1
  2. Upgrade

    Upgrade pip/tensorflow-gpu to a version that resolves this vulnerability.

    Fixed in 2.4.3
  3. Upgrade

    Upgrade pip/tensorflow-gpu to a version that resolves this vulnerability.

    Fixed in 2.3.4
  4. Upgrade

    Upgrade pip/tensorflow-cpu to a version that resolves this vulnerability.

    Fixed in 2.5.1
  5. Upgrade

    Upgrade pip/tensorflow-cpu to a version that resolves this vulnerability.

    Fixed in 2.4.3
  6. Upgrade

    Upgrade pip/tensorflow-cpu to a version that resolves this vulnerability.

    Fixed in 2.3.4
  7. Upgrade

    Upgrade pip/tensorflow to a version that resolves this vulnerability.

    Fixed in 2.5.1
  8. Upgrade

    Upgrade pip/tensorflow to a version that resolves this vulnerability.

    Fixed in 2.4.3
  9. Upgrade

    Upgrade pip/tensorflow to a version that resolves this vulnerability.

    Fixed in 2.3.4
  10. Upgrade

    Upgrade tensorflow to a version that resolves this vulnerability.

    Fixed in 2.6.0Patch 02cc160e29d20631de3859c6653184e3f876b9d7
  11. Upgrade

    Upgrade tensorflow to a version that resolves this vulnerability.

    Fixed in 2.5.1Patch 02cc160e29d20631de3859c6653184e3f876b9d7
  12. Upgrade

    Upgrade tensorflow to a version that resolves this vulnerability.

    Fixed in 2.4.3Patch 02cc160e29d20631de3859c6653184e3f876b9d7
  13. Upgrade

    Upgrade tensorflow to a version that resolves this vulnerability.

    Fixed in 2.3.4Patch 02cc160e29d20631de3859c6653184e3f876b9d7

Event History

Aug 12, 2021
CVE Published
via MITRE·06:10 PM
Data Sourced
via MITRE·06:10 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Aug 25, 2021
Advisory Published
via GitHub·02:43 PM

Frequently Asked Questions

1

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.

2

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.

3

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.

4

What component is vulnerable in CVE-2021-37647?

The vulnerability in CVE-2021-37647 resides in the tf.raw_ops.SparseTensorSliceDataset implementation.

5

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203