Host header Injection rubygems.org
The site did not validate the HTTP Host header, so a request with an arbitrary Host value was answered by the CDN with an error page or a redirect to the supplied domain. The reporter argues this could be abused for web-cache poisoning or password reset link manipulation, though no such exploit was demonstrated.
- Disclosed after 15 months
Hi,
As you are interested in any bug in rubygems.org, I thought of reporting it.
The host header is not validated on rubygems.org. In many cases, developers are trusting the HTTP Host header value and using it to generate links, import scripts and even generate password resets links with its value. This is a very bad idea, because the HTTP Host header can be controlled by an attacker. This can be exploited using web-cache poisoning and by abusing alternative channels like password reset emails.
POC
GET / HTTP/1.1
Host: www.google.com
Response
HTTP/1.1 500 Domain Not Found
Server: Varnish
Retry-After: 0
content-type: text/html
Cache-Control: private, no-cache
connection: keep-alive
Content-Length: 207
Accept-Ranges: bytes
Date: Mon, 31 Oct 2016 07:49:14 GMT
Via: 1.1 varnish
Connection: close
<html>
<head>
<title>Fastly error: unknown domain www.google.com</title>
</head>
<body>
Fastly error: unknown domain: www.google.com. Please check that this domain has been added to a service.</body></html>
Now having my malicious page hosted on fastly(example taken is www.newrelic.com running on faslty), I can expolit the issue:
GET / HTTP/1.1
Host: www.newrelic.com
Response
HTTP/1.1 301 Moved Permanently
Server: nginx
Content-Type: application/x-msdownload
Status: 301 Moved Permanently
Location: http://newrelic.com/
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The reporter claims this could enable web-cache poisoning and password reset link abuse, but only error pages and redirects were shown, so real impact is unproven.
What the attacker needed
Ability to send custom Host header
The fix
The edge should reject or normalise requests whose Host header does not match the legitimate domain, and applications should not build links from the raw Host value.
How it was found
- Send a request to the site with an unrelated Host header value.
- Observe the CDN returns a 500 error naming the unknown domain.
- Send a request with a Host header pointing at another domain hosted on the same CDN.
- Observe a 301 redirect to that domain.
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 report has not been written yet. The Original tab links to the source.
Every web request carries a Host header that tells the server which site name the browser asked for. If a site trusts that value blindly, an attacker can put a different name in it and the site may echo it back in links or redirects. Here the CDN simply returned an error or a redirect for unknown names, and no real harm was shown.
What is Open redirect?
A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.