CVE-2022-21738: TensorFlow: integer overflow crashes process via sparse op
MEDIUM PoC AVAILABLE CISA: TRACK*A network-accessible integer overflow in TensorFlow's SparseCountSparseOutput kernel allows any authenticated user to crash the TF process — availability impact only, no data exfiltration. Patch immediately to TF 2.8.0, 2.7.1, 2.6.3, or 2.5.3; any TF inference endpoint accepting sparse tensor inputs is directly exposed. Priority is elevated for externally-facing model serving APIs where availability SLAs matter.
What is the risk?
Medium-risk but operationally significant for AI deployments. CVSS 6.5 with AV:N/AC:L/PR:L reflects easy network exploitation requiring only low-privilege access — no deep ML knowledge needed. Impact is pure availability (crash/restart cycle), not confidentiality or integrity. Risk increases significantly for production inference APIs serving external users, where repeated crashes translate directly to service downtime and SLA violations. No evidence of active exploitation or CISA KEV listing reduces urgency, but the low exploitation barrier warrants prompt patching.
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 TensorFlow to 2.8.0, 2.7.1, 2.6.3, or 2.5.3 (all contain the fix from commit 6f4d3e8).
-
WORKAROUND
Add server-side validation to reject sparse tensors with suspiciously large dimension values before they reach TF kernels.
-
ISOLATE
Run TF inference in separate processes with automatic restart (e.g., Kubernetes pod restarts, systemd restart policies) to limit downtime impact.
-
MONITOR
Alert on abnormal TF process crash rates — repeated crashes from the same source IP indicate exploitation attempts.
-
NETWORK CONTROL
Restrict access to TF serving endpoints to authenticated, authorized clients only — this vulnerability requires PR:L (low privileges), so unauthenticated exposure significantly expands the attack surface.
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2022-21738?
A network-accessible integer overflow in TensorFlow's SparseCountSparseOutput kernel allows any authenticated user to crash the TF process — availability impact only, no data exfiltration. Patch immediately to TF 2.8.0, 2.7.1, 2.6.3, or 2.5.3; any TF inference endpoint accepting sparse tensor inputs is directly exposed. Priority is elevated for externally-facing model serving APIs where availability SLAs matter.
Is CVE-2022-21738 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2022-21738, increasing the risk of exploitation.
How to fix CVE-2022-21738?
1. PATCH: Upgrade TensorFlow to 2.8.0, 2.7.1, 2.6.3, or 2.5.3 (all contain the fix from commit 6f4d3e8). 2. WORKAROUND: Add server-side validation to reject sparse tensors with suspiciously large dimension values before they reach TF kernels. 3. ISOLATE: Run TF inference in separate processes with automatic restart (e.g., Kubernetes pod restarts, systemd restart policies) to limit downtime impact. 4. MONITOR: Alert on abnormal TF process crash rates — repeated crashes from the same source IP indicate exploitation attempts. 5. NETWORK CONTROL: Restrict access to TF serving endpoints to authenticated, authorized clients only — this vulnerability requires PR:L (low privileges), so unauthenticated exposure significantly expands the attack surface.
What systems are affected by CVE-2022-21738?
This vulnerability affects the following AI/ML architecture patterns: model serving, training pipelines, data preprocessing pipelines.
What is the CVSS score for CVE-2022-21738?
CVE-2022-21738 has a CVSS v3.1 base score of 6.5 (MEDIUM). The EPSS exploitation probability is 0.77%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0029 Denial of AI Service AML.T0034 Cost Harvesting AML.T0049 Exploit Public-Facing Application Compliance Controls Affected
What are the technical details?
Original Advisory
Tensorflow is an Open Source Machine Learning Framework. The implementation of `SparseCountSparseOutput` can be made to crash a TensorFlow process by an integer overflow whose result is then used in a memory allocation. The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.
Exploitation Scenario
An adversary with low-privilege access to a TensorFlow model serving API (e.g., a trial account or compromised service credential) crafts a sparse tensor input where dimension values are set near INT_MAX boundaries. When the SparseCountSparseOutput kernel processes this input, integer arithmetic overflows during memory allocation size calculation, triggering an out-of-bounds allocation and process crash. By automating these requests, the adversary achieves sustained DoS against the inference endpoint — effectively taking down fraud detection, recommendation, or NLP services backed by TensorFlow. In multi-tenant ML platforms, a single malicious tenant can crash shared TF workers affecting other tenants.
Weaknesses (CWE)
CWE-190 — Integer Overflow or Wraparound: The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.
- [Requirements] Ensure that all protocols are strictly defined, such that all out-of-bounds behavior can be identified simply, and require strict conformance to the protocol.
- [Requirements] Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. If possible, choose a language or compiler that performs automatic bounds checking.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H References
- github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/kernels/count_ops.cc Exploit 3rd Party
- github.com/tensorflow/tensorflow/commit/6f4d3e8139ec724dbbcb40505891c81dd1052c4a Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-x4qx-4fjv-hmw6 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