CVE-2021-41216: TensorFlow: heap overflow in Transpose via negative perm

HIGH PoC AVAILABLE
Published November 5, 2021
CISO Take

TensorFlow's Transpose op shape inference fails to validate negative indices in `perm`, triggering a heap buffer overflow exploitable by any low-privilege user who can submit computation graphs. Any shared ML infrastructure running TensorFlow below 2.7.0 is at risk of process compromise and credential exposure. Patch immediately to TF 2.7.0, 2.6.1, 2.5.2, or 2.4.4.

Risk Assessment

CVSS 7.8 High with local attack vector, low complexity, and low privileges required — no remote exploitation without prior access. Not in CISA KEV with no confirmed in-the-wild exploitation. Risk escalates significantly in multi-tenant environments (shared notebooks, batch training clusters) where low-privilege users can submit arbitrary computation graphs, enabling heap corruption that reaches arbitrary code execution within the ML process and its environment secrets.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed 6d ago 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
7.8 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 5% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Moderate
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

Attack Surface

AV AC PR UI S C I A
AV Local
AC Low
PR Low
UI None
S Unchanged
C High
I High
A High

Recommended Action

5 steps
  1. Patch: upgrade to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 (commit c79ba87).

  2. Validate inputs: reject Transpose perm arguments containing non-positive indices at API ingestion boundaries before they reach TF graph execution.

  3. Sandbox: run untrusted model/graph execution in isolated containers with seccomp and AppArmor profiles to limit blast radius.

  4. Audit: scan ML infrastructure for heap corruption indicators (SIGABRT, crash dumps) in TF serving processes.

  5. Least privilege: ensure ML worker processes do not run with elevated OS privileges.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Art. 15 - Accuracy, Robustness and Cybersecurity
ISO 42001
A.10.1 - AI System Security
NIST AI RMF
MANAGE 2.2 - Mechanisms for AI Risk Response
OWASP LLM Top 10
LLM05 - Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2021-41216?

TensorFlow's Transpose op shape inference fails to validate negative indices in `perm`, triggering a heap buffer overflow exploitable by any low-privilege user who can submit computation graphs. Any shared ML infrastructure running TensorFlow below 2.7.0 is at risk of process compromise and credential exposure. Patch immediately to TF 2.7.0, 2.6.1, 2.5.2, or 2.4.4.

Is CVE-2021-41216 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2021-41216, increasing the risk of exploitation.

How to fix CVE-2021-41216?

1. Patch: upgrade to TensorFlow 2.7.0, 2.6.1, 2.5.2, or 2.4.4 (commit c79ba87). 2. Validate inputs: reject Transpose perm arguments containing non-positive indices at API ingestion boundaries before they reach TF graph execution. 3. Sandbox: run untrusted model/graph execution in isolated containers with seccomp and AppArmor profiles to limit blast radius. 4. Audit: scan ML infrastructure for heap corruption indicators (SIGABRT, crash dumps) in TF serving processes. 5. Least privilege: ensure ML worker processes do not run with elevated OS privileges.

What systems are affected by CVE-2021-41216?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, Jupyter notebook environments.

What is the CVSS score for CVE-2021-41216?

CVE-2021-41216 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 function for `Transpose` is vulnerable to a heap buffer overflow. This occurs whenever `perm` contains negative elements. The shape inference function does not validate that the indices in `perm` are all valid. 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 attacker with low-privilege access to a shared ML training cluster submits a TensorFlow SavedModel or computation graph containing a Transpose operation with perm=[0, -1, 2]. TensorFlow's shape inference code processes the negative index without bounds checking, writing out-of-bounds to heap memory. On a typical Linux ML worker, this corrupts adjacent heap structures, enabling the attacker to redirect execution flow, achieve arbitrary code execution within the training job process, and exfiltrate cloud credentials, model weights, and training data from the worker's environment.

CVSS Vector

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Timeline

Published
November 5, 2021
Last Modified
November 21, 2024
First Seen
November 5, 2021

Related Vulnerabilities