GHSA-M5GF-24GV-M9G8
DNS-rebinding TOCTOU in verification callback: raw aiohttp session leaks runner secret past the pre-request SSRF check
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-M5GF-24GV-M9G8 divulgada · CVSS 4.2 (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 verification service in flyto-core sends an evidence callback to a client-supplied `callback_url` and attaches an internal runner secret in the `X-Internal-Key` header. The destination is validated once with a pre-request DNS lookup and a trusted-host check, but the actual request is then made with a raw `aiohttp.ClientSession()` that performs its own independent DNS resolution at connect time. This validate-then-connect gap is a classic DNS-rebinding time-of-check to time-of-use flaw. An authenticated caller who controls DNS for a hostname that matches the trusted-callback configuration can rebind the second lookup to an internal, metadata, or attacker-controlled address, causing the runner secret and evidence payload to be delivered there. The rest of the codebase closes this exact window with a guarded session; the callback path was missed.
Root Cause
The security invariant is that a destination which passed the SSRF and trusted-host validation is the destination actually contacted. `_callback_destination_allowed` resolves the callback host once through `socket.getaddrinfo` (inside `validate_url_with_env_config`) and confirms the hostname matches the trusted-callback configuration, then returns. `post_callback` subsequently calls `aiohttp.ClientSession().post(...)`, and aiohttp's default resolver performs a second, independent DNS resolution at connect time. Nothing pins the address between the two lookups, so a low-TTL record can resolve to a benign public IP during validation and to an internal or attacker IP at connect time. The project already built `_SSRFGuardedResolver` and `guarded_client_session` to close precisely this rebinding window (documented in-source as the fix for the prior DNS-rebinding advisories) and wired the HTTP modules into it, but the verification callback still constructs a raw session and does not import or use the guarded variant. The runner secret is attached unconditionally once the one-time check passes.
src/core/verification_service.py
_callback_destination_allowed (around line 351): validates callback_url once via a pre-request DNS lookup and a trusted-host match, then returns; the resolved address is not pinned.
post_callback (around line 383): attaches FLYTO_RUNNER_SECRET (or FLYTO_VERIFICATION_SECRET) to the X-Internal-Key header, then issues aiohttp.ClientSession().post(...) with a fresh unguarded resolver (no connector, no _SSRFGuardedResolver).
module imports (lines 32-36): SSRFError, ssrf_protection_enabled, validate_url_with_env_config only; guarded_client_session is not imported.Impact
An attacker who can authenticate to the run endpoint (with the verification API key or the fallback secret) and who controls DNS for a hostname matching the trusted-callback configuration can rebind the connect-time lookup. The demonstrated capability is that the callback POST, carrying the internal runner secret in the `X-Internal-Key` header, is delivered to an attacker-controlled or internal destination instead of the engine. When the deployment uses a separate API key for the run endpoint and a distinct runner secret for the callback, this exposes a credential the caller did not already hold; the plausible consequence is impersonation of the verification runner to the engine and submission of forged verification evidence. Even where no distinct secret is configured, the same gap yields a blind SSRF POST that reaches internal services which should be unreachable. Practical exploitation requires authentication and DNS control of a trusted-matching hostname plus rebinding timing, so it is conditional rather than trivially reachable.
Proof of Concept
Static confirmation that post_callback uses a raw, unguarded aiohttp session and
attaches the runner secret, while the rest of the codebase uses guarded_client_session.
Run from the repository root.import ast, pathlib
src = pathlib.Path("src/core/verification_service.py").read_text()
tree = ast.parse(src)
fn = next(n for n in ast.walk(tree)
if isinstance(n, ast.AsyncFunctionDef) and n.name == "post_callback")
calls = [ast.unparse(n.func) for n in ast.walk(fn) if isinstance(n, ast.Call)]
print("raw session in post_callback :", "aiohttp.ClientSession" in calls)
print("guarded session in post_callback:", "guarded_client_session" in calls)
print("guarded_client_session imported :", "guarded_client_session" in src)
print("runner secret attached :", "FLYTO_RUNNER_SECRET" in src and "X-Internal-Key" in src)raw session in post_callback : True
guarded session in post_callback: False
guarded_client_session imported : False
runner secret attached : TrueAttack Chain
- Exposure: The attacker authenticates to the run endpoint using the verification API key or the fallback secret and submits a request whose `callback_url` uses a hostname the attacker controls in DNS and that matches the trusted-callback configuration.
- Control: The attacker controls the callback hostname's DNS records and serves a low-TTL response.
- Path: `_callback_destination_allowed` resolves the hostname once, sees a benign public IP, passes the SSRF check, and confirms the trusted-host match; `post_callback` then attaches the runner secret and issues the POST through a fresh unguarded resolver.
- Guard: The pre-request SSRF and trusted-host check are present, but no connect-time guard pins the validated address; the raw `aiohttp.ClientSession()` re-resolves the hostname independently.
- Primitive: DNS rebinding flips the connect-time resolution to an internal, metadata, or attacker-controlled IP, and the authenticated POST with the `X-Internal-Key` header is delivered there.
- Result: The runner secret is exfiltrated (when it is a distinct credential) enabling forged evidence to the engine, or, failing that, a blind SSRF POST reaches an internal endpoint.
Bypass Evidence
The relevant guards are the pre-request SSRF check and the trusted-host match added in the run-endpoint hardening advisory, and the codebase-wide DNS-rebinding fix that introduced `_SSRFGuardedResolver` and `guarded_client_session`. This finding is an unfixed variant of that DNS-rebinding fix on a code path the rollout missed: the callback path retained a raw `aiohttp.ClientSession()`. The static output above shows `post_callback` uses the raw session, does not use or import the guarded session, and attaches the runner secret. The in-source documentation for `_SSRFGuardedResolver` names the DNS-rebinding TOCTOU as the very issue it exists to close, and the change history wired the HTTP modules but not the callback into it. Attempts to disprove the finding were made and failed: the pre-request check does not pin the address so it cannot prevent rebinding; on the default container deployment there is no OS DNS cache and low-TTL records are not cached, so the two lookups are independent; the systematic outbound-guard coverage test audits registered modules and does not reach the internal verification service; and the trusted-host check narrows the target population but still admits a rebinding attacker with DNS control of a matching hostname. The trusted-host restriction and the authentication requirement are genuine mitigating factors, reflected in the conditional prerequisites, not full guards.
Affected Versions
- `Ecosystem: pip`
- `Package: flyto-core`
- `Confirmed affected range: >= 2.26.7, <= 2.32.1`
- `Latest release checked: 2.32.1 (PyPI)`
- `Fix status: not fixed`
The finding as described (a DNS-rebinding bypass of the pre-request callback validation while carrying the runner secret, requiring authentication to the run endpoint) applies from the release that introduced the run-endpoint authentication and the `_callback_destination_allowed` trusted-host check, namely 2.26.7. Earlier releases exposed the callback path as an unauthenticated request without a destination guard, which is a distinct and already published issue rather than this residual rebinding gap. The raw unguarded session persists through the latest published release, 2.32.1, and no fix exists on any branch.
Suggested Fix
Enforce that the validated destination is the destination contacted. Replace the raw `aiohttp.ClientSession()` in `post_callback` with the project's `guarded_client_session()` (which pins the connect-time resolution through `_SSRFGuardedResolver`), so the SSRF and rebinding checks apply at connect time and not only at validation time. Because the callback follows redirects and carries a custom header that is not stripped across origins, the remediation should also revalidate each redirect hop (the codebase already provides a guarded request helper for this) and consider not following cross-origin redirects for the secret-bearing callback. As an interim mitigation, operators can constrain the callback host to a fixed internal address, disable redirect following, or enforce network-layer egress restrictions on the runner so a rebound resolution cannot reach internal or metadata endpoints.
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-m5gf-24gv-m9g8Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
