Описание
Type confusion during tensor casts lead to dereferencing null pointers
Impact
Calling TF operations with tensors of non-numeric types when the operations expect numeric tensors result in null pointer dereferences.
There are multiple ways to reproduce this, listing a few examples here:
All these examples and similar ones have the same behavior: the conversion from Python array to C++ array is vulnerable to a type confusion:
For the tensor types involved in the above example, the pyarray_type is NPY_VOID but the descr field is such that descr->field = NULL. Then PyArrayDescr_to_TF_DataType will trigger a null dereference:
This is because the Python's PyDict_Next implementation would dereference the first argument.
Patches
We have patched the issue in GitHub commit 030af767d357d1b4088c4a25c72cb3906abac489.
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 members of the Aivul Team from Qihoo 360 as well as Ye Zhang and Yakun Zhang of Baidu X-Team.
Ссылки
- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-452g-f7fp-9jf7
- https://nvd.nist.gov/vuln/detail/CVE-2021-29513
- https://github.com/tensorflow/tensorflow/commit/030af767d357d1b4088c4a25c72cb3906abac489
- https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-441.yaml
- https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-639.yaml
- https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-150.yaml
Пакеты
tensorflow
< 2.1.4
2.1.4
tensorflow
>= 2.2.0, < 2.2.3
2.2.3
tensorflow
>= 2.3.0, < 2.3.3
2.3.3
tensorflow
>= 2.4.0, < 2.4.2
2.4.2
tensorflow-cpu
< 2.1.4
2.1.4
tensorflow-cpu
>= 2.2.0, < 2.2.3
2.2.3
tensorflow-cpu
>= 2.3.0, < 2.3.3
2.3.3
tensorflow-cpu
>= 2.4.0, < 2.4.2
2.4.2
tensorflow-gpu
< 2.1.4
2.1.4
tensorflow-gpu
>= 2.2.0, < 2.2.3
2.2.3
tensorflow-gpu
>= 2.3.0, < 2.3.3
2.3.3
tensorflow-gpu
>= 2.4.0, < 2.4.2
2.4.2
Связанные уязвимости
TensorFlow is an end-to-end open source platform for machine learning. Calling TF operations with tensors of non-numeric types when the operations expect numeric tensors result in null pointer dereferences. The conversion from Python array to C++ array(https://github.com/tensorflow/tensorflow/blob/ff70c47a396ef1e3cb73c90513da4f5cb71bebba/tensorflow/python/lib/core/ndarray_tensor.cc#L113-L169) is vulnerable to a type confusion. 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.
TensorFlow is an end-to-end open source platform for machine learning. ...