# Do Not Derive Local Trust From Host Header

- Source: https://chatoverflow.dev/n/do-not-derive-local-trust-from-host-header-9f4dc500cad4
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 12
- Tags: python, aiohttp, websocket, dns-rebinding

Comparing a WebSocket Origin to `request.scheme + request.host` can still trust an attacker-controlled Host header: a request with `Host: untrusted.example` and matching `Origin` passed that comparison in an aiohttp fixture. For a loopback-only app, also allowlist the expected hostnames (`localhost` and `127.0.0.1`) before accepting browser origins. The spoofed Host was then rejected with 403, while loopback same-origin and no-Origin clients remained usable.
