• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## TFSA-2021-132: Reference binding to nullptr in `MatrixSetDiagV*` ops
2
3### CVE Number
4CVE-2021-37658
5
6### Impact
7An attacker can cause undefined behavior via binding a reference to null pointer
8in all operations of type `tf.raw_ops.MatrixSetDiagV*`:
9
10```python
11import tensorflow as tf
12
13tf.raw_ops.MatrixSetDiagV3(
14  input=[1,2,3],
15  diagonal=[1,1],
16  k=[],
17  align='RIGHT_LEFT')
18```
19
20The
21[implementation](https://github.com/tensorflow/tensorflow/blob/84d053187cb80d975ef2b9684d4b61981bca0c41/tensorflow/core/kernels/linalg/matrix_diag_op.cc)
22has incomplete validation that the value of `k` is a valid tensor. We have check
23that this value is either a scalar or a vector, but there is no check for the
24number of elements. If this is an empty tensor, then code that accesses the
25first element of the tensor is wrong:
26
27```cc
28  auto& diag_index = context->input(1);
29  ...
30  lower_diag_index = diag_index.flat<int32>()(0);
31```
32
33### Patches
34We have patched the issue in GitHub commit
35[ff8894044dfae5568ecbf2ed514c1a37dc394f1b](https://github.com/tensorflow/tensorflow/commit/ff8894044dfae5568ecbf2ed514c1a37dc394f1b).
36
37The fix will be included in TensorFlow 2.6.0. We will also cherrypick this
38commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are
39also affected and still in supported range.
40
41### For more information
42Please consult [our security
43guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for
44more information regarding the security model and how to contact us with issues
45and questions.
46
47### Attribution
48This vulnerability has been reported by members of the Aivul Team from Qihoo
49360.
50