CVE-2021-29518: TensorFlow: null ptr deref in session ops, local RCE

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

TensorFlow eager mode (default since TF 2.0) dereferences a null session state pointer without validation, enabling a local low-privilege attacker to crash the process or achieve code execution. Patch to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 immediately. Risk is highest in multi-tenant ML platforms, shared Jupyter notebook servers, and MLOps pipelines where untrusted users execute TF code on shared infrastructure.

Risk Assessment

CVSS 7.8 High with local attack vector, low complexity, and no user interaction required — straightforward to trigger for any user with shell access to a TF environment. The null pointer dereference (CWE-476) is trivially exploitable: call raw session ops in eager mode and the undefined behavior fires unconditionally. While local access is required, this is rarely a meaningful barrier in ML environments where data scientists, contractors, or notebook services share compute. Not in CISA KEV, but the reliability of exploitation and breadth of TF deployments elevates real-world risk.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed today 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 1% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
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.5.0 or apply backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.

  2. Detect: Audit running TF versions across training nodes, serving clusters, and notebook servers — pip show tensorflow | grep Version.

  3. Isolate: Enforce process-level isolation for untrusted TF workloads (containers, VMs, separate namespaces) so a crash or exploit is contained.

  4. Harden: Remove raw session op access for non-admin users in shared ML platforms where feasible.

  5. Monitor: Alert on unexpected TF process crashes in training pipelines, which may indicate exploitation attempts.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
8.4 - AI system risk management
NIST AI RMF
MANAGE 2.2 - Mechanisms to sustain the value of deployed AI
OWASP LLM Top 10
LLM05:2025 - Improper Output Handling / Supply Chain Vulnerabilities

Frequently Asked Questions

What is CVE-2021-29518?

TensorFlow eager mode (default since TF 2.0) dereferences a null session state pointer without validation, enabling a local low-privilege attacker to crash the process or achieve code execution. Patch to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 immediately. Risk is highest in multi-tenant ML platforms, shared Jupyter notebook servers, and MLOps pipelines where untrusted users execute TF code on shared infrastructure.

Is CVE-2021-29518 actively exploited?

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

How to fix CVE-2021-29518?

1. Patch: Upgrade to TensorFlow 2.5.0 or apply backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4. 2. Detect: Audit running TF versions across training nodes, serving clusters, and notebook servers — `pip show tensorflow | grep Version`. 3. Isolate: Enforce process-level isolation for untrusted TF workloads (containers, VMs, separate namespaces) so a crash or exploit is contained. 4. Harden: Remove raw session op access for non-admin users in shared ML platforms where feasible. 5. Monitor: Alert on unexpected TF process crashes in training pipelines, which may indicate exploitation attempts.

What systems are affected by CVE-2021-29518?

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

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

CVE-2021-29518 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.01%.

Technical Details

NVD Description

TensorFlow is an end-to-end open source platform for machine learning. In eager mode (default in TF 2.0 and later), session operations are invalid. However, users could still call the raw ops associated with them and trigger a null pointer dereference. The implementation(https://github.com/tensorflow/tensorflow/blob/eebb96c2830d48597d055d247c0e9aebaea94cd5/tensorflow/core/kernels/session_ops.cc#L104) dereferences the session state pointer without checking if it is valid. Thus, in eager mode, `ctx->session_state()` is nullptr and the call of the member function is undefined behavior. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.

Exploitation Scenario

An attacker with low-privilege shell access to a shared ML training server (e.g., a data scientist account on a Kubeflow node or a compromised Jupyter container) calls the raw `GetSessionHandle` or `GetSessionTensor` ops directly in eager mode. Since `ctx->session_state()` returns nullptr in eager mode and the implementation dereferences it unconditionally, the call results in undefined behavior — reliably crashing the TF process or, depending on memory layout, enabling controlled memory corruption. In a multi-tenant environment, this terminates co-located training jobs and potentially exposes model artifacts or credentials stored in process memory.

Weaknesses (CWE)

CVSS Vector

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

Timeline

Published
May 14, 2021
Last Modified
November 21, 2024
First Seen
May 14, 2021

Related Vulnerabilities