Skip to content
Access control Write-up Intermediate

Reverse Shell To Your Azure Vm As Local System User Or Root User

The Azure 'vm run-command' feature allows users with the Virtual Machine Contributor role to execute commands as SYSTEM or root on VMs. An attacker with this role could obtain a reverse shell or SSH access, leading to full control of the VM.

Nol White Hat Follow

Published on infosecwriteups.com

In this article, I will show you how you can use the Azure ‘vm run-command’ to get (reverse) shell access to your Azure virtual machines.

Nol White Hat, on infosecwriteups.com

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 with the Virtual Machine Contributor role could execute arbitrary commands as SYSTEM or root, leading to full compromise of the VM and potential lateral movement.

What the attacker needed

Azure account with Virtual Machine Contributor role; Target VM in Azure; Attacker machine with internet access

The fix

Review and restrict role assignments for the Azure 'Virtual Machine Contributor' role to ensure least privilege.

How it was found

  1. Install ngrok and Docker on the attacker machine.
  2. Register an ngrok account and obtain an authtoken.
  3. Install the Azure CLI Docker image and start a container.
  4. Log in to Azure with an account having the Virtual Machine Contributor role.
  5. List available VMs to identify targets.
  6. Use 'az vm run-command' to execute commands on the target VM, such as enabling PowerShell remoting or creating a user with sudo rights.

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.

Azure lets administrators run commands on virtual machines without logging in, which is meant for recovery. But if someone has the 'Virtual Machine Contributor' role, they can use this to run any command as the highest-privilege user (SYSTEM on Windows, root on Linux). This means they could take full control of the machine, even without a password or SSH key.

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.

More by Nol White Hat

View all

8 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.