Host verification — refusing requests addressed to a name the server
doesn't answer to, which is how DNS rebinding reaches a loopback server.
In a rebinding attack, a page on an attacker's domain re-resolves that
domain to 127.0.0.1 and talks to the local server same-origin: its
GETs carry no Origin header, so the origin allowlist (http/origin.ts)
doesn't apply. The Host header gives it away — the browser sets it from
the URL, so it names the attacker's domain, never localhost.
A host is allowed when its name is loopback (localhost, 127.0.0.0/8,
[::1]), at any port — a rebinding page can't put one of those in Host
— or when an allowed origin names it (the allowlist is where the server's
UI is served from, so its hosts are the server's own names). Matching
reuses the origin matchers, so http://localhost:* or https://*.fuz.dev
admit the hosts they'd admit as origins.
A request without a Host header passes: browsers always send one, so its
absence means a non-browser client, which the auth stack governs. An empty
Host and more than one Host are refused (RFC 9112 §3.2), read from the
lines the client sent (get_header_lines) — on @hono/node-server a
WebSocket upgrade's own Headers keep only the first Host line, and on a
runtime that joins repeated lines (a, b) the comma names no host.
The gate is on by default (AppServerOptions.host_gate). A refusal is said
in the log as well as answered: the first in each
HOST_REFUSAL_WARN_INTERVAL_MS is a warning naming the refused Host
(quoted ASCII-only and truncated, since the client wrote it) and the env var
that lists the server's names, with a count of the refusals the interval
held back. The response says neither, so a client learns nothing about the
allowlist.
Twin of the Rust spine's fuz_http::host.