CVE-2021-41221: Access to invalid memory during shape inference in `Cudnn*` ops
Impact The shape inference code for the Cudnn operations in TensorFlow can be tricked into accessing invalid memory, via a heap buffer overflow:
python import tensorflow as tf
@tf.function def func(): return tf.rawops.CudnnRNNV3( input=[0.1, 0.1], inputh=[0.5], inputc=[0.1, 0.1, 0.1], params=[0.5, 0.5], sequencelengths=[-1, 0, 1]) func() This occurs because the ranks of the input, inputh and inputc parameters are not validated, but code assumes they have certain values:
cc auto inputshape = c->input(0); auto inputhshape = c->input(1); auto seqlength = c->Dim(inputshape, 0); auto batchsize = c->Dim(inputshape, 1); // assumes rank >= 2 auto numunits = c->Dim(inputhshape, 2); // assumes rank >= 3
Patches We have patched the issue in GitHub commit af5fcebb37c8b5d71c237f4e59c6477015c78ce6.
The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.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.
Other sources
TensorFlow is an open source platform for machine learning. In affected versions the shape inference code for the Cudnn operations in TensorFlow can be tricked into accessing invalid memory, via a heap buffer overflow. This occurs because the ranks of the input, inputh and inputc parameters are not validated, but code assumes they have certain values. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.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-41221?
CVE-2021-41221 has been classified as a high severity vulnerability due to the risk of heap buffer overflow leading to potential memory access violations.
How do I fix CVE-2021-41221?
To fix CVE-2021-41221, upgrade to TensorFlow version 2.4.4, 2.5.2, or 2.6.1 if you are using a vulnerable version.
What versions of TensorFlow are affected by CVE-2021-41221?
CVE-2021-41221 affects TensorFlow versions from 2.4.0 up to but not including 2.4.4, and from 2.6.0 up to but not including 2.6.1.
What type of vulnerability is CVE-2021-41221?
CVE-2021-41221 is categorized as a heap buffer overflow, which may allow attackers to access invalid memory.
Is CVE-2021-41221 specific to TensorFlow GPU users?
No, CVE-2021-41221 affects both TensorFlow GPU and CPU users across the specified vulnerable versions.