CVE-2021-29530: Invalid validation in `SparseMatrixSparseCholesky`

Published May 14, 2021
·
Updated

Impact An attacker can trigger a null pointer dereference by providing an invalid permutation to tf.rawops.SparseMatrixSparseCholesky:

python import tensorflow as tf import numpy as np from tensorflow.python.ops.linalg.sparse import sparsecsrmatrixops

indicesarray = np.array([[0, 0]]) valuearray = np.array([-10.0], dtype=np.float32) denseshape = [1, 1] st = tf.SparseTensor(indicesarray, valuearray, denseshape)

input = sparsecsrmatrixops.sparsetensortocsrsparsematrix( st.indices, st.values, st.denseshape)

permutation = tf.constant([], shape=[1, 0], dtype=tf.int32) tf.rawops.SparseMatrixSparseCholesky(input=input, permutation=permutation, type=tf.float32)

This is because the implementation fails to properly validate the input arguments: cc void Compute(OpKernelContext ctx) final { ... const Tensor& inputpermutationindices = ctx->input(1); ... ValidateInputs(ctx, inputmatrix, inputpermutationindices, &batchsize, &numrows); ... }

void ValidateInputs(OpKernelContext ctx, const CSRSparseMatrix& sparsematrix, const Tensor& permutationindices, int batchsize, int64 numrows) { OPREQUIRES(ctx, sparsematrix.dtype() == DataTypeToEnum<T>::value, ...) ... } Although ValidateInputs is called and there are checks in the body of this function, the code proceeds to the next line in ValidateInputs since OPREQUIRES is a macro that only exits the current function.

cc #define OPREQUIRES(CTX, EXP, STATUS) \ do { \ if (!TFPREDICTTRUE(EXP)) { \ CheckNotInComputeAsync((CTX), "OPREQUIRESASYNC"); \ (CTX)->CtxFailure(FILE, LINE, (STATUS)); \ return; \ } \ } while (0)

Thus, the first validation condition that fails in ValidateInputs will cause an early return from that function. However, the caller will continue execution from the next line. The fix is to either explicitly check context->status() or to convert ValidateInputs to return a Status.

Patches We have patched the issue in GitHub commit e6a7c7cc18c3aaad1ae0872cb0a959f5c923d2bd.

The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit 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 Ying Wang and Yakun Zhang of Baidu X-Team.

Other sources

TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a null pointer dereference by providing an invalid permutation to tf.rawops.SparseMatrixSparseCholesky. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/080f1d9e257589f78b3ffb75debf584168aa6062/tensorflow/core/kernels/sparse/sparsecholeskyop.cc#L85-L86) fails to properly validate the input arguments. Although ValidateInputs is called and there are checks in the body of this function, the code proceeds to the next line in ValidateInputs since OPREQUIRES(https://github.com/tensorflow/tensorflow/blob/080f1d9e257589f78b3ffb75debf584168aa6062/tensorflow/core/framework/oprequires.h#L41-L48) is a macro that only exits the current function. Thus, the first validation condition that fails in ValidateInputs will cause an early return from that function. However, the caller will continue execution from the next line. The fix is to either explicitly check context->status() or to convert ValidateInputs to return a Status. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit 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

16 affected componentsFixes available
pip/tensorflow-gpu>=2.4.0<2.4.2
2.4.2
pip/tensorflow-gpu>=2.3.0<2.3.3
2.3.3
pip/tensorflow-gpu>=2.2.0<2.2.3
2.2.3
pip/tensorflow-gpu<2.1.4
2.1.4
pip/tensorflow-cpu>=2.4.0<2.4.2
2.4.2
pip/tensorflow-cpu>=2.3.0<2.3.3
2.3.3
pip/tensorflow-cpu>=2.2.0<2.2.3
2.2.3
pip/tensorflow-cpu<2.1.4
2.1.4
pip/tensorflow>=2.4.0<2.4.2
2.4.2
pip/tensorflow>=2.3.0<2.3.3
2.3.3
pip/tensorflow>=2.2.0<2.2.3
2.2.3
pip/tensorflow<2.1.4
2.1.4
Google TensorFlow<2.1.4
Google TensorFlow>=2.2.0<2.2.3
Google TensorFlow>=2.3.0<2.3.3
Google TensorFlow>=2.4.0<2.4.2

Event History

May 14, 2021
CVE Published
via MITRE·07:12 PM
Data Sourced
via MITRE·07:12 PM
DescriptionSeverityWeakness
May 21, 2021
Advisory Published
via GitHub·02:22 PM

Frequently Asked Questions

1

What is the severity of CVE-2021-29530?

The severity of CVE-2021-29530 is not explicitly rated but it can lead to a denial of service due to a null pointer dereference.

2

How do I fix CVE-2021-29530?

To fix CVE-2021-29530, update TensorFlow to version 2.4.2 or later.

3

What software is affected by CVE-2021-29530?

CVE-2021-29530 affects various TensorFlow versions prior to 2.4.2, including versions 2.1.4 to 2.3.3.

4

What is the impact of CVE-2021-29530?

The impact of CVE-2021-29530 allows attackers to trigger a null pointer dereference leading to potential application crashes.

5

How can I identify if my TensorFlow installation is vulnerable to CVE-2021-29530?

You can identify vulnerability by checking if your TensorFlow version is less than 2.4.2.

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