Host Header Injection
Host Header Injection is an attack where a malicious actor manipulates the HTTP Host header sent in a web request to exploit how a server or application processes that value. Because many web applications trust the Host header to construct URLs, route requests, or generate links, an attacker can abuse this trust to redirect users, poison caches, or trigger unintended server-side actions. The vulnerability typically arises from misconfiguration or flawed business logic rather than a flaw in the HTTP protocol itself.
Host Header Injection occurs when a web application uses the value of the HTTP Host header in security-sensitive operations without adequate validation or allowlisting. Because the Host header is fully attacker-controlled in a direct request, an application that reflects this value into redirect URLs, password reset links, internal routing logic, or cache keys may be vulnerable to a range of attack classes. These include web cache poisoning (where a poisoned cache entry is served to other users), password reset poisoning (where the reset link is constructed using the attacker-supplied host, directing victims to an attacker-controlled domain), and server-side request forgery (where internal routing decisions are influenced by the injected value). Initial testing involves substituting an arbitrary domain value in the Host header and observing whether the application reflects or acts upon it. Mitigation typically involves validating the Host header against a strict allowlist of permitted server names, as implemented at the application or middleware configuration level.
Why it matters
Host Header Injection is significant because the HTTP Host header is attacker-controlled in any direct request, yet many web applications treat it as a trusted, server-side value. Applications that use this header to construct URLs, generate links, or make routing decisions introduce a category of vulnerabilities that can affect users who never interact directly with a malicious actor. This indirect harm, where a poisoned cache entry or a crafted password reset link reaches innocent users, makes the attack class particularly dangerous relative to its low exploitation complexity.
Who it's relevant to
Inside Host Header Injection
Common questions
Answers to the questions practitioners most commonly ask about Host Header Injection.