From listKeys to Glory: How We Achieved a Subscription Privilege Escalation and RCE by Abusing Azure Storage Account Keys
Azure Storage accounts use shared key authorization by default, and a user with the listKeys permission can retrieve those keys and gain full control over storage data. Because Function Apps store their source code in such storage accounts, an attacker can modify the code to steal the Function App's managed identity token and escalate privileges, potentially leading to remote code execution on virtual machines.
Published on orca.security
Here at Orca Security, our team of cloud researchers are continually pushing the cloud security limits to ensure that we cover the latest cloud security risks on our Orca Platform and find cloud infrastructure vulnerabilities before bad actors do.
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 design flaw is that Azure Storage shared key authorization is enabled by default and grants full access to storage data, and Function App source code is stored in such storage accounts, so anyone with listKeys permission can modify code and steal the Function App's managed identity.
Impact
An attacker could escalate privileges, move laterally, access critical business assets, and execute remote code on virtual machines; the text notes that Azure Activity Log does not record data-plane events by default, but these can be enabled in diagnostic settings.
What the attacker needed
Compromised user with listKeys permission; or leaked storage account keys; Function App with managed identity
The fix
Organizations should disable Azure Shared Key authorization and use Azure Active Directory authentication instead, and apply the principle of least privilege to avoid granting listKeys permission unnecessarily.
How it was found
- An attacker with listKeys permission lists all storage accounts and their keys.
- The attacker filters storage accounts that host Function App source code by looking for the host.json file.
- The attacker reads the Function App's source code to find functions that use a managed identity.
- The attacker modifies the function code to request and exfiltrate the managed identity's access token.
- The attacker uses the stolen token to list virtual machines and execute commands on them.
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 Storage accounts hold files and data. By default, they can be accessed with a secret key, and anyone who can list those keys gets full control. If a user account with permission to list keys is compromised, the attacker can read and change the files, including the code of Azure Functions, which are small programs that run in the cloud. By changing that code, the attacker can make the function reveal its own identity token, which can then be used to control other cloud resources.
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.