Skip to content
Open redirect Disclosed report Beginner

XSS and Open Redirect on MoPub Login

The MoPub login page accepted a 'next' parameter that redirected users to any URL after login, and it also allowed javascript URIs, enabling cross-site scripting. An attacker could use this for phishing, cookie theft, or to hide the redirect destination.

jackb898 Follow

Originally disclosed on HackerOne

Bounty$1,540 View original
  • Triaged in 3 days
  • Fixed in 13 days
  • Paid in 8 days
  • Disclosed after 28 days

Summary by the researcher

Very simple open redirect made more impactful by the lack of filtering javascript URIs. Thanks again to the Twitter team for a quick response/bounty!

The report

Summary: I found open redirect at the MoPub login page, https://app.mopub.com/login?next=https://google.com. It also allows javascript URIs, leading to XSS.

Description: You can modify the "next" URL parameter to redirect to any website upon logging in on MoPub.

Steps To Reproduce:

  1. Take this URL: https://app.mopub.com/login?next=https://google.com
  2. Change "https://google.com" to whatever URL you want to redirect to.
  3. Visit the URL and login
  4. You will be redirected to that site

Impact: Outlined in Impact section below

Supporting Material/References:

Here's a proof of concept using the URL javascript:alert("proof of concept"):

d075ed6487c103b8c497250d385fe75f.mp4 From the original on HackerOne

Impact

An attacker could use this for phishing, cookie jacking, etc. since it allows javascript URIs and therefore XSS vectors. Additionally, they could use URL encoding to hide the URL that the victim is being redirected to.

The original report as published on HackerOne, by jackb898. 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

MoPub's login page lives at app.mopub.com. Like many login pages, it accepts a next parameter that tells the application where to send the user after a successful sign-in. The intended behaviour is that a user who is bounced to the login page is returned to the page they were trying to reach. The researcher found that this parameter was not restricted to the MoPub application, so it could point anywhere on the web. The same parameter also accepted javascript: URIs, which turned the redirect into a script execution primitive.

The report was filed against the X / xAI program on HackerOne by jackb898, disclosed on 24 September 2019, and paid a bounty of 1540.00 USD. The weakness is classified as an open redirect.

Setup

No special accounts, roles, tools or versions are described. The only precondition visible in the report is a working login on MoPub: the redirect fires after the user authenticates.

Finding it

The login URL carries the destination in a query parameter named next:

HTTP
https://app.mopub.com/login?next=https://google.com

Changing the value of next to an arbitrary URL and then logging in sends the browser to that URL. That is the open redirect. The more interesting part is that the parameter does not filter the URI scheme, so a javascript: URI is accepted as well. A javascript: URI in a redirect position means the browser executes the script in the context of the page that issued the redirect, which is the XSS.

Exploitation

Step 1: Start from the legitimate login URL

The researcher began with the normal form of the URL, where next points at an external site:

HTTP
https://app.mopub.com/login?next=https://google.com

Here next is the post-login destination. Nothing else in the URL is modified.

Step 2: Replace the destination

Change https://google.com to whatever URL the attacker wants the victim to land on. The report does not restrict this to http or https; the value is used as given.

Step 3: Visit the URL and log in

The victim opens the crafted link and completes the MoPub login. The redirect is only triggered after authentication, so the victim must actually sign in for the payload to fire.

Step 4: Observe the redirect

After login the browser is sent to the site named in next. With an ordinary URL this is a plain open redirect. With a javascript: URI it becomes script execution.

Proof of concept

The researcher demonstrated the XSS with the following value for next:

Text
javascript:alert("proof of concept")
d075ed6487c103b8c497250d385fe75f.mp4 From the original on HackerOne

The video is the researcher's proof of concept using the URL javascript:alert("proof of concept").

Root cause

The application takes the next parameter and uses it as the redirect target without validating it. Two checks are missing, and the report's summary names both: the destination is not restricted to the MoPub application, and the URI scheme is not filtered, so javascript: passes through. The report names both gaps: the destination is not restricted to the MoPub application, and the URI scheme is not filtered, so javascript: passes through. The report does not describe the server-side code, so the exact location of the missing validation is not stated.

Impact

The researcher lists phishing and cookie jacking as the main uses. Cookie jacking and other XSS vectors are possible because javascript: URIs are accepted. The report also notes that URL encoding can be used to hide the destination the victim is being redirected to, so the link does not visibly advertise where it goes. All of this requires the victim to visit the crafted login URL and complete the login.

Fix

The report does not describe the fix that was applied. Based on the two gaps it identifies, the redirect target should be validated against an allowlist of permitted destinations within the MoPub application, and the scheme should be restricted so that only http and https are accepted, rejecting javascript: and similar schemes.

Variants to test

  1. Try other schemes in a redirect parameter: javascript:, data:, vbscript: where relevant. A positive result is the browser executing the payload or rendering attacker-controlled content after the redirect.
  2. Try scheme-relative and encoded forms, such as a URL-encoded javascript: value, to see whether a naive filter is bypassed. A positive result is the payload firing despite the filter.
  3. Try destinations that look like the target's own domain but are not, for example a subdomain-style trick or a path that resolves elsewhere. A positive result is the browser leaving the intended origin.
  4. Test the same next-style parameter on other authentication flows (password reset, SSO callbacks, logout). A positive result is a redirect to an external site after the flow completes.

Hunting notes

Login and authentication pages are the natural home for this bug: any parameter that names a post-login destination is a candidate, and next, return, redirect and continue are common names. The signal during recon is a login URL that carries a full URL as a parameter value; if the value is echoed into a redirect after authentication, the parameter is worth testing with an external URL and then with a javascript: URI. The researcher showed both the redirect to an arbitrary site and the javascript: URI, which the report says leads to XSS.

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

What happened, in plain words

Its login page lives at app.mopub.com. Like many login pages, it has a small piece of information attached to the address: a parameter called next. A parameter is a named value you add to the end of a web address after a question mark, and it is how a website passes small pieces of information to itself. The next parameter tells MoPub where to send you after you have signed in.

The idea behind next is helpful. Imagine you try to open a private page while logged out. The site sends you to the login page and remembers where you were going, so that after you sign in it can take you back there. That is what next is for.

The researcher found that MoPub did not restrict the value of next to the MoPub application. You could put any web address in it, and after logging in the browser would go there. That is called an open redirect: the site will happily forward you to anywhere on the internet. The researcher also found that the value was not limited to ordinary web addresses. It accepted a javascript: address too, and a javascript: address in a redirect position makes the browser run the code inside it. That turns the redirect into cross-site scripting, usually shortened to XSS: a way to make a victim's browser run code written by an attacker.

The report was filed on HackerOne, a platform where security researchers report bugs to companies, against the X / xAI program. The researcher is jackb898, it was disclosed on 24 September 2019, and it paid a bounty of 1540.00 USD. The weakness is classified as an open redirect.

Context

Let us unpack the pieces before looking at the steps.

A login page is the form where you type your username and password. After the site confirms who you are, it usually sends you somewhere else, for example your dashboard. The place it sends you is a decision the site makes, and sometimes the site lets the address itself say where to go.

A parameter is the part of a web address after the ?. In https://example.com/search?q=cats, the parameter is named q and its value is cats. Parameters are visible to anyone who looks at the address bar, and anyone can edit them before pressing Enter. That is exactly why they are interesting to an attacker: if the site trusts a value that the visitor controls, the visitor can change the site's behaviour.

A redirect is when a website answers your request by telling the browser "not here, go to this other address instead". It is like a receptionist pointing you to a different office. An open redirect is a redirect where the destination is not checked, so it can point anywhere, including a site the attacker controls.

A URI scheme is the first word of an address, before the colon. https:// means a normal encrypted web page. javascript: is a special scheme that tells the browser "run the code that follows as JavaScript", the programming language that web pages use. A browser that is told to navigate to a javascript: address does not load a page; it executes the code.

XSS (cross-site scripting) means getting code to run in another user's browser as if the trusted site had written it. The dangerous part is the context: the code runs with the trust of the page that triggered it, so it can read things that page can see.

Cookie jacking is a related idea. A cookie is a small piece of data a website stores in your browser so it can recognise you on the next request, a bit like a cloakroom ticket that proves which coat is yours. If an attacker can run code in the right context, they may be able to get at that ticket and act as you. The report names cookie jacking as a possible use of the bug but does not go into detail.

Phishing is tricking someone into believing a link or page is genuine so they hand over information or follow instructions. A link that starts on a real MoPub login page looks far more believable than a link to a random domain.

Setup

The report describes no special accounts, roles, tools or software versions. The only precondition is a working login on MoPub, because the redirect only happens after the user signs in.

Finding it

The login address carries the destination in the next parameter:

HTTP
https://app.mopub.com/login?next=https://google.com

Reading this line from left to right: https://app.mopub.com/login is the real MoPub login page. The ? starts the parameters. next= names the parameter, and https://google.com is its value, meaning "after login, send me to Google".

If you change the value of next to any address you like and then log in, the browser ends up at that address. That is the open redirect. The more serious part is that the parameter does not check the scheme, so a javascript: address is accepted too. When a redirect points at a javascript: address, the browser runs the script in the context of the page that issued the redirect, and that is the XSS.

Exploitation

Step 1: Start from the legitimate login URL

The researcher began with the normal form of the address, where next points at an outside site:

HTTP
https://app.mopub.com/login?next=https://google.com

Here next is simply the place to go after signing in. Nothing else in the address is changed.

Step 2: Replace the destination

Change https://google.com to whatever address the attacker wants the victim to land on. The report does not limit this to http or https; whatever value is supplied is used as given. This is the heart of the bug: the site takes a value the visitor controls and uses it without checking it.

Step 3: Visit the URL and log in

The victim opens the crafted link and completes the MoPub login. The redirect only fires after authentication, so the victim has to actually sign in for the payload to run.

Step 4: Observe the redirect

After login the browser is sent to the address named in next. With an ordinary address that is a plain open redirect. With a javascript: address it becomes script execution.

Proof of concept

The researcher demonstrated the XSS with this value for next:

Text
javascript:alert("proof of concept")

Breaking it down: javascript: tells the browser that what follows is code, not a web address. alert(...) is a built-in browser function that pops up a small dialog box with a message. The text inside the quotes, proof of concept, is the message shown. So the whole value means "run a command that shows a popup saying proof of concept". A popup is harmless in itself; it is used here as visible proof that the browser ran the researcher's code, which is the definition of XSS.

d075ed6487c103b8c497250d385fe75f.mp4 From the original on HackerOne

The video is the researcher's proof of concept using the URL javascript:alert("proof of concept"). In everyday terms, the code is not running in a stranger's empty room; it is running inside the building it was let into.

Root cause

The application takes the next parameter and uses it as the redirect target without validating it. Two checks are missing, and the report's summary names both: the destination is not restricted to the MoPub application, and the scheme is not filtered, so javascript: gets through. The report names both gaps: the destination is not restricted to the MoPub application, and the scheme is not filtered, so javascript: gets through. The report does not describe the server-side code, so the exact place where the validation is missing is not stated.

A useful comparison: a receptionist who will point you to any office in the building is one problem. A receptionist who will also hand you the master key when you ask nicely is a much bigger one. The missing destination check is the first problem; the missing scheme check is the second.

Impact

The researcher lists phishing and cookie jacking as the main uses. Cookie jacking and other XSS vectors are possible because javascript: addresses are accepted. The report also notes that URL encoding can be used to hide the destination the victim is being redirected to, so the link does not visibly advertise where it goes. URL encoding is a way of writing characters in an address as codes, for example replacing a character with a percent sign and two digits, so the address still works but reads differently to a person glancing at it. All of this requires the victim to visit the crafted login address and complete the login.

Fix

The report does not describe the fix that was applied. Based on the two gaps it identifies, the redirect target should be validated against an allowlist of permitted destinations within the MoPub application, and the scheme should be restricted so that only http and https are accepted, rejecting javascript: and similar schemes. An allowlist is the opposite of a blocklist: instead of trying to name everything bad and forbid it, you name everything good and permit only that.

Variants to test

  1. Try other schemes in a redirect parameter: javascript:, data:, vbscript: where relevant. A positive result is the browser executing the payload or rendering attacker-controlled content after the redirect.
  2. Try scheme-relative and encoded forms, such as a URL-encoded javascript: value, to see whether a naive filter is bypassed. A positive result is the payload firing despite the filter.
  3. Try destinations that look like the target's own domain but are not, for example a subdomain-style trick or a path that resolves elsewhere. A positive result is the browser leaving the intended origin.
  4. Test the same next-style parameter on other authentication flows (password reset, SSO callbacks, logout). A positive result is a redirect to an external site after the flow completes.

Hunting notes

Login and authentication pages are the natural home for this bug. Any parameter that names a post-login destination is a candidate, and next, return, redirect and continue are common names. The signal during recon is a login address that carries a full URL as a parameter value. If the value is echoed into a redirect after authentication, the parameter is worth testing with an external address and then with a javascript: address. The researcher showed both the redirect to an arbitrary site and the javascript: address, which the report says leads to XSS.

Glossary

  • Parameter: a named value attached to a web address after a ?, used to pass small pieces of information to the site.
  • Query string: the part of an address from the ? onwards, containing one or more parameters.
  • Redirect: a response from a website that tells the browser to go to a different address instead.
  • Open redirect: a redirect whose destination is not checked, so it can point to any site.
  • URI scheme: the first part of an address before the colon, such as https or javascript, which tells the browser how to handle it.
  • javascript: URI: an address that makes the browser run the code that follows as JavaScript instead of loading a page.
  • XSS (cross-site scripting): getting code to run in another user's browser in the context of a trusted site.
  • Cookie: a small piece of data stored in the browser by a site so it can recognise the user on later requests.
  • Cookie jacking: using access to a user's cookie to act as that user.
  • Phishing: tricking someone into trusting a link or page so they follow instructions or give something away.
  • URL encoding: writing characters in an address as codes, such as a percent sign and two digits, so the address still works but reads differently.
  • Allowlist: a list of things that are permitted, with everything else rejected.
  • Blocklist: a list of things that are forbidden, with everything else permitted.
  • Bounty: a payment a company makes to a researcher who reports a valid security bug.
  • HackerOne: a platform where researchers report security bugs to companies and track the reports.
  • Disclosure: the point at which a bug report is made public.
  • Recon: the early stage of security testing where you look around a target to find things worth testing.
  • SSO: single sign-on, a login flow where one service trusts another to confirm who you are.

More by jackb898

View all

9 more disclosed reports, best first.

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.