{"id":"CVE-2021-41221","aliases":["CVE-2021-41221","GHSA-cqv6-3phm-hcwx","BIT-TENSORFLOW-2021-41221","PYSEC-2021-413","PYSEC-2021-630","PYSEC-2021-828"],"related":[],"kind":"vulnerability","state":"published","title":"Access to invalid memory during shape inference in `Cudnn*` ops","summary":"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`, `input_h` and `input_c` 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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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`, `input_h` and `input_c` 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.","source":"cvelist"},{"lang":"en","text":"### Impact\nThe [shape inference code](https://github.com/tensorflow/tensorflow/blob/9ff27787893f76d6971dcd1552eb5270d254f31b/tensorflow/core/ops/cudnn_rnn_ops.cc) for the `Cudnn*` operations in TensorFlow can be tricked into accessing invalid memory, via a heap buffer overflow:\n\n```python\nimport tensorflow as tf\n\n@tf.function\ndef func():\n  return tf.raw_ops.CudnnRNNV3(\n    input=[0.1, 0.1],\n    input_h=[0.5],\n    input_c=[0.1, 0.1, 0.1], \n    params=[0.5, 0.5],\n    sequence_lengths=[-1, 0, 1])\n  \nfunc() \n```\n  \nThis occurs because the ranks of the `input`, `input_h` and `input_c` parameters are not validated, but code assumes they have certain values:\n\n```cc\nauto input_shape = c->input(0);\nauto input_h_shape = c->input(1);\nauto seq_length = c->Dim(input_shape, 0);\nauto batch_size = c->Dim(input_shape, 1);  // assumes rank >= 2\nauto num_units = c->Dim(input_h_shape, 2); // assumes rank >= 3\n``` \n\n### Patches\nWe have patched the issue in GitHub commit [af5fcebb37c8b5d71c237f4e59c6477015c78ce6](https://github.com/tensorflow/tensorflow/commit/af5fcebb37c8b5d71c237f4e59c6477015c78ce6).\n\nThe 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.\n\n### For more information\nPlease consult [our security guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how to contact us with issues and questions.\n\n### Attribution\nThis vulnerability has been reported by members of the Aivul Team from Qihoo 360.","format":"markdown","source":"ghsa"},{"lang":"es","text":"TensorFlow es una plataforma de código abierto para el aprendizaje automático. En las versiones afectadas, el código de inferencia de formas para las operaciones \"Cudnn*\" en TensorFlow puede ser engañado para acceder a memoria no válida, por medio de un desbordamiento del buffer de la pila. Esto ocurre porque los rangos de los parámetros \"input\", \"input_h\" y \"input_c\" no son comprobados, sino que el código asume que presentan ciertos valores. La corrección será incluida en TensorFlow versión 2.7.0. También será incluida este commit en TensorFlow versión 2.6.1, TensorFlow versión 2.5.2, y TensorFlow versión 2.4.4, ya que estos también están afectados y todavía están en el rango admitido","source":"nvd"}],"published":"2021-11-05T22:15:11.000Z","modified":"2026-09-08T08:48:25.139Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:L/AC:L/Au:N/C:P/I:P/A:P","score":4.6,"rating":"MEDIUM"},{"scorer":"Bitnami Vulnerability Database","scheme":"rating","rating":"HIGH"}],"cwes":["CWE-120","CWE-787"],"affected":[{"ranges":[{"version":">= 2.6.0, < 2.6.1","status":"affected"},{"version":">= 2.5.0, < 2.5.2","status":"affected"},{"version":"< 2.4.4","status":"affected"}],"vendor":"tensorflow","product":"tensorflow","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.6.0","status":"affected","fixed":"2.6.1"}],"ecosystem":"PyPI","package":"tensorflow","purl":"pkg:pypi/tensorflow","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.5.0","status":"affected","fixed":"2.5.2"}],"ecosystem":"PyPI","package":"tensorflow","purl":"pkg:pypi/tensorflow","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.4.4"}],"ecosystem":"PyPI","package":"tensorflow","purl":"pkg:pypi/tensorflow","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.6.0","status":"affected","fixed":"2.6.1"}],"ecosystem":"PyPI","package":"tensorflow-cpu","purl":"pkg:pypi/tensorflow-cpu","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.5.0","status":"affected","fixed":"2.5.2"}],"ecosystem":"PyPI","package":"tensorflow-cpu","purl":"pkg:pypi/tensorflow-cpu","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.4.4"}],"ecosystem":"PyPI","package":"tensorflow-cpu","purl":"pkg:pypi/tensorflow-cpu","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.6.0","status":"affected","fixed":"2.6.1"}],"ecosystem":"PyPI","package":"tensorflow-gpu","purl":"pkg:pypi/tensorflow-gpu","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.5.0","status":"affected","fixed":"2.5.2"}],"ecosystem":"PyPI","package":"tensorflow-gpu","purl":"pkg:pypi/tensorflow-gpu","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.4.4"}],"ecosystem":"PyPI","package":"tensorflow-gpu","purl":"pkg:pypi/tensorflow-gpu","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"2.4.0","fixed":"2.4.4"},{"status":"affected","introduced":"2.5.0","fixed":"2.5.2"},{"status":"affected","introduced":"2.6.0","fixed":"2.6.1"},{"status":"affected","version":"2.7.0"},{"status":"affected","version":"2.7.0"}],"vendor":"google","product":"tensorflow","cpe":"cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"af5fcebb37c8b5d71c237f4e59c6477015c78ce6"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.4.4"},{"type":"ecosystem","introduced":"2.5.0","status":"affected","fixed":"2.5.2"},{"type":"ecosystem","introduced":"2.6.0","status":"affected","fixed":"2.6.1"},{"type":"ecosystem","introduced":"2.7.0rc0","status":"affected","fixed":"2.7.0"}],"ecosystem":"PyPI","package":"tensorflow","purl":"pkg:pypi/tensorflow","repo":"https://github.com/tensorflow/tensorflow","source":"pysec"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"af5fcebb37c8b5d71c237f4e59c6477015c78ce6"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.4.4"},{"type":"ecosystem","introduced":"2.5.0","status":"affected","fixed":"2.5.2"},{"type":"ecosystem","introduced":"2.6.0","status":"affected","fixed":"2.6.1"},{"type":"ecosystem","introduced":"2.7.0rc0","status":"affected","fixed":"2.7.0"}],"ecosystem":"PyPI","package":"tensorflow-cpu","purl":"pkg:pypi/tensorflow-cpu","repo":"https://github.com/tensorflow/tensorflow","source":"pysec"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"af5fcebb37c8b5d71c237f4e59c6477015c78ce6"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.4.4"},{"type":"ecosystem","introduced":"2.5.0","status":"affected","fixed":"2.5.2"},{"type":"ecosystem","introduced":"2.6.0","status":"affected","fixed":"2.6.1"},{"type":"ecosystem","introduced":"2.7.0rc0","status":"affected","fixed":"2.7.0"}],"ecosystem":"PyPI","package":"tensorflow-gpu","purl":"pkg:pypi/tensorflow-gpu","repo":"https://github.com/tensorflow/tensorflow","source":"pysec"},{"ranges":[{"type":"semver","introduced":"2.4.0","status":"affected","fixed":"2.4.4"},{"type":"semver","introduced":"2.5.0","status":"affected","fixed":"2.5.2"},{"type":"semver","introduced":"2.6.0","status":"affected","fixed":"2.6.1"}],"ecosystem":"Bitnami","package":"tensorflow","purl":"pkg:bitnami/tensorflow","source":"bitnami"}],"references":[{"url":"https://github.com/tensorflow/tensorflow/security/advisories/GHSA-cqv6-3phm-hcwx","tags":["advisory","exploit","patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec","bitnami"]},{"url":"https://github.com/tensorflow/tensorflow/commit/af5fcebb37c8b5d71c237f4e59c6477015c78ce6","tags":["advisory","fix","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec","bitnami"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41221","tags":["advisory","web"],"sources":["ghsa","bitnami"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-630.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-828.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-413.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/tensorflow/tensorflow","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-41221","url":"https://www.cve.org/CVERecord?id=CVE-2021-41221","licence":"CVE Terms of Use","modified":"2024-08-04T03:08:31.404Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-cqv6-3phm-hcwx","url":"https://github.com/advisories/GHSA-cqv6-3phm-hcwx","licence":"CC-BY-4.0","modified":"2026-07-08T06:28:40.863Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-41221","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41221","licence":"Public domain","modified":"2026-06-17T04:08:07.423Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2021-413","url":"https://osv.dev/vulnerability/PYSEC-2021-413","licence":"CC-BY-4.0","modified":"2023-12-06T01:01:35.008Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2021-630","url":"https://osv.dev/vulnerability/PYSEC-2021-630","licence":"CC-BY-4.0","modified":"2023-12-06T01:01:35.008Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2021-828","url":"https://osv.dev/vulnerability/PYSEC-2021-828","licence":"CC-BY-4.0","modified":"2023-12-06T01:01:35.008Z"},{"source":"bitnami","name":"Bitnami Vulnerability Database","id":"BIT-TENSORFLOW-2021-41221","url":"https://osv.dev/vulnerability/BIT-TENSORFLOW-2021-41221","licence":"Apache-2.0","modified":"2026-09-08T08:48:25.139Z"}],"updatedAt":"2026-11-25T22:58:05.400Z","epss":{"score":0.00221,"percentile":0.1353,"date":"2026-12-01T12:00:22.000Z"}}