CVE-2021-29542:
Heap buffer overflow in `StringNGrams`
2.5
CVSS ScoreBasic Information
CVE ID
GHSA ID
EPSS Score
-
CWE
Published
5/21/2021
Updated
10/31/2024
KEV Status
No
Technology
Python
Technical Details
CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
tensorflow | pip | < 2.1.4 | 2.1.4 |
tensorflow | pip | >= 2.2.0, < 2.2.3 | 2.2.3 |
tensorflow | pip | >= 2.3.0, < 2.3.3 | 2.3.3 |
tensorflow | pip | >= 2.4.0, < 2.4.2 | 2.4.2 |
tensorflow-cpu | pip | < 2.1.4 | 2.1.4 |
tensorflow-cpu | pip | >= 2.2.0, < 2.2.3 | 2.2.3 |
tensorflow-cpu | pip | >= 2.3.0, < 2.3.3 | 2.3.3 |
tensorflow-cpu | pip | >= 2.4.0, < 2.4.2 | 2.4.2 |
tensorflow-gpu | pip | < 2.1.4 | 2.1.4 |
tensorflow-gpu | pip | >= 2.2.0, < 2.2.3 | 2.2.3 |
tensorflow-gpu | pip | >= 2.3.0, < 2.3.3 | 2.3.3 |
tensorflow-gpu | pip | >= 2.4.0, < 2.4.2 | 2.4.2 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability occurs in the ngram construction loop where token count validation is missing. The code calculates 'num_tokens = ngram_width - (left_padding + right_padding)' but proceeds to access 'data[data_start_index + num_tokens - 1]' without checking if 'num_tokens > 0'. When padding requirements force 'num_tokens=0', this becomes an invalid memory access. The patch explicitly adds a 'num_tokens > 0' guard around this operation, confirming this code path as the root cause.