llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · fastapi-guard

GHSA-63QV-GH36-52QF

WebSocket connections bypass every SecurityMiddleware check, including active IP bans

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición86 dDesde la divulgación, 26 ago 2026, 2:57 p. m.
Detección85 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 7.8.0
Monitoreo
Detectada +1
26 ago 26
20 nov 26
21 nov 26
26 ago 26
17 sept 26
9 oct 26
30 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-63QV-GH36-52QF divulgada
Remediación Parche 7.8.0 fastapi-guard · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

`SecurityMiddleware` extends Starlette's `BaseHTTPMiddleware`
(`guard/middleware.py:46`). `BaseHTTPMiddleware.__call__` opens with
`if scope["type"] != "http": return await self.app(scope, receive, send)`, so a
`websocket` scope is handed straight to the router. Nothing in guard runs: no IP
allow/deny list, no ban check, no rate limit, no penetration detection, no
emergency lockdown. Route decorators on WebSocket handlers are inert too.

An address that is banned for HTTP can still open a socket and be served.

PoC
import asyncio
from fastapi import FastAPI, WebSocket
from starlette.testclient import TestClient
from guard.middleware import SecurityMiddleware
from guard_core.handlers.ipban_handler import ip_ban_manager
from guard_core.models import SecurityConfig

BANNED = ("203.0.113.66", 1234)
app = FastAPI()
app.add_middleware(SecurityMiddleware, config=SecurityConfig(enable_redis=False))

@app.get("/")
async def root():
    return {"ok": True}

@app.websocket("/ws")
async def socket(sock: WebSocket):
    await sock.accept()
    await sock.send_text("data the ban was supposed to withhold")
    await sock.close()

async def main():
    await ip_ban_manager.ban_ip(BANNED[0], 3600)
    with TestClient(app, client=BANNED) as client:
        print("GET  /  ->", client.get("/").status_code)
        with client.websocket_connect("/ws") as sock:
            print("WS  /ws ->", sock.receive_text())

asyncio.run(main())

On 7.7.0 / 3.13.0:

GET  /  -> 403
WS  /ws -> data the ban was supposed to withhold
Impact

Any control the operator configured is absent on the WebSocket half of the
application. For an app that puts its streaming or realtime surface on
WebSockets - chat, notifications, live queries - that surface has no rate limit
and no ban enforcement at all, and the ban that the operator can see in the
admin state does not apply to it. Brute-forcing an authenticated socket, or
continuing an attack after being banned over HTTP, both work.

`examples/simple_app` advertises WebSocket protection, so an operator reading
the examples has positive reason to believe this is covered.

Suggested fix

Either implement `__call__` at the ASGI level and run the identity, ban and rate
checks before the handshake is accepted, or say plainly in the README and the
example that the middleware is HTTP-only and ship a dependency
(`Depends(guard_ws_check)`) that a WebSocket route can use. The documentation
route is fine as a first step; the current state, where the example claims
coverage that does not exist, is the part that needs to change either way.

Fixed in 7.8.0

Fixed in fastapi-guard 7.8.0 https://github.com/rennf93/fastapi-guard/releases/tag/7.8.0 (PyPI https://pypi.org/project/fastapi-guard/7.8.0/), merged in #121 https://github.com/rennf93/fastapi-guard/pull/121 (eb5f284f). `guard_websocket` is a FastAPI dependency that runs the ban list, the IP and country allow lists and the rate limit against the resolved client before `accept()`, closing with 1008 on a policy violation; a client-less socket is rejected under `fail_secure=True`; Redis failures during the handshake follow `redis_fail_open` / `fail_secure` like the HTTP pipeline (close code 1013). `BaseHTTPMiddleware` never runs for websocket scopes, so protection is opt-in per route: `Depends(guard_websocket)`. Documented in the websockets tutorial; the example app wires it on `/ws`.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida Última
fastapi-guard≤ 7.7.0
7.7.0
8.1.2
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypifastapi-guard
Corregida 7.8.0 0 d 8.1.2 no afectada
Versiones corregidas7.8.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/Guard-Core/fastapi-guard/security/advisories/GHSA-63qv-gh36-52qf

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.