Skip to content
XSS Write-up Intermediate

Admin google.com reflected XSS

Brett Buerhaus Follow

Published on buer.haus

Bounty$5,000 View original

After learning about Google's bug bounty program, I decided to look for vulnerabilities on their most sensitive services. Finding a vulnerability on admin.google.com was challenging; I managed to find a simple, but interesting form of Cross-Site Scripting.

Brett Buerhaus (@bbuerhaus), on buer.haus

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

Context

admin.google.com is the administrative console for Google Apps. From it, a domain administrator configures permissions, users and the Google services enabled for a domain. The report notes that this is a feature used mainly by businesses, particularly those running Gmail on their own domain.

The vulnerable page is ServiceNotAllowed. It is shown when a user tries to reach a Google app service that has not been configured for their domain. The page presents a form that lets the user switch accounts and continue to the service they were trying to load. Selecting an account via the radio button on the page runs JavaScript that redirects the browser, and the destination URL comes from the user-supplied continue request parameter.

The researcher describes the result as a simple but interesting form of reflected Cross-Site Scripting.

Setup

Reproducing the page requires being logged into at least two accounts, because the account-switching form is what triggers the redirect. The report does not name specific tools, browser versions or a test domain beyond the ones appearing in the payloads.

Finding it

The continue parameter is a fairly common request variable in the Google login flow. The researcher went through pages that consume it looking for one that failed to validate the URL passed in. ServiceNotAllowed was the only page found where the value was not validated. Because the value is placed into a JavaScript redirect, supplying a javascript: URL as part of the continue value causes script to execute when the browser location is changed.

Exploitation

Step 1: Craft the URL

The proof of concept is a single URL against the admin console:

Text
 https://admin.google.com/mrzioto.com/ServiceNotAllowed?service=grandcentral&continue=javascript:alert(document.cookie);//

The URL targets ServiceNotAllowed with service=grandcentral and a continue value holding a javascript: URI. The value ends with //, a JavaScript comment marker.

Step 2: Trigger the redirect

When the page loads, it renders the account-switching form. Selecting an account via the radio button runs the page's own JavaScript, which sets window.location.href to the value taken from the selected radio input. That value is the attacker-controlled continue URL, so the browser navigates to a javascript: URI and the script runs in the origin of admin.google.com.

Step 3: Weaponise it against an admin

The researcher built a proof of concept in which a JavaScript payload pulls information from the Admin console, grabs a list of users, changes the password and removes security settings from the first user in the list. The report does not include that payload's code.

Root cause

The ServiceNotAllowed page takes the continue parameter and uses it as the destination of a client-side redirect without validating the URL. Other pages in the login flow that consume continue validate it; this one did not. Because the redirect is performed by assigning to window.location.href, a javascript: scheme in the value is executed rather than treated as a navigation target, and it executes in the admin.google.com origin. The report does not describe any server-side or browser-level defence that was present and bypassed; the validation was simply missing on this page.

Impact

The attack lets an attacker force a Google Apps admin to execute any request on the admin.google.com domain. The report lists what that makes possible, framed as forcing the admin to:

  • Create new users with any permission level, such as a super admin.
  • Disable security settings for individual accounts or for multiple domains, including removing two-factor authentication (2FA) from accounts.
  • Modify domain settings so they point to the attacker's domain or DNS, so that all incoming email to that domain is redirected to the attacker instead.
  • Hijack an account or email by resetting the password, disabling 2FA, and removing login challenges temporarily for 10 minutes.

The page requires the user to be logged into at least two accounts, since the account-switching form is what fires the redirect.

Fix

The timeline lists the fix as 9/18/14, after acknowledgement on 9/5/14.

Variants to test

  1. Enumerate every page that consumes a continue-style parameter and compare validation across them. A positive result is one page that accepts a javascript: value where its siblings reject it.
  2. Try scheme variations (javascript:, mixed case, whitespace or control characters before the scheme) against each consumer. A positive result is the browser executing the payload after the redirect.
  3. Look for redirect sinks that assign to window.location.href from a form input value rather than a server-rendered link. A positive result is a radio button or hidden field whose value reaches the location assignment unvalidated.
  4. Test whether a trailing comment (//) is needed to neutralise appended query data, and whether the page appends anything at all. A positive result is execution with or without the comment, which tells you how the URL is assembled.
  5. Check whether the same parameter is reflected into other contexts (HTML attributes, inline script) on the same page. A positive result is a second injection point that does not depend on the redirect.

Timeline

  • Discovered and reported: 9/1/14
  • Acknowledged: 9/5/14
  • Fixed: 9/18/14

The bounty was 5,000 USD.

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

Google runs a programme that pays people for finding security mistakes in its products. After reading about it, Brett Buerhaus decided to look at Google's most sensitive services, the ones where a mistake would matter most. One of those is admin.google.com, the control panel where a company manages its Google Apps setup. He found a way to make that page run code of his choosing inside a victim's browser. This kind of bug is called Cross-Site Scripting, or XSS for short, and the particular flavour here is reflected XSS: the malicious value travels in the link itself and is echoed back by the page.

The timeline lists discovery and report on 9/1/14, acknowledgement on 9/5/14 and fix on 9/18/14.

The product and the page

admin.google.com is the administrative console for Google Apps. From it, a domain administrator configures permissions, users and the Google services enabled for a domain. The report notes that this is a feature used mainly by businesses, particularly those running Gmail on their own domain. Think of it as the back office of a company's email and accounts: whoever holds the keys can create staff accounts, change security rules and redirect mail.

The vulnerable page is called ServiceNotAllowed. It appears when someone tries to reach a Google app service that has not been configured for their domain. Instead of a flat refusal, the page offers a form that lets the user switch accounts and continue to the service they were trying to load. Selecting an account with the radio button on the page runs JavaScript that redirects the browser, and the destination URL comes from a value supplied by the user in the continue request parameter.

A request parameter is the part of a web address after the ?, made of name and value pairs. When you search on a website and the address bar fills with ?q=something, q is the parameter and something is its value. The server, or in this case the page's own script, reads those values and acts on them.

The researcher describes the result as a simple but interesting form of reflected Cross-Site Scripting.

Setting up

Reproducing the page requires being logged into at least two accounts, because the account-switching form is what triggers the redirect. The report does not name specific tools, browser versions or a test domain beyond the ones appearing in the payloads.

Finding it

The continue parameter is a fairly common request variable in the Google login flow. It is the "where do you want to go next" instruction that login pages carry around, so that after signing in you land on the page you originally asked for. The researcher went through pages that consume it, looking for one that failed to check the URL passed in. ServiceNotAllowed was the only page found where the value was not validated.

Because the value is placed into a JavaScript redirect, supplying a javascript: URL as part of the continue value causes script to execute when the browser location is changed. A javascript: URL is a special kind of address: instead of pointing at a web page, it contains code, and a browser that is told to navigate to it runs that code instead. Normally a page should refuse to treat such a value as a destination, but this page did not.

Exploitation

Step 1: Craft the URL

The proof of concept is a single URL against the admin console:

Text
 https://admin.google.com/mrzioto.com/ServiceNotAllowed?service=grandcentral&continue=javascript:alert(document.cookie);//

Line by line, in plain words:

  • https://admin.google.com/ is the address of the admin console, the sensitive back office described above.
  • mrzioto.com/ appears in the path of the URL.
  • ServiceNotAllowed is the page that shows the account-switching form.
  • ? starts the list of parameters.
  • service=grandcentral is the service parameter used in the link.
  • & separates one parameter from the next.
  • continue=javascript:alert(document.cookie); is the important part. The continue parameter is supposed to hold the address to go to next, but here it holds a javascript: URL. alert(document.cookie) is a tiny piece of script that pops up a box showing the browser's cookies for the current site. A cookie is a small piece of data a website stores in your browser, often used to remember who you are; if an attacker can read it, they may be able to act as you. The ; ends that statement.
  • // at the end is a JavaScript comment marker, which makes the browser ignore the rest of the line.

Step 2: Trigger the redirect

When the page loads, it renders the account-switching form. Selecting an account via the radio button runs the page's own JavaScript, which sets window.location.href to the value taken from the selected radio input. window.location.href is simply the browser's current address; assigning to it is the scripted way of saying "go to this address now". That value is the attacker-controlled continue URL, so the browser navigates to a javascript: URI and the script runs in the origin of admin.google.com.

Origin is the combination of scheme, host and port that a browser uses to decide which site a piece of code belongs to, for example https://admin.google.com. Code running in that origin is treated as part of the admin console itself, with the same access as the console's own pages. That is why this matters: the script is not running on some random site, it is running as the admin console.

Step 3: Weaponise it against an admin

The researcher built a proof of concept in which a JavaScript payload pulls information from the Admin console, grabs a list of users, changes the password and removes security settings from the first user in the list. The report does not include that payload's code.

The page's own source

The report includes the relevant part of the page's source, which shows exactly how the value from the form ends up as the browser's destination:

HTML
<form action="" onsubmit="return onContinueClick(2);">
<ul>
	<li><input type="radio" value="javascript:alert(document.cookie);//?authuser=0" checked name="radioChoices" id="radioid0"><label for="radio0">[redacted]</label></li>
	<li><input type="radio" value="javascript:alert(document.cookie);//?authuser=0" checked name="radioChoices" id="radioid1"><label for="radio1">[redacted]</label></li>
</ul>
</form>

<script>
	function onContinueClick(accountCount) {
		var href;
		for (var i = 0; i < accountCount; i++) {
			if (document.getElementById('radioid' + i).checked) {
				href = document.getElementById('radioid' + i).value;
			}
		window.location.href = href;
		return false;
	}
	window.addEventListener("load", function() {
		document.getElementById("radioid0").focus();
	});
</script>

Line by line, in plain words:

  • <form action="" onsubmit="return onContinueClick(2);"> starts a form. action="" means it submits to the same address. onsubmit says: when this form is submitted, run the function onContinueClick with the number 2, and return false stops the browser doing its normal form submission.
  • <ul> opens an unordered list, the bulleted list of accounts.
  • Each <li> is one list item. Inside it, <input type="radio" ...> is a radio button, the round selector you click to pick one option. Its value is the string that will be used as the destination. Here that value is javascript:alert(document.cookie);//?authuser=0, the same trick as in the URL, with ?authuser=0 appended after the comment marker so it is ignored. checked means the button starts selected. name="radioChoices" groups the buttons, and id="radioid0" and id="radioid1" give each one a name the script can look up.
  • <label for="radio0">[redacted]</label> is the text shown next to the button. The two entries stand for the two logged-in accounts the page is offering to switch between.
  • </ul> and </form> close the list and the form.
  • <script> opens a block of JavaScript that the browser runs.
  • function onContinueClick(accountCount) { defines the function that the form calls. accountCount is how many accounts there are, here 2.
  • var href; declares an empty variable to hold the destination.
  • for (var i = 0; i < accountCount; i++) { is a loop that counts from 0 up to one less than the number of accounts, so it visits each radio button in turn.
  • if (document.getElementById('radioid' + i).checked) { asks the page for the button with the matching id and checks whether it is selected. 'radioid' + i glues the number onto the name, giving radioid0 then radioid1.
  • href = document.getElementById('radioid' + i).value; copies the selected button's value into href. This is the step where the attacker's text becomes the destination.
  • window.location.href = href; sends the browser to that value. If the value is a javascript: URL, the browser runs it as code in the page's origin.
  • return false; tells the form not to do a normal submission.
  • window.addEventListener("load", function() { waits until the page has finished loading.
  • document.getElementById("radioid0").focus(); puts the cursor on the first radio button, a small convenience so the user can pick with the keyboard.
  • The closing braces and </script> end the function and the script block.

Why it works: the root cause

The ServiceNotAllowed page takes the continue parameter and uses it as the destination of a client-side redirect without validating the URL. Other pages in the login flow that consume continue validate it; this one did not. Because the redirect is performed by assigning to window.location.href, a javascript: scheme in the value is executed rather than treated as a navigation target, and it executes in the admin.google.com origin. The report does not describe any server-side or browser-level defence that was present and bypassed; the validation was simply missing on this page.

A useful comparison: a redirect is like a receptionist who is told "send the next visitor to room 12". If the receptionist never checks that the instruction is a room number, someone can hand over an instruction that says "send the next visitor to the safe and open it". The page here was that receptionist.

Impact

The attack lets an attacker force a Google Apps admin to execute any request on the admin.google.com domain. The report lists what that makes possible, framed as forcing the admin to:

  • Create new users with any permission level, such as a super admin.
  • Disable security settings for individual accounts or for multiple domains, including removing two-factor authentication (2FA) from accounts.
  • Modify domain settings so they point to the attacker's domain or DNS, so that all incoming email to that domain is redirected to the attacker instead.
  • Hijack an account or email by resetting the password, disabling 2FA, and removing login challenges temporarily for 10 minutes.

Two-factor authentication, or 2FA, is a second proof of identity on top of a password, usually a code from a phone. Removing it makes an account much easier to break into. DNS is the system that translates a domain name into the server it points at; if an attacker controls where a domain points, they can receive its mail.

The page requires the user to be logged into at least two accounts, since the account-switching form is what fires the redirect.

The fix

The timeline lists the fix as 9/18/14, after acknowledgement on 9/5/14.

Variants to test

  1. Enumerate every page that consumes a continue-style parameter and compare validation across them. A positive result is one page that accepts a javascript: value where its siblings reject it.
  2. Try scheme variations (javascript:, mixed case, whitespace or control characters before the scheme) against each consumer. A positive result is the browser executing the payload after the redirect.
  3. Look for redirect sinks that assign to window.location.href from a form input value rather than a server-rendered link. A positive result is a radio button or hidden field whose value reaches the location assignment unvalidated.
  4. Test whether a trailing comment (//) is needed to neutralise appended query data, and whether the page appends anything at all. A positive result is execution with or without the comment, which tells you how the URL is assembled.
  5. Check whether the same parameter is reflected into other contexts (HTML attributes, inline script) on the same page. A positive result is a second injection point that does not depend on the redirect.

Timeline

  • Discovered and reported: 9/1/14
  • Acknowledged: 9/5/14
  • Fixed: 9/18/14

The bounty was 5,000 USD.

Glossary

  • Bug bounty programme: a scheme where a company pays researchers for reporting security flaws in its products.
  • Google Apps: Google's suite of business services, such as Gmail on a company's own domain, managed from an admin console.
  • Admin console: the web interface where a domain administrator manages users, permissions and services.
  • Domain: a name on the internet, such as example.com, that a company or person controls.
  • Cross-Site Scripting (XSS): a bug where an attacker gets their own code to run inside another website's pages, in that site's origin.
  • Reflected XSS: XSS where the malicious value travels in the request (for example in the URL) and is echoed back by the page, rather than being stored on the server.
  • Request parameter: a name and value pair in a URL after the ?, such as continue=....
  • continue parameter: a common login-flow value that says where to go after signing in or switching accounts.
  • javascript: URL: an address whose content is code rather than a page; a browser told to navigate to it runs the code.
  • Cookie: a small piece of data a site stores in your browser, often used to remember who you are.
  • Origin: the scheme, host and port of a page, such as https://admin.google.com; code in an origin is treated as belonging to that site.
  • window.location.href: the browser's current address; assigning to it navigates the browser.
  • Redirect: sending the browser from one address to another.
  • Validation: checking that a value is what it is supposed to be, and rejecting it otherwise.
  • Comment (//): in JavaScript, a marker that makes the rest of the line ignored.
  • Radio button: a round selector in a form that lets you pick one option from a group.
  • Payload: the piece of code or data an attacker uses to carry out the attack.
  • Two-factor authentication (2FA): a second proof of identity on top of a password, usually a code from a phone.
  • DNS: the system that maps domain names to the servers they point at.
  • Super admin: the highest permission level in an admin console, able to do anything in the domain.
  • Sink: a place in code where a value is used in a way that can be dangerous, such as assigning it to window.location.href.
  • Scheme: the first part of a URL, such as https: or javascript:, that says how to interpret the rest.
  • Bounty: the money paid for a valid report.

More by Brett Buerhaus

View all

8 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.