Skip to content
Heist/ feed
Back to feed
Medium

Security advisory

Type: advisorySources: OSVCVE: CVE-2021-29541

TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a dereference of a null pointer in `tf.raw_ops.StringNGrams`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/string_ngrams_op.cc#L67-L74) does not fully validate the `data_splits` argument. This would result in `ngrams_data`(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/string_ngrams_op.cc#L106-L110) to be a null pointer when the output would be computed to have 0 or negative size. Later writes to the output tensor would then cause a null pointer dereference. 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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2021-29541
Confirmed fixed CVEs
Not specified
Updated in this feed
31 Oct 2026, 12:44 UTC · Revision 1

Source evidence

CVE-2021-29541

core-osv · Original source

Published 14 May 2021, 20:15 UTC

TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a dereference of a null pointer in `tf.raw_ops.StringNGrams`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/string_ngrams_op.cc#L67-L74) does not fully validate the `data_splits` argument. This would result in `ngrams_data`(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/string_ngrams_op.cc#L106-L110) to be a null pointer when the output would be computed to have 0 or negative size. Later writes to the output tensor would then cause a null pointer dereference. 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.

osv:CVE-2021-29541
Complete source record
{
  "id": "e52bbcea0c7cb5fd4e2f5542e2c9a857a663507724814431a18268c35b36c2c0",
  "url": "https://osv.dev/vulnerability/CVE-2021-29541",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "CVE-2021-29541",
    "summary": "TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a dereference of a null pointer in `tf.raw_ops.StringNGrams`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/string_ngrams_op.cc#L67-L74) does not fully validate the `data_splits` argument. This would result in `ngrams_data`(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/string_ngrams_op.cc#L106-L110) to be a null pointer when the output would be computed to have 0 or negative size. Later writes to the output tensor would then cause a null pointer dereference. 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.",
    "evidence": "osv:CVE-2021-29541",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2021-29541",
      "aliases": [
        "BIT-tensorflow-2021-29541",
        "CVE-2021-29541",
        "GHSA-xqfj-35wv-m3cr",
        "PYSEC-2021-178",
        "PYSEC-2021-469",
        "PYSEC-2021-667"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/tensorflow/tensorflow",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "0931ea3d985bb9c8fdd054a5e29c4129623c849b"
                },
                {
                  "introduced": "2b96f3662bd776e277f86997659e61046b56c315"
                },
                {
                  "fixed": "cfe0c80169ae984bcdc99ff6de7444164aaa8e07"
                },
                {
                  "introduced": "b36436b087bd8e8701ef51718179037cccdfc26e"
                },
                {
                  "fixed": "3929ffacfbef7c431e8397920d040aaf47acff19"
                },
                {
                  "introduced": "582c8d236cb079023657287c318ff26adb239002"
                },
                {
                  "fixed": "1923123d32ea41d92b70a27a3f6ecf0763b56f6c"
                },
                {
                  "fixed": "ba424dd8f16f7110eea526a8086f1a155f14f22b"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "2.1.4"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "2.2.0"
                      },
                      {
                        "fixed": "2.2.3"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "2.3.0"
                      },
                      {
                        "fixed": "2.3.3"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "2.4.0"
                      },
                      {
                        "fixed": "2.4.2"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "ba424dd8f16f7110eea526a8086f1a155f14f22b"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v2.1.3",
            "v2.2.2",
            "v2.3.2",
            "v2.4.1",
            "v2.1.2",
            "v2.2.1",
            "v2.4.0",
            "v2.3.1",
            "v2.2.0",
            "v2.1.1",
            "v2.3.0",
            "v2.1.0",
            "v2.1.0-rc0",
            "v2.1.0-rc2",
            "v2.1.0-rc1",
            "v1.12.1",
            "v1.9.0-rc2",
            "v1.6.0-rc1",
            "v1.1.0-rc2",
            "v1.1.0-rc1",
            "0.6.0",
            "0.5.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-29541.json",
            "vanir_signatures": [
              {
                "id": "CVE-2021-29541-e874b66d",
                "digest": {
                  "threshold": 0.9,
                  "line_hashes": [
                    "57195627247613741680534829079164726143",
                    "144510031586872538897705158176453270924",
                    "67142721827154383847592773414742897200",
                    "198660284223107093965173105128464076313",
                    "84662326214440819971491155396053498454",
                    "132534507564806510781756549656216176799",
                    "200691599318631407204320864908507718759",
                    "16770105225719283317953667027856362121",
                    "300364817585889570830581672821453167062",
                    "221628520155122292914626066271129826040",
                    "335651150219913271764137831314776022110",
                    "184467774008778873472873586113998640431",
                    "279537133943222736387788191864446234549",
                    "290054871212833249125691179348205222232",
                    "311690171736731432233565701507438207456",
                    "113940870216757540903764345358011746357",
                    "30779893326960046852496776159198435969",
                    "77023344599735399717363121186761084022",
                    "83216137387116021136053497810571554164",
                    "140176743891041545566785711845894573260",
                    "183795575839910971458175928134312205846",
                    "148483364633044098094999335534833305871",
                    "331974045402895367520587276108357081382"
                  ]
                },
                "source": "https://github.com/tensorflow/tensorflow/commit/ba424dd8f16f7110eea526a8086f1a155f14f22b",
                "target": {
                  "file": "tensorflow/core/kernels/string_ngrams_op.cc"
                },
                "deprecated": false,
                "signature_type": "Line",
                "signature_version": "v1"
              }
            ],
            "vanir_signatures_modified": "2026-10-20T14:24:28Z"
          }
        }
      ],
      "modified": "2026-10-20T14:24:28.731768347Z",
      "provider": "osv",
      "references": [
        "https://github.com/tensorflow/tensorflow/commit/ba424dd8f16f7110eea526a8086f1a155f14f22b",
        "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-xqfj-35wv-m3cr"
      ],
      "provider_metadata": {}
    },
    "related_cves": [
      {
        "value": "CVE-2021-29541",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 388916,
  "published_at": "2021-05-14T20:15:12.487+00:00"
}