Making Clouds Rain :: Remote Code Execution in Microsoft Office 365
A cmdlet in Exchange Online accepted attacker-supplied policy template data and executed the embedded PowerShell commands, letting a tenant user run code as SYSTEM on Microsoft's cloud servers. The author bypassed two successive patches for the same flaw.
Published on srcincite.io
When I joined Qihoo’s 360 Vulcan Team, one of the things I had free rein over was having the ability to choose an area of security research that has a high impact. Since I enjoy web security research a lot I decided to target cloud based technologies.
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 policy template's command blocks were passed straight into a PowerShell pipeline without validating which cmdlets they contained.
Impact
An attacker with a suitable role could execute commands as SYSTEM on Microsoft's cloud mail servers and exfiltrate data over HTTP, potentially reaching millions of corporate mailboxes.
What the attacker needed
An Exchange Online account; the Data Loss Prevention role assigned; ability to upload a policy template
The fix
Microsoft patched it by validating the template's cmdlet parameters, but the author bypassed that patch and a second one, so the validation needed to be made robust.
How it was found
- Obtain an account with the Data Loss Prevention role in Exchange Online.
- Upload a crafted DLP policy template through the ECP policy upload page, or call the New-DlpPolicy cmdlet directly over PowerShell remoting.
- The server parses the template and runs the commands inside its command block.
- Read the command output and send it to an external server to confirm execution.
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.
Exchange Online lets administrators create data-loss-prevention policies by uploading a template file. That file can contain small scripts, and the server ran them without checking what they did, so whoever uploaded one could run their own commands on the mail server itself.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.