Skip to content

In-depth lesson · Host header injection

Typical fixes

Every point the Host header injection reports back under this heading, best-backed first, each with the reports it is seen in.

Back to the lesson 1 to 12 of 12
  1. Build reset links from a fixed, server-configured domain rather than any request header.

    Seen in 13 reports
  2. Validate the Host and X-Forwarded-Host headers against an allowlist of expected domains.

    Seen in 10 reports
  3. Only accept X-Forwarded-Host from a trusted proxy.

    Seen in 1 report
  4. Anchor host validation regexes at the end and match the exact domain.

    Seen in 1 report
  5. Canonicalise and validate hostnames so IDN homographs are rejected.

    Seen in 1 report
  6. Do not set the cookie Domain attribute from the request Host header.

    Seen in 1 report
  7. Invalidate old reset codes and use a fixed code strength regardless of request parameters.

    Seen in 1 report
  8. Do not trust X-Forwarded-For for rate limiting unless the request comes from a trusted proxy.

    Seen in 1 report
  9. Strip newline characters from user-supplied email addresses before inserting them into email headers.

    Seen in 1 report
  10. Block the .html extension in media uploads.

    Seen in 1 report
  11. Disable IPv6 router advertisements and WPAD, and enforce LDAP signing and channel binding.

    Seen in 1 report
  12. Do not accept a visible sender address as proof of account ownership.

    Seen in 1 report