Skip to content
XSS Write-up Beginner

Managed Apps and music a tale of two XSSes in Google play

Two cross-site scripting flaws existed in Google Play: a reflected XSS via a JavaScript URI in the 'continue' parameter of a terms-of-service page, and a persistent XSS in Play Music's search history triggered by a crafted URL. An attacker could execute arbitrary JavaScript in a victim's browser, potentially leading to account compromise or data theft.

Yasin Soliman Follow

Published on ysx.me.uk

I've been working hard on Google's Vulnerability Reward Program over the past few weeks, partly inspired by an enjoyable experience with Capture The Flag. After hinting at a VRP writeup release back in June, I'm excited to share a pair of XSS bugs on the Google Play platform (one of Google's Category Two "Highly…

Yasin Soliman (@SecurityYasin), on ysx.me.uk

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

Context

Google Play is one of Google's Category Two "Highly Sensitive" web properties, and the two bugs described here both live on the Play platform. The first is in Managed Google Play, which the report describes as "the app management platform and enterprise marketplace for Android [...] an admin can accept app permissions, approve apps for distribution on user devices, purchase apps in bulk, and more." The second is in Google Play Music, where a member's Recent Searches history is stored and rendered back to them.

Both findings are cross-site scripting. The first is reflected, delivered through a Terms of Service interstitial. The second is persistent, delivered through a crafted listen URL that plants a payload in the victim's search history.

Setup

The researcher had been working on Google's Vulnerability Reward Program over the preceding weeks, partly motivated by a Capture The Flag experience. The write-up was hinted at publicly in June before release.

For the Managed Apps bug, the precondition is access to the Managed Play Store. The researcher reached it with a personal Google Account in two ways:

  1. Having access to an educational institution account with the Managed portal enabled, for instance as a G Suite user or administrator.
  2. Registering for Android Management Experience, a platform that lets users "test enterprise features" by setting up an organisation with their personal Google account.

The researcher had previously explored the Management Experience and set up an organisation, so the personal account was cleared to click through the Terms and reproduce the bug. Testing was done in the latest stable Chrome build at the time.

For the Play Music bug, the precondition is simply that the victim is a Play Music member who can be induced to open a crafted URL.

Finding it

The researcher's stated method is focused research across a range of disciplines, reading The Keyword to keep up with new features and early access opportunities, and combining that with open-source intelligence. The resources named as useful for maximising in-scope opportunities are:

  • Bughunter University
  • The list of active Google products
  • The Security and Developer blogs
  • G Suite Update Alerts and What's New in G Suite

On the Managed Apps side, it was the researcher's first visit to the site. After pre-authenticating with a personal Google Account, the site presented a Terms of Service interstitial. A continue parameter in the URL is what drew attention: open redirection in its basic form is explicitly ineligible for VRP submission, so the interesting question was what else that parameter would accept.

On the Play Music side, the entry point is the listen URL and the #/sr/ fragment that corresponds to search results, which is where Recent Searches are recorded.

Exploitation

Step 1: JavaScript URI in the ToS continue parameter

The interstitial URL takes a continue parameter. Supplying a javascript: URI in that parameter produced reflected XSS. The proof of concept, as tested in the latest stable Chrome build, is:

Text
https://play.google.com/schools/termsofservice?continue=javascript:confirm(document.domain)

The continue parameter carried a javascript: URI, and the payload confirm(document.domain) ran in the origin of the page once the checkbox was marked and "Accept" was selected. Here its value is a javascript: URI, and the payload confirm(document.domain) runs in the origin of the page once the checkbox is marked and "Accept" is selected. The report notes that the payload triggered after marking the checkbox and selecting "Accept", not on page load.

Step 2: Understand the preconditions

Analysing the pre-exploitation process produced two conclusions:

  1. The Terms of Service can only be accepted once, so this is a "one-shot" exploit.
  2. The user must have access to the Managed Play Store.

The second point raised the question of how a personal Google Account could reach the Managed Apps portal at all. The answer is the two sub-conditions listed in Setup: an educational institution account with the Managed portal enabled, or an organisation created through Android Management Experience. The researcher's own account qualified through the second route.

Step 3: Plant a payload in Recent Searches

For Play Music, the crafted URL is a listen URL whose fragment carries the search-results route and a payload. The decoded proof of concept is:

Text
https://play.google.com/music/listen?u=0#/sr/'\"><img src=x onerror=confirm(document.domain)>

The crafted URL carries the payload in its fragment. The payload injects an img element with onerror=confirm(document.domain). When a Play Music member opens this URL, the payload is written into that user's Recent Searches history.

Step 4: Persistence

Once stored, the payload is invoked every time the victim accesses a page on Google Play Music, including the homepage, with no additional interaction required. That is what makes this a persistent XSS rather than a one-off reflection.

Root cause

In the Managed Apps case, the continue parameter was reflected into a context where a javascript: URI was accepted and executed when the user completed the interstitial. The report does not describe the server-side handling beyond the observable behaviour.

In the Play Music case, values committed to Recent Search history were not sanitised before being rendered back into the app. The report states plainly that items committed to Recent Search history are now sanitised. The exact encoding or filtering that was missing is not described.

Impact

The Managed Apps bug gives script execution in the Google Play origin, demonstrated with confirm(document.domain). Its practical reach is limited by two conditions: the Terms of Service can only be accepted once, making it a one-shot exploit, and the victim must have access to the Managed Play Store, either through an educational institution account with the Managed portal enabled or through an organisation set up via Android Management Experience.

The Play Music bug is stronger from an attacker's perspective. A single crafted link, opened by a Play Music member, stores the payload in that member's Recent Searches, and from then on the payload runs on every page of Google Play Music the victim visits, including the homepage, without further interaction.

Fix

The report states that fix confirmation took place simultaneously at 2017-07-07 21:37 GMT. For Play Music it states specifically that items committed to Recent Search history are now sanitised. The report does not describe the change made to the Managed Apps interstitial.

  1. Other interstitial continue parameters. Find Terms of Service, consent and onboarding interstitials that carry a return URL, and try a javascript: URI in it. A positive result is the payload executing after the user completes the interstitial, in the target's origin.
  2. Fragment-routed search and history features. Look for hash routes such as #/sr/ that write user input into a stored history, then reload the app. A positive result is the payload firing again on later page loads, including the homepage, without the crafted URL being revisited.
  3. One-shot flows. Where a consent or setup step can only be completed once, check whether the payload fires on the completion action rather than on load, and account for that in the reproduction steps.
  4. Low-privilege entry into enterprise portals. Check whether a personal account can be granted access to an enterprise console through a self-service trial or experience programme, then retest the same endpoints from that account.

Research timeline

All timestamps are GMT.

XSS by Interstitial Injection: Managed Apps

  • 2017-06-26 18:21: bug reported
  • 2017-06-27 13:48: triaged
  • 2017-06-28 14:42: "nice catch!" (validated)

XSS by Crafted URL with Persistence: Play Music

  • 2017-07-01 18:51: bug reported
  • 2017-07-03 11:22: triaged
  • 2017-07-03 22:19: "nice catch!" (validated)

Fix confirmation took place simultaneously at 2017-07-07 21:37. The researcher credits Eduardo, Maciej and the whole VRP Security Team for the handling of both reports.

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

What happened, in plain words

A security researcher found two bugs in Google Play, Google's store for Android apps, music and other content. Both bugs belong to one family called cross-site scripting, usually shortened to XSS. In plain terms, XSS means that a website can be tricked into running small pieces of code that an attacker supplied, as if the site itself had written them. The code then runs with the site's own permissions, which is why it matters.

The first bug was in Managed Google Play, the part of Play that companies and schools use to hand out apps to their staff or students. A link with a special value in it made the page run code after the user accepted a Terms of Service screen. The second bug was in Google Play Music. A crafted link planted a small piece of code in the victim's search history, and from then on that code ran every time the victim opened Play Music, including the homepage.

The researcher reported both through Google's Vulnerability Reward Program, the scheme that pays people for finding and reporting security bugs. Fix confirmation for both took place on 7 July 2017.

Background: what the researcher was doing

The researcher had spent the preceding weeks working on Google's Vulnerability Reward Program, partly inspired by taking part in a Capture The Flag event. Capture The Flag, or CTF, is a friendly competition where teams solve security puzzles to find hidden flags. The researcher had hinted publicly in June that a write-up about the reward program was coming.

A quick word on method. The researcher says that working across several disciplines, they often read The Keyword, Google's official blog, to keep up with new features and early access opportunities. Focused research, combining that reading with open-source intelligence, is described as a good way to maximise the number of in-scope hunting opportunities. Open-source intelligence here simply means information that is publicly available, such as blogs, documentation and product pages. The resources named as useful are:

  • Bughunter University, Google's own collection of guidance for bug hunters
  • The list of active Google products
  • The Security and Developer blogs
  • G Suite Update Alerts and What's New in G Suite

Why does this matter for a beginner? Because knowing which products exist, and which are new or in early access, tells you where fresh code is likely to be and where testing is allowed. The reward program only pays for bugs in properties it lists as in scope, so reading the rules and the product list first saves time.

The two targets

Google Play is described in the report as one of Google's Category Two "Highly Sensitive" web properties.

Managed Google Play

The report quotes the product description: Managed Google Play is "the app management platform and enterprise marketplace for Android [...] an admin can accept app permissions, approve apps for distribution on user devices, purchase apps in bulk, and more." In everyday terms, it is the admin console a company or school uses to decide which apps its people may install, and to buy apps in bulk. An admin is the person with the management rights.

Google Play Music

Google Play Music was Google's music service. The relevant feature here is Recent Searches: the list of things a member has searched for, which the service stores and shows back to them later. Storing something and showing it again later is the key detail for the second bug.

The vulnerability class: XSS in one minute

A web page is built from text that a browser reads and turns into what you see. Some of that text is instructions: it tells the browser to run a script, to load an image, to follow a link. Cross-site scripting happens when a site takes text that came from outside, such as something in a URL or something a user typed, and puts it into the page without neutralising it. The browser cannot tell that the text was not written by the site, so it obeys it.

A simple comparison: imagine a noticeboard where visitors can leave notes, and the office clerk copies every note onto official letterhead before pinning it up. If a visitor writes "pay the bearer 100 pounds" on their note, it now appears on official letterhead and looks like an instruction from the office. XSS is the web version of that: attacker text ends up on the site's own letterhead, and the browser treats it as the site's word.

There are two flavours in this report:

  • Reflected XSS: the malicious text travels in the link itself and is echoed back into the page once. The victim has to open the crafted link.
  • Persistent XSS, also called stored XSS: the malicious text is saved by the site, for example in a history list, and shown again on later visits. The victim only has to open the crafted link once, and the code keeps running afterwards.

Bug 1: XSS by Interstitial Injection in Managed Apps

What an interstitial is

An interstitial is a page that stands between you and what you asked for, usually to make you accept terms or confirm a choice. You have seen them: the cookie banners, the "we have updated our terms" screens, the "continue to the site" pages. The word just means "in between".

The first visit and the continue parameter

It was the researcher's first time on the Managed Apps site. After signing in beforehand with a personal Google Account, the site showed a Terms of Service interstitial. Signing in beforehand is what the report calls pre-authenticating: the researcher was already logged in, so the site went straight to the terms screen.

A parameter in the URL caught the researcher's eye: continue. A URL parameter is the part after a question mark, made of a name, an equals sign and a value, like ?colour=blue. Websites use parameters to carry small pieces of information between pages.

Why did that matter? Because a parameter that holds an address is a classic place to look for an open redirect, a bug where a site will send you to any address you name, including a malicious one. The report notes that open redirection in its basic form is explicitly ineligible for the reward program, so a plain redirect would not have counted. The interesting question was therefore what else the parameter would accept.

The payload

By putting a JavaScript URI into the parameter, the researcher achieved reflected XSS. A JavaScript URI is a link whose address starts with javascript: instead of https:. When a browser follows such a link, it does not fetch a page; it runs the text after the colon as code. It is like a note that says "instead of going to this room, do this instead".

The proof of concept, tested in the latest stable Chrome build at the time, was:

Text
https://play.google.com/schools/termsofservice?continue=javascript:confirm(document.domain)

Line by line, in plain words:

  • https://play.google.com is Google Play's address.
  • /schools/termsofservice is the page that shows the Terms of Service screen, here under a schools path.
  • ?continue= starts the parameter named continue, whose value follows.
  • javascript:confirm(document.domain) is the value. javascript: tells the browser to run what follows as code. confirm(...) opens a small pop-up box with an OK button. document.domain is the address of the page the code is running on. So the pop-up shows which site the code is running as, which is the standard way to demonstrate that script really executed in the target's own context.

The report is specific about timing: the payload triggered after marking the checkbox and selecting "Accept", not when the page loaded. That makes sense given what the parameter is for. Because the destination was a JavaScript URI, the browser ran the code instead of navigating.

Two conclusions from studying the preconditions

Analysing the process before exploitation led to two conclusions:

  1. The Terms of Service can only be accepted once, so this is a "one-shot" exploit.
  2. The user must have access to the Managed Play Store. The bug only exists for people who can reach the Managed Apps portal in the first place.

The second point raised an obvious question: how did a personal Google Account get into the Managed Apps portal at all? The report gives two distinct sub-conditions in which a user could come into contact with the proof of concept:

  • Having access to an educational institution account with the Managed portal enabled, for instance as a G Suite user or administrator. G Suite is Google's set of workplace tools for organisations; an administrator is someone who manages the organisation's accounts.
  • Alternatively, registering for Android Management Experience, a platform that lets users "test enterprise features" by setting up an organisation with their personal Google account.

The researcher had previously explored the Management Experience and set up an organisation, so the personal account was cleared to click through the Terms and reproduce the bug. The researcher had previously set up an organisation through the Management Experience, so the personal account was cleared to click through the Terms.

Bug 2: XSS by Crafted URL with Persistence in Play Music

The idea

The second bug was described by the researcher as interesting because it featured persistence, with a straightforward attack scenario. A Play Music member opens a crafted listen URL, and that URL injects a code payload into the member's Recent Searches history. From then on, the payload runs whenever the app loads.

The payload

The decoded proof of concept is:

Text
https://play.google.com/music/listen?u=0#/sr/'\"><img src=x onerror=confirm(document.domain)>

Line by line, in plain words:

  • https://play.google.com/music/listen is the Play Music player page.
  • ?u=0 is a parameter named u with the value 0. The report does not explain what it selects.
  • #/sr/ is the fragment. The fragment is the part of a URL after the #. Browsers do not send it to the server; the page's own code reads it and decides what to show.
  • '\"> is the part that breaks out.
  • <img src=x onerror=confirm(document.domain)> is an image tag whose address is x, which does not exist. When an image fails to load, the browser fires an event called onerror, and the code attached to that event runs. Here it is the same confirm(document.domain) pop-up as before, proving script execution on the Play Music origin.

Why an image that fails on purpose? Because it is a compact way to get code to run without needing the user to click anything. The browser tries to load the picture, fails, and runs the handler. The comparison is a smoke alarm wired to a broken fuse: the failure itself is what triggers the alarm.

Persistence

When a Play Music member opens this URL, the payload is written into that user's Recent Searches history. As the researcher noted in the report to the security team, the victim then invokes the malicious payload every time they access a page on Google Play Music, including the homepage, with no additional interaction required. That is what makes it persistent rather than a one-off reflection.

The report also states that items committed to Recent Search history are now sanitised. Sanitising means cleaning input so that characters with special meaning in HTML are treated as plain text rather than as instructions. The report does not describe the exact encoding or filtering that was missing.

Why the bugs worked

In the Managed Apps case, the continue parameter was reflected into a place where a JavaScript URI was accepted and executed when the user completed the interstitial.

In the Play Music case, values committed to Recent Search history were not sanitised before being rendered back into the app. The report states plainly that those items are now sanitised.

Impact

The Managed Apps bug gives script execution in the Google Play origin, demonstrated with confirm(document.domain). Its practical reach is limited by two conditions: the Terms of Service can only be accepted once, making it a one-shot exploit, and the victim must have access to the Managed Play Store, either through an educational institution account with the Managed portal enabled or through an organisation set up via Android Management Experience.

The Play Music bug is stronger from an attacker's point of view. A single crafted link, opened by a Play Music member, stores the payload in that member's Recent Searches, and from then on the payload runs on every page of Google Play Music the victim visits, including the homepage, without further interaction.

The fix

The report states that fix confirmation took place simultaneously at 2017-07-07 21:37 GMT. For Play Music it states specifically that items committed to Recent Search history are now sanitised.

These are the follow-up ideas the report lists for anyone hunting similar bugs:

  1. Other interstitial continue parameters. Find Terms of Service, consent and onboarding interstitials that carry a return URL, and try a JavaScript URI in it. A positive result is the payload executing after the user completes the interstitial, in the target's origin.
  2. Fragment-routed search and history features. Look for hash routes such as #/sr/ that write user input into a stored history, then reload the app. A positive result is the payload firing again on later page loads, including the homepage, without the crafted URL being revisited.
  3. One-shot flows. Where a consent or setup step can only be completed once, check whether the payload fires on the completion action rather than on load, and account for that in the reproduction steps.
  4. Low-privilege entry into enterprise portals. Check whether a personal account can be granted access to an enterprise console through a self-service trial or experience programme, then retest the same endpoints from that account.

Research timeline

All timestamps are GMT.

XSS by Interstitial Injection: Managed Apps

  • 2017-06-26 18:21: bug reported
  • 2017-06-27 13:48: triaged
  • 2017-06-28 14:42: "nice catch!" (validated)

XSS by Crafted URL with Persistence: Play Music

  • 2017-07-01 18:51: bug reported
  • 2017-07-03 11:22: triaged
  • 2017-07-03 22:19: "nice catch!" (validated)

Fix confirmation took place simultaneously at 2017-07-07 21:37. The researcher credits Eduardo, Maciej and the whole VRP Security Team for the handling of both reports.

Glossary

  • Admin: a person with management rights over an organisation's accounts and apps.
  • Android Management Experience: a Google platform that lets users "test enterprise features" by setting up an organisation with their personal Google account.
  • Capture The Flag (CTF): a security competition where teams solve puzzles to find hidden flags.
  • Category Two "Highly Sensitive": the reward program's grouping for web properties where bugs are treated as especially serious.
  • continue parameter: a URL parameter that usually carries the address to return to after a step such as accepting terms.
  • Fragment: the part of a URL after the #, read by the page's own code rather than sent to the server.
  • G Suite: Google's set of workplace tools for organisations.
  • Interstitial: a page shown between you and what you asked for, such as a terms or consent screen.
  • JavaScript URI: a link starting with javascript: that runs the text after the colon as code instead of loading a page.
  • Managed Google Play: "the app management platform and enterprise marketplace for Android", used by admins to approve, distribute and buy apps.
  • Open redirect: a bug where a site will send a visitor to any address named in a parameter, including a malicious one.
  • Open-source intelligence: information gathered from publicly available sources such as blogs and documentation.
  • Parameter: a name and value pair in a URL after the question mark, used to pass small pieces of information between pages.
  • Payload: the piece of code an attacker wants the target to run.
  • Persistent XSS (stored XSS): XSS where the malicious text is saved by the site and shown again on later visits.
  • Pre-authenticating: signing in beforehand, so the site goes straight to the page you wanted.
  • Proof of concept (PoC): a minimal demonstration that a bug is real.
  • Reflected XSS: XSS where the malicious text travels in the link and is echoed back into the page once.
  • Sanitising: cleaning input so characters with special meaning in HTML are treated as plain text.
  • Triaged: reviewed by the security team and confirmed worth investigating.
  • Validated: confirmed by the security team as a real bug.
  • Vulnerability Reward Program (VRP): Google's scheme that pays people for finding and reporting security bugs.
  • onerror: an event that fires when something, such as an image, fails to load; code attached to it then runs.

More by Yasin Soliman

View all

6 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

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.