CVE-2021-29518: TensorFlow: null ptr deref in session ops, local RCE
HIGH PoC AVAILABLETensorFlow 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 |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
5 steps-
Patch: Upgrade to TensorFlow 2.5.0 or apply backports 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.
-
Detect: Audit running TF versions across training nodes, serving clusters, and notebook servers —
pip show tensorflow | grep Version. -
Isolate: Enforce process-level isolation for untrusted TF workloads (containers, VMs, separate namespaces) so a crash or exploit is contained.
-
Harden: Remove raw session op access for non-admin users in shared ML platforms where feasible.
-
Monitor: Alert on unexpected TF process crashes in training pipelines, which may indicate exploitation attempts.
Classification
Compliance Impact
This CVE is relevant to:
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 References
- github.com/tensorflow/tensorflow/commit/ff70c47a396ef1e3cb73c90513da4f5cb71bebba Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-62gx-355r-9fhg Exploit Patch 3rd Party
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