TL;DR — ProxyShell is a chain of three Microsoft Exchange Server vulnerabilities — CVE-2021-34473, CVE-2021-34523 and CVE-2021-31207 — that together produce unauthenticated remote code execution on internet-facing Exchange. Discovered by Orange Tsai and demonstrated at Pwn2Own 2021, it became one of the most exploited server-side chains of the year. This article reconstructs each link: the Autodiscover-based SSRF/path-confusion, the PowerShell backend privilege confusion, and the arbitrary mailbox-export primitive that drops a web shell.
Executive Summary
Microsoft Exchange is a perennial top-tier target: it is internet-facing by necessity, it authenticates against Active Directory, and a compromise yields email — the connective tissue of an organisation — plus a foothold deep inside the network. ProxyShell, alongside its sibling ProxyLogon, defined the 2021 Exchange threat landscape.
ProxyShell is not one bug but a chain, and understanding it means understanding the Client Access Service (CAS) proxy architecture that all three bugs abuse. Exchange's front end accepts requests and proxies them to back-end services. The chain manipulates how that proxying happens — confusing the front end about who the user is and which back-end path the request reaches — to ultimately reach a privileged PowerShell endpoint and abuse a legitimate mailbox-export feature for code execution.
| CVE | Role in chain | Bug class |
|---|---|---|
| CVE-2021-34473 | Pre-auth path confusion (Autodiscover) | SSRF / ACL bypass |
| CVE-2021-34523 | Elevation in Exchange PowerShell backend | Privilege confusion |
| CVE-2021-31207 | Post-auth arbitrary file write | Arbitrary write via mailbox export |
The Architecture Being Abused
Exchange's front end is essentially a reverse proxy. A request to https://exchange/<path> is inspected by the CAS layer, which decides which back-end virtual directory and service should handle it, and forwards it — including a back-end authentication context. The proxy makes trust decisions based on the URL path and on internal headers.
flowchart LR
A["Internet client"] --> B["Front-End CAS<br/>(IIS reverse proxy)"]
B -->|"normal: authed user"| C["Mailbox / EWS / PowerShell<br/>back-end services"]
B -.->|"ProxyShell: confuse the<br/>path + identity"| D["PowerShell back-end<br/>as a privileged user"]
D --> E["New-MailboxExportRequest<br/>arbitrary file write"]
E --> F["Web shell on disk → RCE"]
style D fill:#2a0c14,stroke:#ef233c,color:#fee2e2
style F fill:#2a0c14,stroke:#ef233c,color:#fee2e2The chain's elegance is that each bug attacks a different trust assumption in this proxy: the path-routing logic, the back-end identity mapping, and the assumption that an authenticated PowerShell user can only write to safe locations.
Link 1 — CVE-2021-34473: Autodiscover Path Confusion
The first link is a pre-authentication flaw in how the Autodiscover endpoint handled URLs. Exchange exposes /autodiscover/autodiscover.json, and the front end's URL-normalisation logic could be tricked using a crafted `X-Rps-CAT`-adjacent path and an explicit logon/email parameter combined with path elements that the proxy stripped or rewrote inappropriately.
The practical effect: by appending a specially structured suffix to the Autodiscover URL, an attacker could make the front end route the request to an arbitrary back-end endpoint as if it were internal, bypassing the normal access-control checks. This is the SSRF/path-confusion primitive that gives the rest of the chain its reach.
POST /autodiscover/autodiscover.json?@evil.com/powershell?&Email=autodiscover/autodiscover.json%3F@evil.com HTTP/1.1Host: exchange.victim.comThe @-and-? trickery exploits the gap between how the proxy parses the URL for routing decisions and how the back end parses it for handling. The two parsers disagree, and that disagreement is the vulnerability — a textbook parser differential.
Link 2 — CVE-2021-34523: PowerShell Backend Elevation
Reaching the PowerShell back-end is not enough by itself; you need to be a privileged user there. CVE-2021-34523 is an elevation-of-privilege bug in the Exchange PowerShell back-end's handling of the user identity carried in the proxied request.
The back-end derived the acting user from a token/SID supplied in the proxied context. Because of the path confusion from Link 1, the attacker controls enough of that context to present themselves as a highly privileged account — effectively the SYSTEM/Exchange machine identity — to the PowerShell endpoint. The PowerShell back end, trusting the front end to have authenticated correctly, grants access.
sequenceDiagram
participant A as Attacker
participant FE as Front-End CAS
participant PS as PowerShell Back-End
A->>FE: Crafted Autodiscover URL (CVE-2021-34473)
FE->>PS: Proxied request, attacker-influenced identity
PS->>PS: Trust front-end identity (CVE-2021-34523)
Note over PS: Attacker now acts as privileged user
A->>PS: Run management cmdlets via remote PowerShellAt this point the attacker has authenticated, privileged access to Exchange's remote PowerShell — the same interface administrators use to manage the server. That is an enormous capability on its own; Link 3 turns it into code execution.
Link 3 — CVE-2021-31207: Arbitrary File Write via Mailbox Export
The final link abuses a legitimate administrative feature: New-MailboxExportRequest. This cmdlet exports a mailbox to a PST file at an administrator-specified path. It exists for backup and e-discovery.
The exploitation idea: the attacker controls the export's destination path and its content (by first writing a malicious payload into a mailbox draft/message). They point the export at the Exchange web root with an .aspx extension. The exported PST is technically a PST, but because PSTs are loosely structured and IIS will execute the .aspx, the attacker embeds a web shell in a message such that the exported file, when requested over the web, executes as ASP.NET.
# Conceptual flow (via privileged remote PowerShell from Link 2)New-ManagementRoleAssignment -Role "Mailbox Import Export" -User attacker# Seed a mailbox with a payload-bearing message, then:New-MailboxExportRequest -Mailbox attacker ` -FilePath "\\localhost\C$\inetpub\wwwroot\aspnet_client\shell.aspx"# The written file is reachable + executable via IIS → web shellThe result is a web shell written to a publicly reachable directory, executing with the privileges of the Exchange application pool. From there the operator has interactive command execution on the Exchange server, which is typically a high-value, AD-joined, internally trusted host.
The Full Chain End to End
flowchart TD
A["1. Unauthenticated request"] --> B["CVE-2021-34473<br/>Autodiscover path confusion<br/>→ reach back-end"]
B --> C["CVE-2021-34523<br/>PowerShell backend elevation<br/>→ act as privileged user"]
C --> D["Authenticated, privileged<br/>remote PowerShell"]
D --> E["CVE-2021-31207<br/>New-MailboxExportRequest<br/>arbitrary .aspx write"]
E --> F["Web shell in IIS web root"]
F --> G["Interactive RCE on Exchange<br/>(AD-joined, internal trust)"]
style B fill:#1a230c,stroke:#fca311,color:#fef3c7
style C fill:#1a230c,stroke:#fca311,color:#fef3c7
style E fill:#2a0c14,stroke:#ef233c,color:#fee2e2
style G fill:#2a0c14,stroke:#ef233c,color:#fee2e2Three bugs, three distinct trust assumptions defeated, ending in unauthenticated RCE. No single CVE is a full compromise; the composition is.
Post-Exploitation and Real-World Use
Once attackers held a web shell on Exchange, observed activity included:
- Persistence via additional web shells (China Chopper-style, often planted in
aspnet_clientorowa/auth), and scheduled tasks. - Credential theft from the host (LSASS) and from the Exchange environment.
- Mass mailbox exfiltration — the entire point for espionage actors.
- Ransomware deployment — multiple ransomware crews used ProxyShell for initial access during 2021.
The dwell time was often substantial because Exchange web shells blended into a noisy, complex application and because many organisations did not monitor Exchange's IIS logs closely.
ProxyShell vs ProxyLogon vs ProxyNotShell
ProxyShell is one of a family of Exchange chains discovered in the same era, all of which abuse the front-end/back-end proxy architecture. Confusing them is common, so it is worth disentangling them.
| Chain | CVEs | Auth required? | Core mechanism |
|---|---|---|---|
| ProxyLogon | CVE-2021-26855 (+26857/26858/27065) | No (pre-auth SSRF) | SSRF on front end → authenticated as Exchange → write file |
| ProxyShell | CVE-2021-34473/34523/31207 | No (pre-auth) | Autodiscover path confusion → PowerShell → mailbox export |
| ProxyNotShell | CVE-2022-41040 + CVE-2022-41082 | Yes (needs creds) | SSRF (Autodiscover) + PowerShell remoting RCE |
| ProxyToken | CVE-2021-33766 | No | Auth bypass via delegated SecurityToken handling |
The throughline across all four is the CAS proxy trust boundary — every one of them exploits the fact that the internet-facing front end makes routing and identity decisions that the back end then trusts. ProxyLogon (spring 2021) and ProxyShell (summer 2021) were both unauthenticated and were mass-exploited by the HAFNIUM espionage cluster and numerous ransomware crews. ProxyNotShell (autumn 2022) required valid credentials, narrowing its blast radius but still proving the architecture remained fertile ground a full year later. For defenders, the practical implication is that any internet-facing Exchange must be treated as continuously at risk from this bug class, not just from a single patched CVE.
The Autodiscover Parser Differential, Explained
The heart of ProxyShell's first link is a parser differential — two components disagreeing about what a URL means. It is worth understanding precisely because the same flaw shape recurs across web security.
The Exchange front end performs URL normalisation and access-control based on its interpretation of the request path. It looks at the path, decides "this is an Autodiscover request, which has relaxed pre-auth handling," and forwards it. But the suffix the attacker appends — using @, ?, and encoded path separators — causes the back end to interpret the same string as a request to a different, more sensitive endpoint (the PowerShell virtual directory).
Front end sees: /autodiscover/autodiscover.json → "relaxed, route it"Back end sees: .../powershell → "privileged endpoint" ^ same bytes, two different parsingsBecause the front end made its trust decision based on its reading, and the back end honoured the request based on its reading, the access-control check and the actual handling diverged. The attacker lives in that divergence. This is the identical principle behind HTTP request smuggling (front-end and back-end disagree about request boundaries) and many URL-parsing SSRFs (the validator and the fetcher disagree about the host). Wherever two parsers process the same attacker-controlled string and can be made to disagree, there is a latent vulnerability.
Incident Response Checklist
If you operated Exchange during the ProxyShell window — or discover a suspected compromise now — the following triage sequence is the practical starting point:
- Hunt for web shells. Search
aspnet_client,owa/auth,ecp/auth, andFrontEnd\HttpProxy\owa\authfor unexpected.aspxfiles; compare against a known-good baseline. - Review export history. Run
Get-MailboxExportRequestand inspect the Exchange admin audit log forNew-MailboxExportRequestandNew-ManagementRoleAssignment— these persist even after the PST is deleted. - Triage IIS logs. Grep for Autodiscover requests containing
@,&Email=autodiscover, or/powershellsuffixes, and forX-Rps-CATanomalies. - Check for child processes. Look for
w3wp.exespawningcmd.exe,powershell.exe,csc.exe(web-shell compilation), ornet.exe. - Assume credential theft. If RCE is confirmed, treat all credentials on the host — and the Exchange service account — as compromised, and plan rotation.
- Scope persistence. Look for scheduled tasks, new local accounts, and additional shells, since operators commonly planted several.
Detection
| Source | Indicator |
|---|---|
IIS logs (.../W3SVC*) | Autodiscover requests with anomalous ? / @ / Email= patterns; long encoded paths |
| Exchange web root | New .aspx files in aspnet_client, owa/auth, ecp/auth, or unusual export paths |
| Exchange admin audit log | Unexpected New-MailboxExportRequest, New-ManagementRoleAssignment for non-admin users |
| PowerShell back-end logs | Remote PowerShell sessions for accounts that never use them |
| Process telemetry | w3wp.exe (Exchange app pool) spawning cmd.exe/powershell.exe |
Hunt tip: Get-MailboxExportRequest and the Exchange admin audit log will surface export requests even after the on-disk PST is deleted. Reviewing export history is one of the most reliable retrospective indicators of ProxyShell.PROXYSHELL DETECTION VALUE (signal strength) w3wp.exe → cmd/powershell ██████████ very highNew-MailboxExportRequest abuse █████████░ very highNew .aspx in web root ████████░░ highAnomalous Autodiscover URLs ███████░░░ high (catches the trigger)Remote PS for odd accounts ██████░░░░ medium-highRemediation
- Patch. The definitive fix is the Microsoft security updates that resolved all three CVEs. Exchange must be kept on a current Cumulative Update + Security Update level; out-of-band updates for these bugs were released in 2021.
- Reduce exposure. Where feasible, do not expose Exchange management endpoints (ECP, PowerShell) to the internet. Front Exchange with a reverse proxy / pre-authentication (e.g. published through an identity-aware gateway) so unauthenticated requests never reach the CAS chain.
- Run the Exchange Health/Mitigation tooling. Microsoft's Exchange On-premises Mitigation Tool and the EOMT/Health Checker scripts help detect web shells and apply URL-rewrite mitigations.
- Monitor exports and role assignments. Alert on any
New-MailboxExportRequestand on management-role changes; these are rare in normal operations. - Constrain the app pool. Limit what the Exchange application pool identity can execute, and deploy EDR that flags
w3wp.exechild processes. - Consider migration. The strongest long-term mitigation for the on-prem Exchange attack surface is moving to a hosted/cloud mail platform, eliminating the internet-facing CAS proxy entirely.
Root-Cause Themes
ProxyShell is fundamentally a story about parser differentials and misplaced trust between tiers. The front end and back end disagreed about URL semantics (Link 1) and about identity (Link 2), and a powerful administrative feature trusted its caller's intentions (Link 3). Every link is a case of one component trusting another's interpretation of attacker-influenced data.
The architectural lesson generalises far beyond Exchange: any system with a front-end proxy and a privileged back-end must ensure both tiers parse and authenticate requests identically. Wherever two parsers can disagree about the same input, an attacker will find the gap.
Detection with Exchange Server Event Logs
ProxyShell leaves a distinctive trail across multiple Exchange and Windows log sources. The challenge is volume: an Exchange server produces thousands of IIS log entries per hour, and the ProxyShell indicators are buried in that noise. The following log-by-log breakdown focuses on the highest-fidelity signals — the ones that, when automated, catch the chain reliably even when the web shell itself has been deleted.
IIS Logs (W3SVC* in %SystemDrive%\inetpub\logs\)
The Autodiscover-based path confusion (CVE-2021-34473) produces unmistakable patterns in IIS request logs. Key fields: cs-uri-stem, cs-uri-query, cs-method, sc-status.
# Signature pattern: Autodiscover URL containing @ and powershell in the query2021-08-13 04:15:22 10.0.0.1 POST /autodiscover/autodiscover.json @evil.com/powershell? 443 - 1.2.3.4 - 200 0 0 312 # Any Autodiscover path with URL-encoded path separators or @ is suspicious:/autodiscover/autodiscover.json%3F@evil.com/autodiscover/autodiscover.json?&Email=autodiscover/autodiscover.json%3F@A PowerShell query to hunt these in IIS logs (adjust path to match your log rotation):
$logPath = "C:\inetpub\logs\LogFiles\W3SVC1"Get-ChildItem $logPath -Filter "*.log" -Recurse | Select-String -Pattern "autodiscover.*@|autodiscover.*powershell" | Where-Object { $_ -match "autodiscover" } | Select-Object Filename, LineNumber, LineExchange Admin Audit Log
The mailbox-export abuse (CVE-2021-31207) generates entries in the Exchange admin audit log even after the PST file is deleted from disk. This is the most durable retroactive indicator.
# Search for New-MailboxExportRequest entries (Exchange Management Shell)Search-AdminAuditLog -Cmdlets New-MailboxExportRequest ` -StartDate "2021-01-01" -EndDate (Get-Date) | Select-Object RunDate, Caller, CmdletName, ObjectModified, CmdletParameters # Also check for role assignment abuse preceding the export:Search-AdminAuditLog -Cmdlets New-ManagementRoleAssignment ` -StartDate "2021-01-01" -EndDate (Get-Date) | Select-Object RunDate, Caller, CmdletName, CmdletParametersExpected output when ProxyShell was used:
RunDate : 2021-08-13 04:16:41Caller : NT AUTHORITY\SYSTEM or a machine accountCmdletName : New-MailboxExportRequestCmdletParameters : [{FilePath: \\localhost\C$\inetpub\wwwroot\aspnet_client\shell.aspx}, {Mailbox: attacker_mailbox}]Windows Security and System Events
| Event ID | Log | Meaning in ProxyShell context |
|---|---|---|
| 4688 | Security | Process creation: look for w3wp.exe (Exchange app pool) spawning cmd.exe, powershell.exe, csc.exe, or net.exe — this is the web shell executing |
| 4698 | Security | Scheduled task created — common persistence mechanism planted after shell access |
| 4720 | Security | Local account created — attacker adding a backdoor account |
| 7045 | System | New service installed — alternative persistence method |
| 4104 | PowerShell (Operational) | Script block logging: captures the content of PowerShell commands run through the remote PS endpoint; invaluable for reconstructing what the attacker did |
A WEVTUTIL or PowerShell query to capture the web-shell execution signal:
# Alert: w3wp.exe spawning command interpreters$filter = @{ LogName = 'Security' Id = 4688 StartTime = (Get-Date).AddDays(-7)}Get-WinEvent -FilterHashtable $filter | Where-Object { $_.Message -match "w3wp\.exe" -and $_.Message -match "cmd\.exe|powershell\.exe|csc\.exe|net\.exe" } | Format-List TimeCreated, MessageExchange PowerShell Backend Logs
The remote PowerShell session established via CVE-2021-34523 is captured in the Exchange HttpProxy logs (%ExchangeInstallPath%Logging\HttpProxy\PowerShell). Each log file is CSV-formatted and includes the authenticated identity and the AnchorMailbox header — which in an attack scenario will contain the manipulated identity from the path-confusion step.
# Suspicious entry in HttpProxy\PowerShell log:DateTime,RequestId,UrlStem,TargetServer,AuthenticatedUser,...2021-08-13T04:15:45,...,/powershell,...,NT AUTHORITY\SYSTEM,...An unauthenticated pre-exploitation request will show up with AuthenticatedUser as anonymous or as a machine-account identity — never as a legitimate named admin. Any remote PowerShell session whose AuthenticatedUser is SYSTEM or an unusual identity is a high-confidence indicator.
Automated Hunting with Get-ExchangeDiagnosticInfo
Microsoft's Exchange Health Checker and the CSS-Exchange toolset (open source on GitHub) include ProxyShell-specific hunt modules that automate the log queries above and check the web-root for unexpected ASPX files in a single pass:
# Run the MSERT / CSS-Exchange webshell scannerInvoke-WebRequest -Uri "https://aka.ms/EOMTv2" -OutFile EOMT.ps1.\EOMT.ps1 # Applies URL rewrite mitigations and scans for known web shellsMITRE ATT&CK Mapping
| ATT&CK Tactic | Technique ID | Technique Name | ProxyShell link |
|---|---|---|---|
| Initial Access | T1190 | Exploit Public-Facing Application | CVE-2021-34473: unauthenticated path confusion against Exchange |
| Privilege Escalation | T1068 | Exploitation for Privilege Escalation | CVE-2021-34523: elevated identity in the PowerShell backend |
| Persistence | T1505.003 | Server Software Component: Web Shell | CVE-2021-31207: .aspx web shell dropped via mailbox export |
| Execution | T1059.001 | Command and Scripting Interpreter: PowerShell | Remote PowerShell commands run through the Exchange PS endpoint |
| Execution | T1059.003 | Command and Scripting Interpreter: Windows Command Shell | cmd.exe spawned as a child of w3wp.exe via the web shell |
| Collection | T1114.002 | Email Collection: Remote Email Collection | Mass mailbox exfiltration using Exchange admin cmdlets post-compromise |
| Credential Access | T1003.001 | OS Credential Dumping: LSASS Memory | LSASS dump from the Exchange host post-shell access |
| Defense Evasion | T1036 | Masquerading | Web shells planted in aspnet_client and owa/auth to blend with legitimate IIS content |
| Lateral Movement | T1021.006 | Remote Services: Windows Remote Management | Exchange server as a pivot point — internally trusted, AD-joined host |
| Persistence | T1053.005 | Scheduled Task/Job: Scheduled Task | Scheduled tasks planted for persistence after shell access |
Conclusion and Takeaways
ProxyShell earned its notoriety because it combined maximum impact (unauthenticated RCE) with a juicy, ubiquitous target (Exchange) and because it abused legitimate features — Autodiscover routing and mailbox export — rather than relying on memory corruption. That made it reliable, cross-version, and devastating in the hands of both espionage actors and ransomware crews.
For defenders the practical priorities are: patch Exchange relentlessly, minimise its internet exposure, monitor mailbox-export and role-assignment activity, and treat any w3wp.exe-spawned shell as an emergency. For the broader engineering community, ProxyShell is a permanent argument for the dual-parser principle: never let your edge and your core disagree about what a request means, because that disagreement is precisely where the chain begins. And where you can, retire internet-facing on-prem Exchange entirely — the most reliable way to be immune to the next ProxyShell is to not run the attack surface at all.