CVE-2022-21733: TensorFlow: StringNGrams integer overflow enables OOM DoS
MEDIUM PoC AVAILABLE CISA: TRACK*Any TensorFlow deployment exposing the StringNGrams operation via an inference API is vulnerable to remote DoS by any authenticated user — the exploitation bar is low. Patch immediately to TF 2.8.0, 2.7.1, 2.6.3, or 2.5.3. If patching is delayed, add strict server-side input validation on pad_width parameters and enforce memory limits on inference containers.
What is the risk?
Medium severity (CVSS 6.5) but operationally significant for NLP inference services. AV:N/AC:L/PR:L means any authenticated API consumer can crash the server with a single crafted request. No code execution or data exposure, but uncontrolled OOM can cascade to container or node failures in shared infrastructure. Not in CISA KEV and no observed in-the-wild exploitation, but the vulnerability is trivially reproducible from the public patch diff.
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.8.0, 2.7.1, 2.6.3, or 2.5.3 — commit f68fdab93fb7f4ddb4eb438c8fe052753c9413e8 contains the fix.
-
Workaround: validate and bound pad_width inputs at the API gateway layer before invoking StringNGrams operations.
-
Defense-in-depth: enforce memory limits on TF inference containers (e.g., Kubernetes resource limits) to contain blast radius of OOM events.
-
Detection: alert on sudden memory spikes followed by OOM kills in TF serving processes; monitor for abnormal request patterns targeting string processing endpoints.
-
API hardening: restrict inference API access to the minimum required set of authenticated callers.
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-21733?
Any TensorFlow deployment exposing the StringNGrams operation via an inference API is vulnerable to remote DoS by any authenticated user — the exploitation bar is low. Patch immediately to TF 2.8.0, 2.7.1, 2.6.3, or 2.5.3. If patching is delayed, add strict server-side input validation on pad_width parameters and enforce memory limits on inference containers.
Is CVE-2022-21733 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2022-21733, increasing the risk of exploitation.
How to fix CVE-2022-21733?
1. Patch: upgrade to TensorFlow 2.8.0, 2.7.1, 2.6.3, or 2.5.3 — commit f68fdab93fb7f4ddb4eb438c8fe052753c9413e8 contains the fix. 2. Workaround: validate and bound pad_width inputs at the API gateway layer before invoking StringNGrams operations. 3. Defense-in-depth: enforce memory limits on TF inference containers (e.g., Kubernetes resource limits) to contain blast radius of OOM events. 4. Detection: alert on sudden memory spikes followed by OOM kills in TF serving processes; monitor for abnormal request patterns targeting string processing endpoints. 5. API hardening: restrict inference API access to the minimum required set of authenticated callers.
What systems are affected by CVE-2022-21733?
This vulnerability affects the following AI/ML architecture patterns: model serving, NLP preprocessing pipelines, training pipelines.
What is the CVSS score for CVE-2022-21733?
CVE-2022-21733 has a CVSS v3.1 base score of 6.5 (MEDIUM). The EPSS exploitation probability is 0.81%.
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 `StringNGrams` can be used to trigger a denial of service attack by causing an out of memory condition after an integer overflow. We are missing a validation on `pad_witdh` and that result in computing a negative value for `ngram_width` which is later used to allocate parts of the output. 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 a valid API account — a trial user, compromised credential, or malicious insider — submits a text inference request to a TensorFlow Serving endpoint that processes n-gram features. The request includes a crafted pad_width value designed to trigger integer overflow in the StringNGrams kernel. TF computes a negative ngram_width and attempts to allocate an impossibly large output buffer, exhausting server memory and crashing the inference process. In Kubernetes environments, this triggers pod restart loops, producing a sustained service outage for all users sharing that endpoint with no forensic indicators beyond OOM logs.
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/string_ngrams_op.cc Exploit 3rd Party
- github.com/tensorflow/tensorflow/commit/f68fdab93fb7f4ddb4eb438c8fe052753c9413e8 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-98j8-c9q4-r38g 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