Skip to content
OpenAdvisories
Low · 2.5 CVE-2021-29542 BIT-tensorflow-2021-29542EUVD-2021-0283GHSA-4hrh-9vmp-2jggPYSEC-2021-179PYSEC-2021-470PYSEC-2021-668

Heap buffer overflow in `StringNGrams`

Published May 14, 2021 · Updated Aug 3, 2024 · Assigned by GitHub_M

Description

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/string_ngrams_op.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.

Affected products

VendorProductAffectedFixed
tensorflow tensorflow < 2.1.4, >= 2.2.0, < 2.2.3, >= 2.3.0, < 2.3.3, >= 2.4.0, < 2.4.2 —

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI tensorflow < 2.1.4 2.1.4 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow >= 2.2.0, < 2.2.3 2.2.3 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow >= 2.3.0, < 2.3.3 2.3.3 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow >= 2.4.0, < 2.4.2 2.4.2 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow < 2.1.4 · >= 2.2.0, < 2.2.3 · >= 2.3.0, < 2.3.3 · >= 2.4.0, < 2.4.2 2.1.4, 2.2.3, 2.3.3, 2.4.2 PYSEC-2021-179
PyPI tensorflow-cpu < 2.1.4 2.1.4 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-cpu >= 2.2.0, < 2.2.3 2.2.3 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-cpu >= 2.3.0, < 2.3.3 2.3.3 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-cpu >= 2.4.0, < 2.4.2 2.4.2 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-cpu < 2.1.4 · >= 2.2.0, < 2.2.3 · >= 2.3.0, < 2.3.3 · >= 2.4.0, < 2.4.2 2.1.4, 2.2.3, 2.3.3, 2.4.2 PYSEC-2021-470
PyPI tensorflow-gpu < 2.1.4 2.1.4 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-gpu >= 2.2.0, < 2.2.3 2.2.3 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-gpu >= 2.3.0, < 2.3.3 2.3.3 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-gpu >= 2.4.0, < 2.4.2 2.4.2 GHSA-4hrh-9vmp-2jgg
PyPI tensorflow-gpu < 2.1.4 · >= 2.2.0, < 2.2.3 · >= 2.3.0, < 2.3.3 · >= 2.4.0, < 2.4.2 2.1.4, 2.2.3, 2.3.3, 2.4.2 PYSEC-2021-668

References