Azure Privilege Escalation via Cloud Shell
Azure Subscription Contributors have default read/write access to all storage accounts, including Cloud Shell storage files. By modifying these files, an attacker can execute commands in other users' Cloud Shell sessions, leading to cross-account command execution and privilege escalation.
blog.netspi.com
Published on blog.netspi.com
Technical / Cloud Pentesting
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
Root cause
Likely the default permission model grants all subscription Contributors read/write access to all storage accounts, including Cloud Shell file shares, without isolating each user's home directory.
Impact
An attacker with Contributor rights could execute commands as other users, potentially escalating privileges to Owner or Global Administrator, though Microsoft stated this is expected behaviour and not a vulnerability.
What the attacker needed
Compromised AzureAD account with Contributor role; Target user has a Cloud Shell instance
The fix
Microsoft should restrict default Contributor access to Cloud Shell storage or isolate each user's home directory; the report notes Microsoft considers this designed behaviour and has only expanded documentation.
How it was found
- Compromise an AzureAD account with Contributor rights to the subscription.
- Download the target user's Cloud Shell IMG file from the storage account.
- Mount the IMG file on a Linux machine.
- Append malicious commands to .bashrc and the PowerShell profile file.
- Unmount the IMG file and upload it back to the storage account, overwriting the original.
- Wait for the victim to launch a new Cloud Shell session, which executes the commands.
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.
In Azure, a 'Contributor' is a role that can manage resources but not grant access. Cloud Shell is a browser-based command line that saves your files in a storage account. The report shows that anyone with Contributor rights can access and change those saved files, so they can add commands that run the next time the victim opens Cloud Shell.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.