Skip to content
XSS Write-up Advanced

IE & Edge URL parsin Problem

Internet Explorer and Edge mishandled malformed Host headers, allowing attackers to force requests with a Host header containing a slash. Combined with lax Host parsing by Heroku and Fastly, this let attackers serve their own content on any customer domain hosted on those platforms.

detectify Follow

Published on labs.detectify.com

TwitterLinkedIn

Detectify Labs, on labs.detectify.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This write-up, by Frans Rosén and Mathias Karlsson of Detectify, describes how a bug in Internet Explorer and Edge that allowed malformed Host headers to be sent could be combined with lax Host header parsing at two hosting and CDN providers, Heroku and Fastly. The result was that the researchers could make those providers serve content they controlled on domains belonging to the providers' customers.

The same Internet Explorer bug had previously been used by File Descriptor to steal GitHub OAuth tokens. The researchers used it to confuse the host routing of Heroku and Fastly. Both providers have since patched the issue on their side.

Setup

The attack needs three things:

  1. A victim using Internet Explorer or Edge, the only browsers that allowed the malformed Host header to be produced.
  2. A target domain that resolves to Fastly or Heroku and does not sit behind any additional proxy in between.
  3. An account on the provider that lets the attacker claim a wildcard domain, in this case *.to.to, and point its subdomains at content the attacker controls.

The researchers checked the routing with host and reproduced the server-side behaviour with cURL.

Finding it

The Internet Explorer/Edge bug worked as follows. A malicious link returned the following redirect:

HTTP
HTTP/1.1 307 Redirect
Location: https://www.drupal.org%2f.to.to

Internet Explorer/Edge would then send this request to www.drupal.org:

HTTP
GET /.to.toto/ HTTP/1.1
Host: www.drupal.org/.to.to

Both Heroku and Fastly parsed the Host header laxly. Even though the / character was inside the header, they still treated the host as a subdomain of .to.to. That made it possible to claim *.to.to as your own domain on the services, point all subdomains of .to.to at malicious content, and then use the Internet Explorer/Edge bug to serve that content on any domain bound to Heroku or Fastly.

Exploitation

Step 1: Confirm the target resolves to the provider

The researchers picked www.drupal.org as the victim domain and checked where it pointed:

Bash
$ host www.drupal.org
www.drupal.org is an alias for j.global-ssl.fastly.net.

It is an alias for a Fastly hostname, so the domain is served through Fastly.

Step 2: Claim the wildcard domain and send a crafted Host header

The researchers claimed *.to.to in Fastly and served a simple app from it as a proof of concept. They then sent a test request with cURL, putting the malformed value directly into the Host header:

Bash
curl -H 'Host: www.drupal.org/.to.to' https://www.drupal.org/

The response was:

HTML
<script>alert(document.domain)</script>

Fastly parsed the Host header, resolved it to the wrong domain, the wildcard *.to.to, and returned the content from the researchers' app instead of the customer's site.

Step 3: Deliver the malformed header through the browser

To trigger the same request in a victim's browser, the researchers sent the following link:

Text
https://avlidienbrunn.se/redirect.php?redirect=https://www.drupal.org%252f.to.to

The redirect endpoint returned:

HTTP
HTTP/1.1 307 Redirect
Location: https://www.drupal.org%2f.to.to

Internet Explorer/Edge followed the redirect and sent the following Host header:

HTTP
Host: www.drupal.org/.to.to

Instead of rejecting the request as invalid, both services handled the header as a subdomain of *.to.to and served the content the researchers controlled. The browser had resolved the original domain, www.drupal.org, which belongs to a Fastly/Heroku customer, but the page body came from the attacker's app.

Step 4: Assess what the served content can do

Because the browser still considered the page to be on the customer's origin, the attacker could serve any content, or make authenticated requests that would be allowed under the Same-Origin Policy (SOP) and so hijack the current user.

Root cause

The flaw is in how Heroku and Fastly parsed the Host header. A / inside the header value should make the value invalid as a hostname, but both services accepted it and treated the host as a subdomain of .to.to. Routing therefore followed attacker-controlled data rather than the hostname the browser had actually resolved and connected to.

The browser-side precondition is the Internet Explorer/Edge URL parsing bug, which let a redirect place a / into the Host header in the first place. Microsoft had been informed twice about the Host header injection; it was fixed once, but a regression brought it back.

Impact

All customers of Heroku and Fastly that did not use any additional proxies in between were vulnerable. The attack only worked in Internet Explorer and Edge. Safari had similar issues at the time, but the origin was emptied, so the SOP restricted additional requests; content extraction worked in Safari, but the resolved page only had the attacker's content, which made the Safari bug pointless in this case.

Within those limits, the combination allowed spoofing content on all customers of the two services: the attacker could serve any content they wanted, or make authenticated requests under the SOP to hijack the current user.

Fix

Fastly and Heroku patched the issue on their side. Microsoft patched the Host header injection in Internet Explorer/Edge. The timeline was:

Date Event
June 16 Reported to both Fastly and Heroku
June 21 Triaged by Fastly
June 28 Patch deployed by Fastly
June 30 Triaged by Heroku
July 7 Additions to the patch added
September X Host header injection in Internet Explorer/Edge patched by Microsoft
October 20 Final patches added by Heroku

Variants to test

  • Send a Host header containing a / to a CDN or hosting provider and see whether it routes to the part after the slash. A positive result is a response body from a domain you control rather than the requested site.
  • Claim a wildcard domain on a hosting provider and point its subdomains at your own content, then request a customer domain with a Host header of the form customer.example/your.wildcard. A positive result is your content returned for the customer's hostname.
  • Check whether a redirect endpoint under your control can place an encoded separator into the Host header of a browser request, and whether the browser still resolves the original domain. A positive result is the original domain resolving while the response body comes from the attacker's host.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

Two security researchers, Frans Rosén and Mathias Karlsson from Detectify, found a way to make two large web services, Heroku and Fastly, show content that the researchers controlled on websites that belonged to other people. The trick relied on a bug in two web browsers, Internet Explorer and Edge, plus a sloppy way the two services read a piece of information that every browser sends with every request.

To understand the story you need a few everyday ideas first.

When you type a website address into your browser, the browser has to find the computer that holds that website. It does this by looking up the name in a kind of phone book called DNS. The result is an address of a server. The browser then connects to that server and asks for the page.

Every request the browser sends includes a small note called the Host header. Think of it like the name you give at a reception desk: "I am here for the Drupal website." The server reads that note to decide which website to show. One physical server can hold many websites, so the note is how it tells them apart.

Heroku and Fastly are companies that run servers for other people. Customers put their websites on Heroku or Fastly, and those companies route each request to the right customer based on the Host header. If the note says "drupal.org", the request goes to Drupal's site. If it says something else, it goes somewhere else.

The bug was that Heroku and Fastly read the note too loosely. Normally the note should contain only a plain website name, like www.drupal.org. But the researchers found that if the note contained a slash character (/) followed by more text, the services still treated the host as a subdomain of .to.to. That let the researchers make the services show their own content while the browser still believed it was looking at a customer's website.

The second half of the trick was a bug in Internet Explorer and Edge. Those browsers could be made, through a specially crafted redirect link, to send a request with a malformed Host header containing a slash. The same browser bug had been used before by another researcher, File Descriptor, to steal GitHub login tokens. The researchers used it here to confuse the routing at Heroku and Fastly.

Both companies have since fixed the problem on their side. Microsoft also fixed the browser bug.

The browser bug: malformed Host headers in Internet Explorer and Edge

The Internet Explorer/Edge bug worked like this. A victim clicked a malicious link, and the server behind that link replied with a redirect. A redirect is a message that says "don't look here, look over there instead". The reply looked like this:

HTTP
HTTP/1.1 307 Redirect
Location: https://www.drupal.org%2f.to.to

Line by line:

  • HTTP/1.1 307 Redirect is the status line. 307 is a code that means "temporary redirect", and the browser should go to the address given in the next line without changing the request method.
  • Location: https://www.drupal.org%2f.to.to is the address the browser is told to go to. The %2f is a URL-encoded slash. In URLs, some characters cannot appear literally, so they are written in a percent-encoded form. %2f is the encoded form of /.

But Internet Explorer and Edge did something different. They sent this request to www.drupal.org:

HTTP
GET /.to.toto/ HTTP/1.1
Host: www.drupal.org/.to.to

Line by line:

  • GET /.to.toto/ HTTP/1.1 is the request line. GET means "give me this page", /.to.toto/ is the path being requested, and HTTP/1.1 is the version of the protocol.
  • Host: www.drupal.org/.to.to is the note telling the server which website is wanted. Here it contains a slash and extra text after the real hostname. That is not a valid hostname, but the browser sent it anyway.

That is the browser-side bug: a redirect could put a slash into a place where a slash should never be.

The server-side bug: lax Host parsing at Heroku and Fastly

Both Heroku and Fastly read the Host header loosely. Even though the / character was inside the header, they still treated the host as a subdomain of .to.to. A subdomain is a name that sits under a larger name, like blog.example.com sitting under example.com. A wildcard domain, written *.to.to, means "any subdomain of to.to".

That made it possible to claim *.to.to as your own domain on the services, point all subdomains of to.to at malicious content, and then use the Internet Explorer/Edge bug to serve that content on any domain bound to Heroku or Fastly. In other words, the services treated the malformed header as a subdomain of *.to.to and served that content instead of the customer's site.

Proving it works

The flow looked like this:

  1. You created a malicious redirect link and sent it to a victim.
  2. The redirect link would create the malformed Host header in Internet Explorer/Edge. The resolve would still be made to the original domain (in our case www.drupal.org) which was pointing to Fastly/Heroku.
  3. Fastly/Heroku would parse the Host header and resolve the wrong domain, in our case the wildcard *.to.to.
  4. Fastly/Heroku would then return data from our domain, even though the domain resolved by the browser was still the one owned by the customer of Fastly/Heroku.

Step 1: Check where the target domain points

The researchers picked www.drupal.org as the victim domain and checked where it pointed. They used a command-line tool called host, which asks the DNS phone book for information about a name:

Bash
$ host www.drupal.org
www.drupal.org is an alias for j.global-ssl.fastly.net.

Line by line:

  • $ host www.drupal.org is the command being run. The $ is just the prompt symbol, not part of the command. host is the tool, and www.drupal.org is the name being looked up.
  • www.drupal.org is an alias for j.global-ssl.fastly.net. is the answer. It says the name is an alias, meaning it points to another name, and that other name belongs to Fastly. So the domain is served through Fastly.

This step matters because the attack only works if the target site is actually hosted behind Heroku or Fastly. If it were hosted somewhere else, the loose parsing would never come into play.

Step 2: Claim the wildcard domain and send a crafted Host header

The researchers claimed *.to.to in Fastly and served a simple app from it as a proof of concept. A proof of concept is a small demonstration that shows the problem is real without doing any actual harm. They then sent a test request with cURL, a command-line tool for making web requests, putting the malformed value directly into the Host header:

Bash
curl -H 'Host: www.drupal.org/.to.to' https://www.drupal.org/

Line by line:

  • curl is the tool that sends the request.
  • -H 'Host: www.drupal.org/.to.to' tells cURL to add a custom header. -H means "header", and the quoted text is the header name and value. This is the malformed value with the slash in it.
  • https://www.drupal.org/ is the address being requested.

The response was:

HTML
<script>alert(document.domain)</script>

This is a tiny piece of JavaScript, the language web pages use to run code in the browser. alert(document.domain) shows a pop-up box containing the domain of the page. The fact that this came back instead of Drupal's real page showed that Fastly had parsed the Host header, resolved it to the wrong domain, the wildcard *.to.to, and returned the content from the researchers' app instead of the customer's site.

Step 3: Deliver the malformed header through the browser

Sending the request by hand with cURL proves the server behaves badly, but a real victim would never type such a request. To trigger the same request in a victim's browser, the researchers sent the following link:

Text
https://avlidienbrunn.se/redirect.php?redirect=https://www.drupal.org%252f.to.to

Line by line:

  • https://avlidienbrunn.se/redirect.php is a page on a server the researchers controlled. It is a redirect endpoint: a page whose only job is to send the visitor somewhere else.
  • ?redirect= starts the part of the address that carries information to that page. The page reads this value and uses it as the destination.
  • https://www.drupal.org%252f.to.to is the destination. Notice the %252f. The %25 is the encoded form of the percent sign %, so %252f decodes once to %2f, which is the encoded slash.

The redirect endpoint returned:

HTTP
HTTP/1.1 307 Redirect
Location: https://www.drupal.org%2f.to.to

Line by line:

  • HTTP/1.1 307 Redirect again means a temporary redirect.
  • Location: https://www.drupal.org%2f.to.to is the destination. The double-encoded %252f has now become %2f, the single-encoded slash.

Internet Explorer/Edge followed the redirect and sent the following Host header:

HTTP
Host: www.drupal.org/.to.to

Line by line:

  • Host: www.drupal.org/.to.to is the note the browser sends to the server. The %2f has been turned into a literal /, so the header now contains a slash and extra text after the real hostname.

Instead of rejecting the request as invalid, both services handled the header as a subdomain of *.to.to and served the content the researchers controlled. The browser had resolved the original domain, www.drupal.org, which belongs to a Fastly/Heroku customer, but the page body came from the attacker's app.

Step 4: What the served content can do

Because the browser still considered the page to be on the customer's origin, the attacker could serve any content, or make authenticated requests that would be allowed under the Same-Origin Policy (SOP) and so hijack the current user.

The Same-Origin Policy is a browser rule that stops one website from reading data belonging to another. An origin is the combination of scheme, host and port, roughly "which site". If a page is on the customer's origin, the browser treats it as that site, so it can read that site's cookies and make requests as the logged-in user. A cookie is a small piece of data a site stores in your browser to remember who you are. If an attacker can run code on the customer's origin, they can act as the user: that is what "hijack the current user" means.

Why it worked

The flaw is in how Heroku and Fastly parsed the Host header. A / inside the header value should make the value invalid as a hostname, but both services accepted it and extracted the part after the slash as the host to route on. Routing therefore followed attacker-controlled data rather than the hostname the browser had actually resolved and connected to.

The browser-side precondition is the Internet Explorer/Edge URL parsing bug, which let a redirect place a / into the Host header in the first place. Microsoft had been informed twice about the Host header injection; it was fixed once, but a regression brought it back. A regression means a bug that was fixed came back in a later version.

Who was affected

All customers of Heroku and Fastly that did not use any additional proxies in between were vulnerable. A proxy is a server that sits between the visitor and the real server and forwards requests.

The attack only worked in Internet Explorer and Edge. Safari had similar issues at the time, but the origin was emptied, so the SOP restricted additional requests; content extraction worked in Safari, but the resolved page only had the attacker's content, which made the Safari bug pointless in this case.

Within those limits, the combination allowed spoofing content on all customers of the two services: the attacker could serve any content they wanted, or make authenticated requests under the SOP to hijack the current user.

How it was fixed

Fastly and Heroku patched the issue on their side. Microsoft patched the Host header injection in Internet Explorer/Edge. The timeline was:

Date Event
June 16 Reported to both Fastly and Heroku
June 21 Triaged by Fastly
June 28 Patch deployed by Fastly
June 30 Triaged by Heroku
July 7 Additions to the patch added
September X Host header injection in Internet Explorer/Edge patched by Microsoft
October 20 Final patches added by Heroku

"Triaged" means the company confirmed the report was real and started working on it.

Things to test if you are learning

  • Send a Host header containing a / to a CDN or hosting provider and see whether it routes to the part after the slash. A positive result is a response body from a domain you control rather than the requested site.
  • Claim a wildcard domain on a hosting provider and point its subdomains at your own content, then request a customer domain with a Host header of the form customer.example/your.wildcard. A positive result is your content returned for the customer's hostname.
  • Check whether a redirect endpoint under your control can place an encoded separator into the Host header of a browser request, and whether the browser still resolves the original domain. A positive result is the original domain resolving while the response body comes from the attacker's host.

Glossary

  • Host header: a line in every web request that names the website the browser wants, so a server holding many sites knows which one to show.
  • DNS: the internet's phone book, which turns a website name into the address of a server.
  • Redirect: a server reply that tells the browser to go to a different address instead.
  • URL encoding: a way of writing characters that cannot appear literally in a web address, using a percent sign and two characters, such as %2f for /.
  • Subdomain: a name that sits under a larger name, like blog.example.com under example.com.
  • Wildcard domain: a setting that covers every subdomain of a name, written *.example.com.
  • CDN: a content delivery network, a company that stores and serves websites for many customers from servers around the world.
  • Heroku: a hosting company that runs websites and apps for its customers.
  • Fastly: a content delivery network that serves websites for its customers.
  • cURL: a command-line tool for sending web requests by hand.
  • host command: a command-line tool that looks up DNS information about a name.
  • Proof of concept: a small demonstration that shows a problem is real without causing harm.
  • JavaScript: the programming language web pages use to run code in the browser.
  • Same-Origin Policy (SOP): a browser rule that stops one website from reading data belonging to another.
  • Origin: the combination of scheme, host and port that identifies which site a page belongs to.
  • Cookie: a small piece of data a site stores in your browser to remember who you are.
  • Session hijacking: taking over a logged-in user's session so you can act as them.
  • Proxy: a server that sits between a visitor and the real server and forwards requests.
  • Regression: a bug that was fixed coming back in a later version.
  • Triaged: a company confirming a security report is real and starting work on it.
  • Patch: a software update that fixes a problem.
  • OAuth token: a piece of data that proves a user has authorised an app to act on their behalf.

More by detectify

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.