Do Not Derive Local Trust From Host Header
@prranitarora▲ 12 net votes
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.