offsecnotes

Host header injection

by frankheat

Introduction

Virtual hosting

Routing traffic via an intermediary

HTTP Host header

Http host header refers to the Host header to determine the intended back-end

GET /web-security HTTP/1.1
Host: portswigger.net

Warning: Some intercepting proxies use the Host header to determine the target IP address, making testing difficult. Burp Suite keeps the Host header and target IP address separate, which is crucial.


Supply an arbitrary Host header

Start by testing the effect of providing an arbitrary domain name in the Host header


Exploitation

Password reset poisoning

Accessing restricted functionality

Admin panel with host: Host: localhost

Accessing internal websites with brute-forcing

Bruteforce subdomain

Web cache poisoning via the Host header

Routing-based SSRF

If load balancers and reverse proxies are misconfigured to forward requests based on an invalid Host header, you can exploit this to reroute requests to any system you choose -> exploit this to have access internal-only systems.

Detection

In the host header add your attacker.com website. If it doesn’t work try to identify private IP addresses anyway.

You can also brute force 192.168.0.0/16 , 10.0.0.0/8, etc.

Connection state attacks

You may encounter servers that only perform thorough validation on the first request they receive over a new connection. So, you can potentially bypass this validation by sending an innocent-looking initial request then following up with your malicious one down the same connection.

Note: You need to set up a single connection.

Exploiting server-side vulnerabilities

E.g. SQLi, etc.


Bypass validation