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.
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.
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
- Download an SVG file into the Cloud Shell environment.
- Click the SVG file in the editor's file navigator.
- Observe that the file opens in preview mode and is rendered as an image.
- Modify the SVG to include a script that shows the file's location.
- 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.