CVE-2021-41221: TensorFlow: CuDNN heap overflow, local code execution
HIGH PoC AVAILABLEA local attacker with low privileges on any system running TensorFlow can trigger a heap buffer overflow in CuDNN shape inference, leading to arbitrary code execution under the TF process's identity. In shared GPU training clusters or multi-tenant ML platforms, this is a lateral movement vector. Patch immediately to TF 2.7.0, 2.6.1, 2.5.2, or 2.4.4 and audit who has access to shared ML compute infrastructure.
Risk Assessment
CVSS 7.8 High with local access requirement limits internet-exposed risk, but shared ML training clusters (common in enterprise and cloud environments) dramatically increase the realistic attack surface. No active exploitation recorded in CISA KEV, but the low complexity and absence of user interaction requirements make this straightforward to weaponize for a local adversary. Risk is elevated for organizations running multi-tenant GPU infrastructure or CI/CD ML pipelines where multiple users submit training jobs to shared hardware.
Affected Systems
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| tensorflow | pip | — | No patch |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
5 steps-
PATCH
Upgrade TensorFlow to 2.7.0, 2.6.1, 2.5.2, or 2.4.4 — apply to all nodes in training clusters, model serving infrastructure, and developer workstations.
-
ISOLATE
Enforce OS-level isolation (containers/VMs) for multi-tenant ML training jobs; do not run untrusted training scripts under shared GPU user accounts.
-
VALIDATE
Add input shape validation before passing tensors to CuDNN operations in custom training code as a defense-in-depth measure.
-
DETECT
Monitor for unexpected process crashes (segfaults) in TensorFlow workers on GPU nodes — these may indicate exploitation attempts or probing activity.
-
AUDIT
Review access lists for shared ML compute nodes; apply least-privilege to ML pipeline service accounts.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-41221?
A local attacker with low privileges on any system running TensorFlow can trigger a heap buffer overflow in CuDNN shape inference, leading to arbitrary code execution under the TF process's identity. In shared GPU training clusters or multi-tenant ML platforms, this is a lateral movement vector. Patch immediately to TF 2.7.0, 2.6.1, 2.5.2, or 2.4.4 and audit who has access to shared ML compute infrastructure.
Is CVE-2021-41221 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-41221, increasing the risk of exploitation.
How to fix CVE-2021-41221?
1. PATCH: Upgrade TensorFlow to 2.7.0, 2.6.1, 2.5.2, or 2.4.4 — apply to all nodes in training clusters, model serving infrastructure, and developer workstations. 2. ISOLATE: Enforce OS-level isolation (containers/VMs) for multi-tenant ML training jobs; do not run untrusted training scripts under shared GPU user accounts. 3. VALIDATE: Add input shape validation before passing tensors to CuDNN operations in custom training code as a defense-in-depth measure. 4. DETECT: Monitor for unexpected process crashes (segfaults) in TensorFlow workers on GPU nodes — these may indicate exploitation attempts or probing activity. 5. AUDIT: Review access lists for shared ML compute nodes; apply least-privilege to ML pipeline service accounts.
What systems are affected by CVE-2021-41221?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, GPU compute clusters, CI/CD ML pipelines.
What is the CVSS score for CVE-2021-41221?
CVE-2021-41221 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.02%.
Technical Details
NVD Description
TensorFlow is an open source platform for machine learning. In affected versions the shape inference code for the `Cudnn*` operations in TensorFlow can be tricked into accessing invalid memory, via a heap buffer overflow. This occurs because the ranks of the `input`, `input_h` and `input_c` parameters are not validated, but code assumes they have certain 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 a low-privilege account on a shared GPU training cluster (e.g., a compromised data scientist account via credential phishing) submits a crafted training script that calls a Cudnn* operation with tensors whose input, input_h, or input_c ranks deviate from expected values. TensorFlow's shape inference code accesses memory beyond the allocated heap buffer without rank validation, triggering a heap buffer overflow. With careful memory layout manipulation, the attacker achieves arbitrary write primitives, injects shellcode, and escalates to the process owner's privileges — potentially compromising the entire GPU node and any models, credentials, or training data accessible by that process.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H References
- github.com/tensorflow/tensorflow/commit/af5fcebb37c8b5d71c237f4e59c6477015c78ce6 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-cqv6-3phm-hcwx 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
AI Threat Alert