From Pwn2Own 2021: A New Attack Surface On Microsoft Exchange - Proxyshell!
A pre-authentication path confusion flaw in Exchange's frontend allowed an attacker to reach arbitrary backend URLs, and a backend PowerShell component trusted a user-supplied identity parameter, enabling impersonation of an Exchange administrator. The attacker could then use a mailbox export command to write a web shell and execute arbitrary commands on the server.
zerodayinitiative.com
Published on zerodayinitiative.com
Hi, I am Orange Tsai from DEVCORE Research Team. In this article, I will introduce the exploit chain we demonstrated at the Pwn2Own 2021.
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 frontend's URL normalisation for Explicit Logon requests did not properly validate the mailbox address, allowing path confusion, and the PowerShell backend trusted a user-controlled identity parameter when the authentication header was missing.
Impact
An unauthenticated attacker could execute arbitrary commands on the Exchange server, though Windows Defender blocked direct cmd.exe execution and a workaround was needed.
What the attacker needed
Network access to Exchange on port 443; Ability to send email to the target mailbox; No authentication required
The fix
Microsoft fixed all three vulnerabilities via patches released in April and May, and for the file-write issue it limited export file extensions to .pst, .eml, or .ost.
How it was found
- Deliver an encoded web shell to the targeted mailbox via SMTP or an external mail service.
- Rewrite the request URL to the EwsAutodiscoverProxyRequestHandler path to trigger the path confusion and reach the PowerShell backend.
- Insert the X-Rps-CAT parameter into the query string with the SID of an Exchange Admin to impersonate that admin.
- In the established PowerShell session, grant the Mailbox Import Export role to the attacker.
- Use New-MailboxExportRequest to export the mailbox containing the payload to the webroot, creating a web shell.
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.
This is a chain of three bugs in Microsoft Exchange, the software many companies use for email. The first bug lets an unauthenticated person trick the web-facing part of Exchange into talking to internal services it should not. The second bug lets that person pretend to be an administrator, and the third lets them write a file that runs code on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.