CVE-2021-29612: Heap buffer overflow in `BandedTriangularSolve`
Impact An attacker can trigger a heap buffer overflow in Eigen implementation of tf.rawops.BandedTriangularSolve:
python import tensorflow as tf import numpy as np matrixarray = np.array([]) matrixtensor = tf.converttotensor(np.reshape(matrixarray,(0,1)),dtype=tf.float32) rhsarray = np.array([1,1]) rhstensor = tf.converttotensor(np.reshape(rhsarray,(1,2)),dtype=tf.float32) tf.rawops.BandedTriangularSolve(matrix=matrixtensor,rhs=rhstensor)
The implementation calls ValidateInputTensors for input validation but fails to validate that the two tensors are not empty: cc void ValidateInputTensors(OpKernelContext ctx, const Tensor& in0, const Tensor& in1) { OPREQUIRES( ctx, in0.dims() >= 2, errors::InvalidArgument("In[0] ndims must be >= 2: ", in0.dims()));
OPREQUIRES( ctx, in1.dims() >= 2, errors::InvalidArgument("In[1] ndims must be >= 2: ", in1.dims())); }
Furthermore, since OPREQUIRES macro only stops execution of current function after setting ctx->status() to a non-OK value, callers of helper functions that use OPREQUIRES must check value of ctx->status() before continuing. This doesn't happen in this op's implementation, hence the validation that is present is also not effective.
Patches We have patched the issue in GitHub commit ba6822bd7b7324ba201a28b2f278c29a98edbef2 followed by GitHub commit 0ab290774f91a23bebe30a358fde4e53ab4876a0.
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 Ye Zhang 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 heap buffer overflow in Eigen implementation of tf.rawops.BandedTriangularSolve. The implementation(https://github.com/tensorflow/tensorflow/blob/eccb7ec454e6617738554a255d77f08e60ee0808/tensorflow/core/kernels/linalg/bandedtriangularsolveop.cc#L269-L278) calls ValidateInputTensors for input validation but fails to validate that the two tensors are not empty. Furthermore, since OPREQUIRES macro only stops execution of current function after setting ctx->status() to a non-OK value, callers of helper functions that use OPREQUIRES must check value of ctx->status() before continuing. This doesn't happen in this op's implementation(https://github.com/tensorflow/tensorflow/blob/eccb7ec454e6617738554a255d77f08e60ee0808/tensorflow/core/kernels/linalg/bandedtriangularsolveop.cc#L219), hence the validation that is present is also not effective. 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
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2021-29612?
CVE-2021-29612 is classified as a high severity vulnerability due to its potential to allow an attacker to execute arbitrary code via a heap buffer overflow.
How do I fix CVE-2021-29612?
To fix CVE-2021-29612, upgrade TensorFlow to version 2.4.2 or later, or to version 2.3.3 or version 2.2.3 depending on your current version.
Which versions of TensorFlow are affected by CVE-2021-29612?
CVE-2021-29612 affects TensorFlow versions prior to 2.1.4 and between 2.2.0 and 2.2.3, 2.3.0 and 2.3.3, and 2.4.0 and 2.4.2.
What type of vulnerability is CVE-2021-29612?
CVE-2021-29612 is a heap buffer overflow vulnerability that can be triggered in the Eigen implementation of TensorFlow.
Can CVE-2021-29612 impact data security?
Yes, CVE-2021-29612 could expose systems to risks, including arbitrary code execution, compromising data integrity and security.