CVE-2021-41224: TensorFlow: heap OOB read in SparseFillEmptyRows op
HIGH PoC AVAILABLEUpgrade TensorFlow to 2.7.0, 2.6.1, 2.5.2, or 2.4.4 immediately. Any pipeline processing sparse tensors from untrusted sources is at risk — an attacker can trigger a heap out-of-bounds read to leak adjacent memory or crash the process. Prioritize model serving endpoints that accept sparse tensor inputs from external users.
What is the risk?
Moderate-high risk for organizations running unpatched TensorFlow in shared or externally-accessible ML infrastructure. CVSS 7.1 (High) with local attack vector limits remote-only exploitation, but multi-tenant ML platforms, Jupyter environments, or serving APIs that process user-supplied sparse tensors are viable attack surfaces. No active exploitation observed and not in CISA KEV, but the low attack complexity (AC:L) means exploitation is straightforward once access is obtained.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| TensorFlow | pip | — | No patch |
Do you use TensorFlow? You're affected.
How severe is it?
What is the attack surface?
What should I do?
5 steps-
Patch: Upgrade to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 per the advisory.
-
Input validation: Enforce that indices and values arrays are equal in length before invoking SparseFillEmptyRows or any sparse tensor op.
-
Isolation: Run TensorFlow training and serving in containers with restricted privileges to limit heap disclosure blast radius.
-
SBOM
Audit all TensorFlow instances in production using your software inventory — this includes transitive dependencies in ML pipelines.
-
Detection: Alert on abnormal TensorFlow process crashes or SIGABRT signals in serving infrastructure as a potential exploitation indicator.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-41224?
Upgrade TensorFlow to 2.7.0, 2.6.1, 2.5.2, or 2.4.4 immediately. Any pipeline processing sparse tensors from untrusted sources is at risk — an attacker can trigger a heap out-of-bounds read to leak adjacent memory or crash the process. Prioritize model serving endpoints that accept sparse tensor inputs from external users.
Is CVE-2021-41224 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-41224, increasing the risk of exploitation.
How to fix CVE-2021-41224?
1. Patch: Upgrade to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 per the advisory. 2. Input validation: Enforce that indices and values arrays are equal in length before invoking SparseFillEmptyRows or any sparse tensor op. 3. Isolation: Run TensorFlow training and serving in containers with restricted privileges to limit heap disclosure blast radius. 4. SBOM: Audit all TensorFlow instances in production using your software inventory — this includes transitive dependencies in ML pipelines. 5. Detection: Alert on abnormal TensorFlow process crashes or SIGABRT signals in serving infrastructure as a potential exploitation indicator.
What systems are affected by CVE-2021-41224?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, data preprocessing pipelines, recommendation systems.
What is the CVSS score for CVE-2021-41224?
CVE-2021-41224 has a CVSS v3.1 base score of 7.1 (HIGH). The EPSS exploitation probability is 0.20%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0043 Craft Adversarial Data AML.T0049 Exploit Public-Facing Application Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an open source platform for machine learning. In affected versions the implementation of `SparseFillEmptyRows` can be made to trigger a heap OOB access. This occurs whenever the size of `indices` does not match the size of `values`. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.4, as these are also affected and still in supported range.
Exploitation Scenario
An adversary with access to a model serving API or data ingestion pipeline submits a crafted sparse tensor payload where the indices array length does not match the values array length. When TensorFlow internally calls SparseFillEmptyRows — for example, during sparse feature preprocessing in a recommendation model — it reads beyond the allocated heap buffer. In a multi-tenant ML platform or a training pipeline processing uploaded datasets, a malicious record can trigger the condition, leaking heap contents from adjacent memory pages (potentially including model parameters or API tokens stored in the process) or crashing the training worker, disrupting operations.
Weaknesses (CWE)
CWE-125 — Out-of-bounds Read: The product reads data past the end, or before the beginning, of the intended buffer.
- [Implementation] Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylis
- [Architecture and Design] Use a language that provides appropriate memory abstractions.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H References
- github.com/tensorflow/tensorflow/commit/67bfd9feeecfb3c61d80f0e46d89c170fbee682b Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-rg3m-hqc5-344v Exploit Patch 3rd Party
- github.com/ARPSyndicate/cvemon Exploit
- github.com/adwisatya/SnykVulndb Exploit
Timeline
Related Vulnerabilities
CVE-2020-15196 9.9 TensorFlow: heap OOB read in sparse/ragged count ops
Same package: tensorflow CVE-2020-15205 9.8 TensorFlow: heap overflow in StringNGrams, ASLR bypass
Same package: tensorflow CVE-2020-15208 9.8 TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow CVE-2019-16778 9.8 TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflow CVE-2022-23587 9.8 TensorFlow: integer overflow in Grappler enables RCE
Same package: tensorflow