{"id":"CVE-2021-37657","published":"2021-08-12T20:50:17Z","modified":"2024-08-04T01:23:01Z","title":"Reference binding to nullptr in `MatrixDiagV*` ops in TensorFlow","vendor":"tensorflow","product":"tensorflow","tier":"tail","description":{"text":"TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can cause undefined behavior via binding a reference to null pointer in all operations of type `tf.raw_ops.MatrixDiagV*`. The [implementation](https://github.com/tensorflow/tensorflow/blob/84d053187cb80d975ef2b9684d4b61981bca0c41/tensorflow/core/kernels/linalg/matrix_diag_op.cc) has incomplete validation that the value of `k` is a valid tensor. We have check that this value is either a scalar or a vector, but there is no check for the number of elements. If this is an empty tensor, then code that accesses the first element of the tensor is wrong. We have patched the issue in GitHub commit f2a673bd34f0d64b8e40a551ac78989d16daad09. 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.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.1,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00167,"percentile":0.06128,"provenance":"source"},"cwes":[{"id":"CWE-824","name":"Access of Uninitialized Pointer"}],"references":[{"url":"https://github.com/tensorflow/tensorflow/security/advisories/GHSA-5xwc-mrhx-5g3m","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/tensorflow/tensorflow/commit/f2a673bd34f0d64b8e40a551ac78989d16daad09","tags":["x_refsource_MISC"]}],"priority":{"score":6.2,"factors":[{"name":"EPSS percentile","points":1.23},{"name":"CVSS severity","points":4.97}]},"vendorSlug":"tensorflow","affectedVersions":[{"vendor":"tensorflow","product":"tensorflow","versions":[">= 2.5.0, < 2.5.1",">= 2.4.0, < 2.4.3","< 2.3.4"]}],"affected":[{"ecosystem":"PyPI","package":"tensorflow","vulnerableRanges":["<2.3.4",">=2.4.0, <2.4.3",">=2.5.0, <2.5.1",">=2.3.0, <2.3.4"],"patched":["2.3.4","2.4.3","2.5.1"],"from":["GHSA-5xwc-mrhx-5g3m","PYSEC-2021-279"],"provenance":"source"},{"ecosystem":"PyPI","package":"tensorflow-cpu","vulnerableRanges":["<2.3.4",">=2.4.0, <2.4.3",">=2.5.0, <2.5.1",">=2.3.0, <2.3.4"],"patched":["2.3.4","2.4.3","2.5.1"],"from":["GHSA-5xwc-mrhx-5g3m","PYSEC-2021-570"],"provenance":"source"},{"ecosystem":"PyPI","package":"tensorflow-gpu","vulnerableRanges":["<2.3.4",">=2.4.0, <2.4.3",">=2.5.0, <2.5.1",">=2.3.0, <2.3.4"],"patched":["2.3.4","2.4.3","2.5.1"],"from":["GHSA-5xwc-mrhx-5g3m","PYSEC-2021-768"],"provenance":"source"}],"summary":{"text":"The flaw is in TensorFlow's MatrixDiagV* operations, where incomplete validation of the tensor k lets an empty tensor pass the scalar-or-vector check, so downstream code reads its first element and binds a reference to a null pointer. An attacker who can invoke these operations with a crafted empty k tensor, which requires local access with low privileges and no user interaction, can trigger undefined behavior that may corrupt integrity and availability.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:16:30Z"},"euvd":{"id":"EUVD-2021-0383","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-tensorflow-cve-2021-29515","parents":[{"from":"CVE-2021-29515","to":"CVE-2021-37657","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["tensorflow/core/kernels/linalg/matrix_diag_op.cc"],"commits":["https://github.com/tensorflow/tensorflow/commit/a7116dd3913c4a4afd2a3a938573aa7c785fdfc6","https://github.com/tensorflow/tensorflow/commit/f2a673bd34f0d64b8e40a551ac78989d16daad09"],"basis":"shared function","functions":["MatrixDiagOp"]}]},{"from":"CVE-2021-37643","to":"CVE-2021-37657","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["tensorflow/core/kernels/linalg/matrix_diag_op.cc"],"commits":["https://github.com/tensorflow/tensorflow/commit/482da92095c4d48f8784b1f00dda4f81c28d2988","https://github.com/tensorflow/tensorflow/commit/f2a673bd34f0d64b8e40a551ac78989d16daad09"],"basis":"shared function","functions":["MatrixDiagPartOp"]}]}]}}