CVE-2021-37643: TensorFlow: null deref in MatrixDiagPartOp, DoS risk
HIGHIf your ML infrastructure runs TensorFlow below 2.6.0 (or un-patched 2.3.x–2.5.x), a low-privileged local user can crash training jobs or silently corrupt matrix diagonal computations by passing an invalid padding value. Patch to the fixed versions immediately; the silent data-corruption path—where invalid outputs are produced without crashing—is more dangerous than the DoS in automated training pipelines. Shared ML compute clusters (multi-tenant GPU nodes, CI/CD-driven training) are the highest-priority remediation targets.
What is the risk?
Moderate-high risk in shared compute environments. CVSS 7.1 (Local/Low complexity/Low privileges) understates the real risk in organizations running multi-tenant ML infrastructure. Exploiting this requires only local shell access—common on shared training clusters, compromised CI/CD runners, or containerized notebook environments. The silent corruption variant (invalid results with no crash) is operationally more dangerous than the null-pointer crash because it can produce subtly incorrect model weights that propagate undetected through downstream pipelines.
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.6.0+, or apply backported fixes: 2.5.1, 2.4.3, or 2.3.4 (commit 482da92). Versions outside supported range (< 2.3.x) receive no patch and should be treated as EOL.
-
Input validation
Add upstream validation to reject empty tensors or invalid padding values before they reach MatrixDiagPartOp.
-
Multi-tenant hardening
Audit who can submit arbitrary TF jobs on shared clusters; apply job-submission RBAC if not already in place.
-
Detection
Enable process crash monitoring on training nodes (OOM/segfault signals); anomalous job terminations may indicate exploitation.
-
Pipeline integrity
For affected pipeline runs between publication (2021-08-12) and patch deployment, consider revalidating model outputs produced during that window if inputs came from untrusted sources.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-37643?
If your ML infrastructure runs TensorFlow below 2.6.0 (or un-patched 2.3.x–2.5.x), a low-privileged local user can crash training jobs or silently corrupt matrix diagonal computations by passing an invalid padding value. Patch to the fixed versions immediately; the silent data-corruption path—where invalid outputs are produced without crashing—is more dangerous than the DoS in automated training pipelines. Shared ML compute clusters (multi-tenant GPU nodes, CI/CD-driven training) are the highest-priority remediation targets.
Is CVE-2021-37643 actively exploited?
No confirmed active exploitation of CVE-2021-37643 has been reported, but organizations should still patch proactively.
How to fix CVE-2021-37643?
1. **Patch**: Upgrade to TensorFlow 2.6.0+, or apply backported fixes: 2.5.1, 2.4.3, or 2.3.4 (commit 482da92). Versions outside supported range (< 2.3.x) receive no patch and should be treated as EOL. 2. **Input validation**: Add upstream validation to reject empty tensors or invalid padding values before they reach MatrixDiagPartOp. 3. **Multi-tenant hardening**: Audit who can submit arbitrary TF jobs on shared clusters; apply job-submission RBAC if not already in place. 4. **Detection**: Enable process crash monitoring on training nodes (OOM/segfault signals); anomalous job terminations may indicate exploitation. 5. **Pipeline integrity**: For affected pipeline runs between publication (2021-08-12) and patch deployment, consider revalidating model outputs produced during that window if inputs came from untrusted sources.
What systems are affected by CVE-2021-37643?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, data preprocessing, MLOps/CI-CD pipelines.
What is the CVSS score for CVE-2021-37643?
CVE-2021-37643 has a CVSS v3.1 base score of 7.1 (HIGH). The EPSS exploitation probability is 0.16%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0029 Denial of AI Service AML.T0049 Exploit Public-Facing Application Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an end-to-end open source platform for machine learning. If a user does not provide a valid padding value to `tf.raw_ops.MatrixDiagPartOp`, then the code triggers a null pointer dereference (if input is empty) or produces invalid behavior, ignoring all values after the first. The [implementation](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/linalg/matrix_diag_op.cc#L89) reads the first value from a tensor buffer without first checking that the tensor has values to read from. We have patched the issue in GitHub commit 482da92095c4d48f8784b1f00dda4f81c28d2988. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Exploitation Scenario
An attacker with a data-scientist account on a shared GPU training cluster (compromised credentials, insider, or rogue contractor) submits a TensorFlow training script that passes an empty tensor to `tf.raw_ops.MatrixDiagPartOp` with an invalid padding value. In the crash path, the null-pointer dereference kills the TF process mid-training, causing denial of service to co-located jobs sharing the same node. In the more insidious corruption path, the attacker crafts a tensor where MatrixDiagPartOp silently discards valid diagonal entries, subtly degrading model accuracy. The corrupted weights pass automated test thresholds (accuracy within noise), get promoted through the MLOps pipeline, and are deployed to production—eroding model integrity without triggering alerts.
Weaknesses (CWE)
CWE-476 — NULL Pointer Dereference: The product dereferences a pointer that it expects to be valid but is NULL.
- [Implementation] For any pointers that could have been modified or provided from a function that can return NULL, check the pointer for NULL before use. When working with a multithreaded or otherwise asynchronous environment, ensure that proper locking APIs are used to lock before the check, and unlock when it has finished [REF-1484].
- [Requirements] Select a programming language that is not susceptible to these issues.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H References
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