Skip to content
Open redirect Disclosed report Beginner

[dev.twitter.com] XSS and Open Redirect Protection Bypass

A sign-in page on a Twitter developer subdomain accepted a crafted URL that appended a second address, and the server redirected to that attacker-chosen address. The same trick let the redirect target a javascript: URL, which could run script in the site's context, and the page could also be framed.

bywalks Follow

Originally disclosed on HackerOne

Bounty$1,120 Medium View original
  • Triaged in 10 days
  • Fixed in 2 months
  • Paid in 25 days
  • Disclosed after 10 months

Description: Hi after I finish reading the report https://hackerone.com/reports/260744.i start to test this subdomain.i fount an interesting url [https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/basics/adding-international-support-to-your-apps].this url is special,my intuition tells me that this URL may have a problem.so,i try test,amzing i found a way to bypass protection.

PoC: Open Redirect https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/

HTTP Response: HTTP/1.1 302 Found location: http://www.bywalks.com ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>Redirecting...</title> <h1>Redirecting...</h1> <p>You should be redirected automatically to target URL: <a href="http://www.bywalks.com">http://www.bywalks.com</a>. If not click the link.

PoC: XSS https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/javascript:alert(1)/

HTTP Response: HTTP/1.1 302 Found location: javascript:alert(1) ...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>Redirecting...</title> <h1>Redirecting...</h1> <p>You should be redirected automatically to target URL: <a href="javascript:alert(1)">javascript:alert(1)</a>. If not click the link.

PoC: ClickJacking

<iframe src="https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/" sandbox="allow-forms"></iframe>

Impact

go fishing.steal cookie,etc

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

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. 4 min read.

Context

The target is dev.twitter.com, a subdomain of Twitter's developer portal. The report was filed against the *.twitter.com asset on HackerOne and was disclosed on 7 February 2019 with a medium severity rating and a bounty of 1120.00 USD.

The feature involved is the sign-in path under /web/sign-in. The researcher does not describe what this endpoint normally does beyond the fact that it is a sign-in URL on the developer site. The report also references an earlier public report, https://hackerone.com/reports/260744, as the starting point for testing this subdomain.

Setup

No accounts, roles, tools or versions are described. The report shows raw HTTP responses but does not describe the tools used. The only precondition is access to the public dev.twitter.com host.

Finding it

While reading the earlier report, the researcher began testing the subdomain and came across an unusual URL:

Text
https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/basics/adding-international-support-to-your-apps

What stands out is the concatenation: the sign-in path is immediately followed by a second absolute URL with no separator. The researcher's intuition was that this shape might expose a problem, so they tested it and found a way to bypass the protection in place.

Exploitation

Step 1: Open redirect

The first payload appends an attacker-controlled absolute URL after the sign-in path:

Text
https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/

The server answered with a redirect to the external host:

HTTP
HTTP/1.1 302 Found
location: http://www.bywalks.com
...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="http://www.bywalks.com">http://www.bywalks.com</a>.  If not click the link.

The Location header points at http://www.bywalks.com, a domain outside twitter.com, and the body is the standard redirect page that repeats the target URL as a clickable link. The payload places the attacker-controlled URL after a second copy of the Twitter developer domain.

Step 2: XSS via the javascript: scheme

The same construction works with a javascript: URI instead of an HTTP URL:

Text
https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/javascript:alert(1)/

The response redirects to the script scheme:

HTTP
HTTP/1.1 302 Found
location: javascript:alert(1)
...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="javascript:alert(1)">javascript:alert(1)</a>.  If not click the link.

Here the Location header carries javascript:alert(1), and the redirect page renders the same value inside an anchor href. The response carries javascript:alert(1) in the Location header and in the anchor href; the report does not show the script executing.

Step 3: Clickjacking

The researcher also shows the redirect can be framed:

HTML
<iframe src="https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/" sandbox="allow-forms"></iframe>

The src is the open redirect URL from step 1, and the sandbox attribute is set to allow-forms. The report presents this as a clickjacking proof of concept without further explanation of the framing conditions.

Root cause

The sign-in endpoint takes the remainder of the path and uses it as a redirect target. The report says a protection was bypassed but does not describe how it works. Because the check is a prefix match on a string that itself contains a second absolute URL, the attacker can satisfy the check and still control what follows. The same construction also produced a redirect to a javascript: URI.

Impact

The researcher states the impact as "go fishing.steal cookie,etc": phishing and cookie theft. In practice, the open redirect gives an attacker a dev.twitter.com URL that lands on an arbitrary external site, which is useful for convincing phishing links. The report includes an iframe payload pointing at the redirect URL, without further explanation. The report does not quantify which cookies or sessions are reachable, and the impact depends on a victim following the crafted link.

Fix

Variants to test

  1. Append a second absolute URL after a known redirect path, as in https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/. A positive result is a 302 with a Location header pointing at the external host.
  2. Replace the external URL with a javascript: URI, as in https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/javascript:alert(1)/. A positive result is a Location header containing the script scheme.
  3. Embed the working redirect URL in an iframe with sandbox="allow-forms", as in the report. A positive result is the frame loading the redirect page.

Hunting notes

This kind of bug tends to hide in redirect and sign-in endpoints that accept a path segment or parameter and pass it to a Location header. The signal during recon is a URL that already contains a second absolute URL, as the researcher found here, which suggests the application is concatenating or prefix-matching rather than parsing. When testing, check whether a known-good prefix is required before the payload, since that indicates a string check that can be bypassed by placing the attacker value after it. The researcher gave three proofs: an off-host redirect, a javascript: redirect, and an iframe payload.

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. 11 min read.

What happened, in plain words

A security researcher was reading an earlier public bug report about Twitter's developer website, dev.twitter.com. That site is the place where people who build apps on top of Twitter go to read documentation and sign in. While poking around the sign-in area of that site, the researcher noticed a strange-looking web address. It looked like two addresses glued together. Their hunch was that something was wrong with how the site handled it, so they tried a few variations, and the site turned out to be easy to trick into sending visitors somewhere else, or even into running code.

The researcher reported three separate proofs of the same underlying weakness:

  1. An open redirect: a link on the real Twitter developer site that quietly sends the visitor to a completely different website.
  2. A cross-site scripting (XSS) issue: a link on the real Twitter developer site that makes the visitor's browser run a small piece of JavaScript code.
  3. A clickjacking demonstration: the same redirect page can be loaded inside a frame on someone else's website.

The report was filed on HackerOne, a platform where researchers report bugs to companies, against the *.twitter.com asset (meaning any subdomain of twitter.com). It was disclosed on 7 February 2019, rated medium severity, and paid a bounty of 1120.00 USD.

The target and the feature

The target is dev.twitter.com, a subdomain of Twitter's developer portal. A subdomain is a prefix on a domain name: just as www.example.com and mail.example.com can be different machines run by the same organisation, dev.twitter.com is a separate site under twitter.com.

The feature involved is the sign-in path under /web/sign-in. A path is the part of a web address after the domain name, like the folder structure on a computer. The researcher does not describe what this sign-in endpoint normally does beyond the fact that it is a sign-in URL on the developer site. The report also references an earlier public report, https://hackerone.com/reports/260744, as the starting point for testing this subdomain.

Setup

No accounts, roles, tools or versions are described. The report shows raw HTTP responses but does not describe the tools used. An HTTP client is any program that speaks the language of the web (HTTP) to a server: a browser is one, and so is a command-line tool that lets you send a request and read the raw reply. The only precondition is access to the public dev.twitter.com host.

Finding it

While reading the earlier report, the researcher began testing the subdomain and came across an unusual URL:

Text
https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/basics/adding-international-support-to-your-apps

What stands out is the concatenation: the sign-in path is immediately followed by a second absolute URL with no separator. An absolute URL is a complete web address that includes the scheme (https://), the domain, and the path, so it can stand on its own. Concatenation means joining two pieces of text end to end, like gluing two sentences together without a space. Here the sign-in path /web/sign-in is glued directly to a second full address starting with https://dev.twitter.com/basics/..., with nothing in between.

The researcher's intuition was that this shape might expose a problem, so they tested it and found a way to bypass the protection in place. A protection here means some check in the site's code that is supposed to stop the sign-in page from sending people to arbitrary places.

Exploitation

Step 1: Open redirect

An open redirect is when a website takes a destination from the address bar and forwards the visitor there without checking whether the destination is trustworthy. It is like a receptionist who will forward your call to any number a caller names, including a scammer's.

The first payload appends an attacker-controlled absolute URL after the sign-in path:

Text
https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/

Reading this address from left to right: it starts with the real Twitter developer site, then the sign-in path, then a second copy of the Twitter developer domain, and finally http://www.bywalks.com/, a website outside Twitter. The trick is that the beginning looks legitimate to a simple check, while the end is what the attacker actually wants the visitor to reach.

The server answered with a redirect to the external host:

HTTP
HTTP/1.1 302 Found
location: http://www.bywalks.com
...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="http://www.bywalks.com">http://www.bywalks.com</a>.  If not click the link.

Line by line:

  • HTTP/1.1 302 Found is the server's status line. HTTP is the protocol browsers and servers use to talk. 302 is a status code meaning "the thing you asked for has moved; go to this other address instead". A status code is a three-digit number the server sends to summarise what happened.
  • location: http://www.bywalks.com is a response header, a small labelled piece of information attached to the reply. The Location header is the standard way a server tells the browser where to go next. Here it points at http://www.bywalks.com, a domain outside twitter.com.
  • The ... stands for other headers the report does not show.
  • <!DOCTYPE HTML PUBLIC ...> and the lines after it are the body of the response: the actual content sent back. This is the standard redirect page that repeats the target URL as a clickable link.
  • <title>Redirecting...</title> is the page title shown in the browser tab.
  • <h1>Redirecting...</h1> is a large heading on the page.
  • The <p> paragraph tells the visitor they should be redirected automatically, and the <a href="http://www.bywalks.com"> is a link (an anchor element) whose href attribute holds the destination. If the automatic redirect does not happen, the visitor can click it.

The payload places the attacker-controlled URL after a second copy of the Twitter developer domain.

Step 2: XSS via the javascript: scheme

XSS, short for cross-site scripting, is when an attacker gets their own code to run inside a victim's browser as if it came from the trusted website. A scheme is the first part of a web address before the colon, such as https:, http:, mailto: or javascript:. The javascript: scheme tells the browser that what follows is code to run rather than a page to load.

The same construction works with a javascript: URI instead of an HTTP URL:

Text
https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/javascript:alert(1)/

Again the address begins with the expected Twitter prefix, and then instead of a normal web address it carries javascript:alert(1). alert(1) is a built-in browser function that pops up a small dialogue box showing the number 1. It is harmless in itself; researchers use it as a visible sign that code has run.

The response redirects to the script scheme:

HTTP
HTTP/1.1 302 Found
location: javascript:alert(1)
...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="javascript:alert(1)">javascript:alert(1)</a>.  If not click the link.

Line by line:

  • HTTP/1.1 302 Found is again the redirect status.
  • location: javascript:alert(1) is the crucial part: the server is telling the browser to go to a javascript: address, which means "run this code".
  • The body is the same standard redirect page, and this time the anchor's href is javascript:alert(1), so clicking the link also runs the code.

An origin is the combination of scheme, domain and port that browsers use to decide which site a page belongs to; code running in an origin can read that site's data, including cookies. A cookie is a small piece of data a website asks the browser to store and send back on every request, commonly used to remember that you are logged in.

Step 3: Clickjacking

Clickjacking is when an attacker loads a real website inside an invisible or disguised frame on their own page, so that when you think you are clicking something on their page you are actually clicking a button on the real site. A frame (or iframe) is a window inside a web page that shows another page.

The researcher also shows the redirect can be framed:

HTML
<iframe src="https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/" sandbox="allow-forms"></iframe>

Line by line:

  • <iframe ...> is the HTML element that embeds one page inside another.
  • src="..." is the attribute that says which address to load. Here it is the open redirect URL from step 1, so the frame loads the Twitter redirect page, which then sends the frame to the external site.
  • sandbox="allow-forms" is an attribute that restricts what the framed page is allowed to do. The value allow-forms permits forms inside the frame to be submitted, while other capabilities are blocked by default.

The report presents this as a clickjacking proof of concept without further explanation of the framing conditions.

Root cause

The sign-in endpoint takes the remainder of the path and uses it as a redirect target. The report says a protection was bypassed but does not describe how it works. Parsing means breaking a piece of text down into its structured parts (scheme, host, path) so you can reason about them; a host is the domain name part of an address. Because the check is a prefix match on a string that itself contains a second absolute URL, the attacker can satisfy the check and still control what follows. The same construction also produced a redirect to a javascript: URI. An allowlist is a list of things that are explicitly permitted, with everything else rejected.

Impact

The researcher states the impact as "go fishing.steal cookie,etc": phishing and cookie theft. Phishing is tricking someone into trusting a link or page so they hand over information or follow instructions. In practice, the open redirect gives an attacker a dev.twitter.com URL that lands on an arbitrary external site, which is useful for convincing phishing links, because the visible start of the link looks like the real Twitter developer site. The report includes an iframe payload pointing at the redirect URL, without further explanation. The report does not quantify which cookies or sessions are reachable, and the impact depends on a victim following the crafted link.

Fix

Variants to test

  1. Append a second absolute URL after a known redirect path, as in https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/http://www.bywalks.com/. A positive result is a 302 with a Location header pointing at the external host.
  2. Replace the external URL with a javascript: URI, as in https://dev.twitter.com/web/sign-inhttps://dev.twitter.com/javascript:alert(1)/. A positive result is a Location header containing the script scheme.
  3. Embed the working redirect URL in an iframe with sandbox="allow-forms", as in the report. A positive result is the frame loading the redirect page.

Hunting notes

This kind of bug tends to hide in redirect and sign-in endpoints that accept a path segment or parameter and pass it to a Location header. A parameter is a named value in a URL, usually after a ?, such as ?next=/home. The signal during recon is a URL that already contains a second absolute URL, as the researcher found here, which suggests the application is concatenating or prefix-matching rather than parsing. Recon, short for reconnaissance, is the early phase of looking around a target to understand how it is built. When testing, check whether a known-good prefix is required before the payload, since that indicates a string check that can be bypassed by placing the attacker value after it. The researcher gave three proofs: an off-host redirect, a javascript: redirect, and an iframe payload.

Glossary

  • Absolute URL: a complete web address containing scheme, domain and path, able to stand on its own.
  • Allowlist: a list of things explicitly permitted, with everything else rejected.
  • Anchor element: the HTML element (<a>) that creates a clickable link; its href attribute holds the destination.
  • Body: the main content of an HTTP response, as opposed to its headers.
  • Clickjacking: tricking a user into clicking something on a real site by hiding or disguising it inside a frame on another page.
  • Concatenation: joining two pieces of text end to end.
  • Cookie: a small piece of data a site asks the browser to store and send back on later requests, often used to keep you logged in.
  • Cross-site scripting (XSS): getting attacker-supplied code to run in a victim's browser as if it came from a trusted site.
  • Frame (iframe): a window embedded inside a web page that displays another page.
  • Header: a labelled piece of information attached to an HTTP request or response, such as Location.
  • Host: the domain name part of a web address.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTP client: any program that sends HTTP requests and reads the replies, such as a browser or a command-line tool.
  • Location header: the response header a server uses to tell the browser where to go next during a redirect.
  • Open redirect: a site forwarding visitors to a destination taken from the address bar without checking that it is trustworthy.
  • Origin: the combination of scheme, domain and port that browsers use to decide which site a page belongs to.
  • Parameter: a named value in a URL, usually after a ?.
  • Parsing: breaking text down into its structured parts so it can be reasoned about.
  • Path: the part of a web address after the domain name, like a folder path.
  • Phishing: tricking someone into trusting a link or page so they hand over information or follow instructions.
  • Recon: the early phase of exploring a target to understand how it is built.
  • Redirect: a server reply telling the browser to load a different address instead.
  • Scheme: the first part of a web address before the colon, such as https: or javascript:.
  • Status code: a three-digit number in an HTTP response summarising the outcome, such as 302.
  • Subdomain: a prefix on a domain name, such as dev in dev.twitter.com.
  • 302: the HTTP status code meaning the requested resource has moved and the browser should go to the address in the Location header.

More from X / xAI

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.