Skip to Content
HTTP Host header manipulation attack

Host Header Poisoning

How applications that trust the HTTP Host header end up with poisoned password reset links, poisoned caches, SSRF and access control bypasses.

Sep 8, 2025
Updated Nov 22, 2026
4 min read

Description

Host header poisoning happens when an application reads the HTTP Host header and uses it without checking it. The header names the site the client wants, which is how one server hosts many virtual hosts. The client controls it like any other header.

Developers tend to treat Host as trustworthy and use it to build absolute URLs, check origins and fill in links in outgoing email. Change the header and those URLs point wherever you want. That gives you poisoned reset links, poisoned cache entries, or a way past checks that compare the hostname to a trusted value.

Why it is worth testing

This gets missed often. Password reset poisoning alone can mean takeover of any account whose owner clicks the reset link.

Impact

  • Password reset emails carry a link to the attacker's domain, so the reset token leaks when the victim clicks it.
  • A cache stores a response built with the attacker's host and serves it to other users.
  • Routing based on Host sends requests to internal systems or to an attacker-controlled server (SSRF).
  • Access controls that trust certain hostnames, such as admin panels limited to localhost, can be reached.
  • Outgoing email notifications contain attacker-supplied links or content.

Common examples

  • Password reset emails linking to evil.com instead of the real domain
  • Cached pages with attacker-controlled script or link URLs served to everyone
  • Internal API calls routed through a manipulated Host header
  • Admin or internal pages opened by sending Host: localhost
  • Notification emails with injected links used for phishing
  • SSRF against internal services through a reverse proxy that routes on Host

Detection

  • Change Host to arbitrary values in Burp Repeater and see what the response does with it.
  • Burp Scanner and OWASP ZAP both flag some cases of unvalidated Host handling.
  • Request a password reset for an account you control with a modified Host (and X-Forwarded-Host), then read the link in the email.
  • Check whether a cache keeps the response when only the host value changed.

Values worth trying in Host:

  • evil.com
  • localhost
  • internal.corp.local
  • Malformed values such as host:port@evil.com

Remediation

In rough priority order:

  • Validate the Host header:
    • Keep an allowlist of hostnames and compare the incoming header against it.
    • Reject requests with a missing or unexpected value.
    • Parse the value strictly rather than with substring checks.
  • Stop building URLs from the request:
    • Take the base URL for password resets and other sensitive links from configuration.
    • Never derive it from Host or X-Forwarded-Host.
  • Configure the web server:
    • Add a default virtual host that rejects unknown hostnames.
    • Return an error or a static page for anything that does not match.
    • Redirect to the canonical hostname at the server level.
  • Behind reverse proxies and load balancers:
    • Validate X-Forwarded-Host, or strip it at the edge if the application does not need it.
    • A Content Security Policy limits where injected resource URLs can load from.
    • A strict Referrer-Policy keeps reset tokens in URLs from leaking through the Referer header.
  • Framework settings:
    • Django: set ALLOWED_HOSTS to the real hostnames.
    • Express.js/Node.js: add middleware that checks the host against an allowlist.
    • ASP.NET: do not trust HttpContext.Request.Url.Host for URL generation.

Example configurations

  • Nginx

    server {
      listen 80 default_server;
      server_name _;
      return 444;  # Drop connection for invalid hosts
    }
    
    server {
      listen 80;
      server_name example.com www.example.com;
      # Application configuration
    }
  • Apache: the first VirtualHost for an address is the default, so in a real config put the catch-all block first.

    <VirtualHost *:80>
      ServerName example.com
      ServerAlias www.example.com
      # Application configuration
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerName _default_
      DocumentRoot /var/www/html/error
      # Catch-all for invalid hosts
    </VirtualHost>
  • Application-level validation

    # Python/Django example
    ALLOWED_HOSTS = ['example.com', 'www.example.com']
    
    def validate_host(request):
        host = request.get_host()
        if host not in settings.ALLOWED_HOSTS:
            raise DisallowedHost("Invalid host header")

Verification

After the fix:

  • Send malicious Host values and confirm they are rejected.
  • Trigger a password reset and confirm the link uses the configured domain.
  • Confirm the cache does not store responses built from a modified host.
  • Confirm internal routes cannot be reached by changing the header.

References

Next steps

If you find host header poisoning, list every place the application uses the header to build a URL, since the reset link is rarely the only one. Related notes:

On this page