Skip to content
XSS Write-up Intermediate

XSS vulnerability in Google Cloud Shell’s code editor through SVG files

The Google Cloud Shell code editor previewed SVG files inside an iframe whose sandbox settings allowed scripts and same-origin access, so an SVG containing a script would execute. An attacker who could get a user to open a malicious SVG in the editor could run code in the context of that user's Cloud Shell backend and potentially access their GCP resources.

Psi Follow

Published on ψ.fun

Google Cloud Shell is a product of the Google Cloud Platform (GCP) that provides a number of interesting features, such as an interactive shell environment and an integrated code editor, with the intent of making experimenting and administration of GCP products easier while requiring very little setup.

Psi, on ψ.fun

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could execute arbitrary commands on the victim's Cloud Shell virtual machine and potentially access their GCP resources, but the attack required tricking the user into opening a malicious SVG file.

What the attacker needed

Victim uses Google Cloud Shell; attacker can host a repository with a malicious SVG; victim clicks an 'Open in Cloud Shell' link; victim follows a tutorial to open the SVG

The fix

It was fixed by overriding the mini-browser's default sandbox options to an empty list, making the iframe fully restrictive.

How it was found

  1. Download an SVG file into the Cloud Shell environment.
  2. Click the SVG file in the editor's file navigator.
  3. Observe that the file opens in preview mode and is rendered as an image.
  4. Modify the SVG to include a script that shows the file's location.
  5. Open the modified SVG and confirm the script executes.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

SVG files are images, but they can also contain scripts. The code editor showed SVG files in a preview window that was not properly locked down, so those scripts ran. An attacker could use this to act as the victim inside their cloud environment.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Psi

View all

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