CVE-2022-35938: TensorFlow: OOB read in GatherNd causes crash/data leak
CRITICALAny TensorFlow deployment using GatherNd operations (embedding lookups, attention mechanisms, sparse ops) exposed to untrusted input is vulnerable to remote crash or memory disclosure with no authentication required. Patch immediately to TF 2.10.0 / 2.9.1 / 2.8.1 / 2.7.2 — there are no workarounds. Prioritize model-serving endpoints (TensorFlow Serving, TFX) reachable from the internet or untrusted networks.
What is the risk?
Critical risk for organizations running TensorFlow inference APIs. CVSS 9.1 with network vector, zero authentication, and low complexity means exploitation is straightforward for any attacker who can reach the endpoint. The OOB read (CWE-125) yields both availability impact (crash/DoS) and confidentiality impact (process memory disclosure), which in an ML context could leak model weights, API secrets, or training data fragments from process memory. No active KEV listing suggests no confirmed mass exploitation, but the attack surface is large given TensorFlow's prevalence.
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.10.0, or backport patches to 2.9.1, 2.8.1, or 2.7.2. Commit 4142e47e9e31db481781b955ed3ff807a781b494 contains the fix.
-
SCOPE
Audit all services using tf.gather_nd() or models with embedding lookup layers exposed to external inputs.
-
NETWORK
Place TensorFlow Serving behind an API gateway with input validation and rate limiting. Reject tensors with indices outside expected bounds at the gateway layer.
-
DETECT
Monitor for anomalous crash/restart cycles in TF Serving containers — repeated crashes on specific inputs may indicate active probing.
-
TFLITE-MICRO: Patch tflite-micro separately if deployed on edge devices; it has its own affected kernel at gather_nd.cc:143-154.
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-35938?
Any TensorFlow deployment using GatherNd operations (embedding lookups, attention mechanisms, sparse ops) exposed to untrusted input is vulnerable to remote crash or memory disclosure with no authentication required. Patch immediately to TF 2.10.0 / 2.9.1 / 2.8.1 / 2.7.2 — there are no workarounds. Prioritize model-serving endpoints (TensorFlow Serving, TFX) reachable from the internet or untrusted networks.
Is CVE-2022-35938 actively exploited?
No confirmed active exploitation of CVE-2022-35938 has been reported, but organizations should still patch proactively.
How to fix CVE-2022-35938?
1. PATCH: Upgrade to TensorFlow 2.10.0, or backport patches to 2.9.1, 2.8.1, or 2.7.2. Commit 4142e47e9e31db481781b955ed3ff807a781b494 contains the fix. 2. SCOPE: Audit all services using tf.gather_nd() or models with embedding lookup layers exposed to external inputs. 3. NETWORK: Place TensorFlow Serving behind an API gateway with input validation and rate limiting. Reject tensors with indices outside expected bounds at the gateway layer. 4. DETECT: Monitor for anomalous crash/restart cycles in TF Serving containers — repeated crashes on specific inputs may indicate active probing. 5. TFLITE-MICRO: Patch tflite-micro separately if deployed on edge devices; it has its own affected kernel at gather_nd.cc:143-154.
What systems are affected by CVE-2022-35938?
This vulnerability affects the following AI/ML architecture patterns: model serving, training pipelines, inference, embedding-based recommendation systems, edge/IoT ML (TFLite Micro).
What is the CVSS score for CVE-2022-35938?
CVE-2022-35938 has a CVSS v3.1 base score of 9.1 (CRITICAL). The EPSS exploitation probability is 0.43%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0029 Denial of AI Service AML.T0040 AI Model Inference API Access AML.T0049 Exploit Public-Facing Application Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an open source platform for machine learning. The `GatherNd` function takes arguments that determine the sizes of inputs and outputs. If the inputs given are greater than or equal to the sizes of the outputs, an out-of-bounds memory read or a crash is triggered. This issue has been patched in GitHub commit 4142e47e9e31db481781b955ed3ff807a781b494. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.
Exploitation Scenario
An adversary targets a public recommendation or NLP inference API backed by TensorFlow Serving. The model uses an embedding lookup layer (internally GatherNd). The adversary submits a crafted inference request containing index values equal to or exceeding the output tensor size. This triggers the OOB memory read: in the best case the service crashes (DoS, disrupting the AI pipeline); in the worst case the read returns adjacent process memory contents in the response or error trace, potentially leaking model weights, environment variables with API keys, or fragments of other users' inference data. With low complexity and no auth required, a script-kiddie can automate this via repeated requests to map exploitable endpoints.
Weaknesses (CWE)
CWE-125 — Out-of-bounds Read: The product reads data past the end, or before the beginning, of the intended buffer.
- [Implementation] Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylis
- [Architecture and Design] Use a language that provides appropriate memory abstractions.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H References
- github.com/tensorflow/tensorflow/security/advisories/GHSA-3m3g-pf5v-5hpj Patch 3rd Party
- github.com/tensorflow/tflite-micro/blob/1bc98621180a350eb4e8d3318ea8e228c7559b37/tensorflow/lite/micro/kernels/gather_nd.cc 3rd Party
- github.com/tensorflow/tflite-micro/commit/4142e47e9e31db481781b955ed3ff807a781b494 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