Skip to content
Open redirect Disclosed report Intermediate CVE-2015-8935

Response Header injection using redirect_uri together with PHP that utilizes Header Folding according to RFC1945 and Internet Explorer 11

The redirect_uri parameter was passed unvalidated into a PHP Location header, and PHP's RFC1945 header folding allowed an attacker to inject a tab-prefixed continuation line that set an arbitrary cookie. Internet Explorer 11 would strip the tab and honour the injected Set-Cookie header, enabling response header injection.

Frans Rosén Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 51 days
  • Disclosed after 2 months

Hi, I noticed that the redirect_uri used to redirect users to any location on the page, passes in all data into a header("Location.. without any validation. The problem is that PHP (current PHP-versions of Debian/Ubuntu, there seem to be a patch properly in place in other dists) actually built the header-function according to RFC1945 which says:

HTTP/1.0 headers may be folded onto multiple lines if each
continuation line begins with a space or horizontal tab. All linear
whitespace, including folding, has the same semantics as SP.

Ref: https://tools.ietf.org/html/rfc1945#page-11

This means that doing the following request:

http://nextcloud/index.php?redirect_url=/%3f%0d%0a%09set-cookie:+hello=yoyoo

Will result in the following response:

Location: http://nextcloud/?
	set-cookie: hello=yoyoo

The problem is that IE is actually not caring at all about that rule from RFC1945 and will strip the tab-character from that header and listen to it:

Screen_Shot_2016-06-17_at_15.18.36.png
Screen_Shot_2016-06-17_at_15.18.36.png From the original on HackerOne

You should most likely disallow this character sequence completely so the failed backported versions of PHP won't do this. Properly secured PHP versions will fail doing the request due to new-lines in the header.

Regards, Frans

The original report as published on HackerOne, by fransrosen. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Root cause

Likely the redirect_uri value was concatenated into a Location header without rejecting carriage-return, line-feed and tab characters, and the PHP build followed RFC1945 header folding so the injected continuation line was emitted.

Impact

An attacker could set arbitrary cookies in the victim's browser when the victim used Internet Explorer 11.

What the attacker needed

Victim uses Internet Explorer 11; victim visits a crafted redirect link; PHP build follows RFC1945 header folding

The fix

The redirect_uri should reject carriage-return, line-feed and tab sequences entirely so that even PHP builds with header folding cannot emit an injected header.

How it was found

  1. Send a request to the redirect endpoint with a redirect_uri containing an encoded question mark, carriage return, line feed and a tab followed by a Set-Cookie header.
  2. Observe the response Location header now contains a folded continuation line carrying the injected cookie.
  3. Open the response in Internet Explorer 11, which strips the tab and honours the injected Set-Cookie header.

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.

When a website redirects you, it puts the destination in a response header called Location. This report shows that the destination was taken straight from the URL without checking, and a quirk in how PHP writes headers let an attacker sneak an extra header (a cookie) onto the response. Old Internet Explorer then treated that extra line as a real instruction, so the attacker could set cookies in the victim's browser.

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.

More by Frans Rosén

View all

26 more disclosed reports, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.