CVE-2021-29542

Source
https://cve.org/CVERecord?id=CVE-2021-29542
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-29542.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2021-29542
Aliases
Related
Published
2021-05-14T20:15:12.537Z
Modified
2026-04-11T17:12:41.809542Z
Severity
  • 5.5 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
[none]
Details

TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a heap buffer overflow by passing crafted inputs to tf.raw_ops.StringNGrams. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/1cdd4da14282210cc759e468d9781741ac7d01bf/tensorflow/core/kernels/stringngramsop.cc#L171-L185) fails to consider corner cases where input would be split in such a way that the generated tokens should only contain padding elements. If input is such that num_tokens is 0, then, for data_start_index=0 (when left padding is present), the marked line would result in reading data[-1]. 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.

References

Affected packages

Git / github.com/tensorflow/tensorflow

Affected ranges

Type
GIT
Repo
https://github.com/tensorflow/tensorflow
Events
Database specific
{
    "versions": [
        {
            "introduced": "0"
        },
        {
            "fixed": "2.1.4"
        },
        {
            "introduced": "2.2.0"
        },
        {
            "fixed": "2.2.3"
        },
        {
            "introduced": "2.3.0"
        },
        {
            "fixed": "2.3.3"
        },
        {
            "introduced": "2.4.0"
        },
        {
            "fixed": "2.4.2"
        }
    ]
}

Affected versions

0.*
0.5.0
0.6.0
v1.*
v1.1.0-rc1
v1.1.0-rc2
v1.12.1
v1.6.0-rc1
v1.9.0-rc2
v2.*
v2.1.0
v2.1.0-rc0
v2.1.0-rc1
v2.1.0-rc2
v2.1.1
v2.1.2
v2.1.3
v2.2.0
v2.2.1
v2.2.2
v2.3.0
v2.3.1
v2.3.2
v2.4.0
v2.4.1

Database specific

source
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-29542.json"
vanir_signatures_modified
"2026-04-11T17:12:41Z"
vanir_signatures
[
    {
        "signature_version": "v1",
        "signature_type": "Line",
        "source": "https://github.com/tensorflow/tensorflow/commit/ba424dd8f16f7110eea526a8086f1a155f14f22b",
        "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"
            ]
        },
        "id": "CVE-2021-29542-e874b66d",
        "deprecated": false,
        "target": {
            "file": "tensorflow/core/kernels/string_ngrams_op.cc"
        }
    }
]