Skip to content
RCE Write-up Intermediate

Google Cloud Shell - Command Injection

The Google Cloud Shell terminal embedded the user-controlled 'project' parameter into a Python script without encoding, allowing an attacker to break out of a string and execute arbitrary Python code. This led to command injection and remote shell access.

Bugra Eskici Follow

Published on bugra.ninja

Hi, I’m bugra, and here is a write-up about my Google Bug Bounty report.

Bugra Eskici (@bugraeskici), on bugra.ninja

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 Cloud Shell instance, potentially leading to remote shell access and compromise of the environment.

What the attacker needed

Access to Google Cloud Shell

The fix

The vulnerability was fixed by properly encoding or sanitising the 'project' parameter before embedding it in the Python script.

How it was found

  1. Visit the Cloud Shell URL with a 'project' parameter.
  2. Change the 'show' parameter to 'ide' to get a different terminal view.
  3. Enter a value with an apostrophe in the 'project' parameter to cause a syntax error.
  4. Craft a value that closes the string and injects Python code, such as importing os and running a system command.
  5. Observe the command output in the terminal.

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.

Cloud Shell is a web-based terminal for managing Google Cloud. The 'project' parameter in the URL was inserted directly into a Python script that runs in the terminal. By adding special characters, an attacker could make the script run their own commands, like reading files or opening a remote shell.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.