HTTP Cache Poisoning via Host Header Injection
Web applications that use the client-supplied HTTP Host header to build links in pages can be tricked into writing attacker-chosen URLs into those pages. If any cache along the path stores the response, other users receive the poisoned page with links pointing to the attacker's site.
carlos.bueno.org
Published on carlos.bueno.org
I've decided to post this here since it is pretty serious and there is no one vendor to blame. Watch yourselves.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application treats the client-controlled Host header as trusted data and uses it to generate absolute URLs in responses, which are then cached.
Impact
Attackers could rewrite URLs on cached pages, potentially redirecting other users to malicious sites; the author notes that caching by ISPs or CDNs may extend the poisoned content beyond the victim site's control.
What the attacker needed
Target uses Host header to build links; a cache stores the response; attacker can send crafted requests
The fix
Do not use the Host header value for anything; if unavoidable, strictly validate and whitelist allowed fully qualified domain names, and disable webserver features that echo the Host header.
How it was found
- Connect to the target web server and send a request for a page with a Host header set to an attacker-controlled domain.
- Observe that the returned page contains links rewritten to the attacker's domain.
- If a cache is present, the poisoned response is stored and served to other users.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you visit a website, your browser sends a 'Host' header saying which site name you want. Some sites copy that name into the links they generate. An attacker can send a different name, and if a cache (a server that stores copies of pages to serve them faster) keeps the result, everyone else gets a page full of links to the attacker's site.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.