Forwarded Headers Behind Tunnels: Why X-Forwarded-For, Proto and Host Can't Be Trusted Blindly
When an application runs behind a tunnel, headers such as X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host determine what the app believes about the caller, the protocol and the requested hostname. Misconfiguring trust can cause harmless problems like redirect loops or a rate limiter treating all visitors as one, or more serious ones where an attacker controls values that security checks rely on. Tunnel providers such as ngrok and Cloudflare append client information rather than sanitizing it, so client-supplied values remain in the header. Only entries added by proxies the developer controls should be trusted, and reading the leftmost value is unsafe for security decisions. Redirect loops occur when an app enforcing HTTPS sees plain HTTP because TLS terminates at the edge, and frameworks such as Django and Rails provide proxy-header settings to resolve this.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in