CVE-2021-29542: TensorFlow - Buffer Overflow
- Cve: CVE-2021-29542
- Name: TensorFlow - Buffer Overflow
- 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.
- Impact: Attackers can cause heap buffer overflow leading to potential memory corruption or crashes, impacting system stability and security.
- Remediation: Update to TensorFlow 2.5.0 or apply the cherrypick fix to affected versions 2.4.2, 2.3.3, 2.2.3, and 2.1.4.
- Vulnerability type: buffer_overflow
- Vulnerability impact: denial_of_service
- Requirement type: none
- Labels source: projectdiscovery
- Severity: medium
- Cvss score: 5.5
- Cvss vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
- Epss score: 0.00198
- Epss percentile: 0.09474
- Assignee: [email protected]
- Published at: 2021-05-14T20:15:12Z
- Age in days: 2020
- Modified at: 2026-06-17T03:47:52Z
- Patch available: yes
- Public exploits total: 1
- References total: 2
- Products total: 1
- Oss: yes
- Projects total: 1
- Advisory url: https://nvd.nist.gov/vuln/detail/CVE-2021-29542
- Nvd status: modified
- Checked, none or zero: known exploited entries, nuclei templates, public exploits capped, rejected by nvd
- Not known: requirements, hackerone
Cwe
| Id | Name |
|---|---|
| CWE-131 | Incorrect Calculation of Buffer Size |
| CWE-787 | Out-of-bounds Write |
Public exploits
| Url | Source | Added date |
|---|---|---|
| https://github.com/tensorflow/tensorflow/security/advisories/GHSA-4hrh-9vmp-2jgg | nvd | 2021-05-14 |
References
| Url | Source | Tags |
|---|---|---|
| https://github.com/tensorflow/tensorflow/commit/ba424dd8f16f7110eea526a8086f1a155f14f22b | nvd | Patch, Third Party Advisory |
| https://github.com/tensorflow/tensorflow/security/advisories/GHSA-4hrh-9vmp-2jgg | nvd | Exploit, Patch, Third Party Advisory |
Products
| Product | Affected | Platform bound | Sources | Url |
|---|---|---|---|---|
| google:tensorflow | >= 2.4.0, < 2.4.2; >= 2.3.0, < 2.3.3; >= 2.2.0, < 2.2.3; < 2.1.4 | no | nvd | /v1/products/google/tensorflow |
Projects
| Repository | Link kinds | Indexed | Url |
|---|---|---|---|
| tensorflow/tensorflow | commit, package, security_advisory | yes | /v1/repositories/tensorflow/tensorflow |
Index
- Repositories: 331
- Repositories high signal: 130
- Packages: 3
Exploitation
- Public exploit: yes
- Public exploit count: 1
- Public exploit first date: 2021-05-14
- Authentication required: yes
- Checked, none or zero: known exploited, known exploited by, exploitation seen, initial access, remote
- Not known: known exploited since, vulncheck known exploited since, nuclei template, initial access since, hackerone reports, exposed hosts