AVID-2026-R0836
Description
Bad alloc in StringNGrams caused by integer conversion in TensorFlow (CVE-2021-37646)
Details
TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation of tf.raw_ops.StringNGrams is vulnerable to an integer overflow issue caused by converting a signed integer value to an unsigned one and then allocating memory based on this value. The implementation calls reserve on a tstring with a value that sometimes can be negative if user supplies negative ngram_widths. The reserve method calls TF_TString_Reserve which has an unsigned long argument for the size of the buffer. Hence, the implicit conversion transforms the negative value to a large integer. We have patched the issue in GitHub commit c283e542a3f422420cfdb332414543b62fc4e4a5. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Reason for inclusion in AVID: The candidate describes CVE-2021-37646, a vulnerability in TensorFlow (an AI framework) involving an integer conversion leading to bad memory allocation in StringNGrams. This is a software vulnerability in a component commonly used to build/train/deploy AI systems, i.e., a general-purpose AI software stack. It affects AI-related software supply chains (TensorFlow runtime/kernels) and has a security impact (potentially affecting availability). The report provides explicit details, affected scope, and a patch commit, giving sufficient evidence for curation.
References
- NVD entry
- https://github.com/tensorflow/tensorflow/security/advisories/GHSA-h6jh-7gv5-28vg
- https://github.com/tensorflow/tensorflow/commit/c283e542a3f422420cfdb332414543b62fc4e4a5
Affected or Relevant Artifacts
- Developer: tensorflow
- Deployer: tensorflow
- Artifact Details:
| Type | Name |
|---|---|
| System | tensorflow |
Impact
AVID Taxonomy Categorization
- Risk domains: Security
- SEP subcategories: S0100: Software Vulnerability
- Lifecycle stages: L06: Deployment
CVSS
| Version | 3.1 |
| Vector String | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| Base Score | 5.5 |
| Base Severity | 🟠 Medium |
| Attack Vector | LOCAL |
| Attack Complexity | 🟢 Low |
| Privileges Required | 🟢 Low |
| User Interaction | NONE |
| Scope | UNCHANGED |
| Confidentiality Impact | NONE |
| Integrity Impact | NONE |
| Availability Impact | 🔴 High |
CWE
| ID | Description |
|---|---|
| CWE-681 | CWE-681: Incorrect Conversion between Numeric Types |
Other information
- Report Type: Advisory
- Credits:
- Date Reported: 2021-08-12
- Version: 0.3.3
- AVID Entry