import { RequestHandler } from 'express'; type RequireTrustedHostOptions = { /** * Port-agnostic hostnames permitted in the `Host` and `Origin` headers. * IPv6 entries must be bracketed, e.g. `[::1]`. Invalid entries cause * {@link requireTrustedHost} to throw at construction time (fail fast). */ allowedHosts: string[]; }; /** * Loopback hostnames always trusted by {@link requireTrustedHost}. Stored * bracketed for IPv6 because `new URL('http://[::1]').hostname` returns `[::1]`. */ declare const DEFAULT_ALLOWED_HOSTS: string[]; /** * Build the list of hostnames trusted in the Host and Origin headers. Always * includes the loopback defaults, plus any names from `allowedHostsEnv` * (comma-separated), plus the configured `host` (so an explicit bind — loopback * alias like 127.0.1.1, a LAN IP, etc. — is always trusted). Bind wildcards * (0.0.0.0/::) are never added because they are never valid Host header values — * operators exposing on a wildcard must enumerate client hostnames via * ALLOWED_HOSTS. */ declare function buildAllowedHosts(host: string, allowedHostsEnv?: string): string[]; /** * Express middleware that rejects requests whose `Host` or `Origin` header is * not in the trusted allowlist. This is DNS-rebinding protection: a malicious * website that rebinds its domain to a victim's loopback address keeps its own * `Host`/`Origin`, so string-matching against the allowlist (we never DNS * resolve) blocks the request before it can reach the MCP transport. * * - Missing `Host` → 403. * - `Host` hostname not in the allowlist → 403. * - `Origin` absent → allowed (non-browser clients such as `mcp-remote`/`curl` * send none; the browser attack path always sends one). * - `Origin` present but untrusted or unparseable → 403. * * Throws at construction time if `allowedHosts` contains an entry that isn't a * valid authority, so misconfiguration fails fast instead of becoming opaque * 403s at request time. */ declare function requireTrustedHost(options: RequireTrustedHostOptions): RequestHandler; export { DEFAULT_ALLOWED_HOSTS, buildAllowedHosts, requireTrustedHost, type RequireTrustedHostOptions, }; //# sourceMappingURL=require-trusted-host.d.ts.map