How to Mitigate Exchange Server ProxyShell Vulnerabilities using IIS Request Filtering

The Microsoft Exchange Server ProxyShell vulnerability chain (CVE-2021-34473, CVE-2021-34523, and CVE-2021-31207) remains one of the most critical threats to enterprise infrastructure. These vulnerabilities allow unauthenticated attackers to bypass ACL controls, elevate privileges, and execute arbitrary PowerShell commands on the Exchange server, frequently leading to complete domain compromise or ransomware deployment. While applying the official Microsoft Security Updates (SUs) is the only definitive resolution, emergency situations often require immediate, temporary mitigation before a patching window can be scheduled. In such scenarios, administrators can utilize Internet Information Services (IIS) Request Filtering to mathematically block the specific malicious URL patterns exploited by ProxyShell.

The Anatomy of a ProxyShell Attack

ProxyShell exploits a fundamental flaw in the Client Access Service (CAS) running on port 443. The architecture of modern Exchange relies on the CAS front-end proxying requests to the mailbox back-end service on port 444. The vulnerability arises from how the front-end normalizes explicit logon URLs (e.g., /autodiscover/[email protected]). By appending specific payloads to the Autodiscover URL, an attacker forces the front-end to misinterpret the intended back-end destination, effectively tricking the CAS into forwarding the request directly to the privileged Exchange PowerShell virtual directory (/powershell) or the Exchange Web Services (EWS) endpoint.

Because the CAS performs the authentication check on the intended target rather than the actual proxy destination, the request bypasses authentication entirely and hits the back-end as the highly privileged NT AUTHORITY\SYSTEM account.

Implementing IIS Request Filtering

To mitigate this attack vector, we can instruct the IIS web server hosting the Exchange front-end to forcefully drop any incoming HTTP request containing the malicious Autodiscover JSON payload pattern.

First, ensure the Request Filtering role service is installed on your Windows Server. This is typically installed by default on Exchange servers, but can be verified via Server Manager or by running the following PowerShell command:

Get-WindowsFeature Web-Filtering

If it is not installed, add it using Install-WindowsFeature Web-Filtering.

Applying the Filtering Rules via Appcmd

Open an elevated Command Prompt (not PowerShell, as the syntax below is optimized for the IIS command-line tool) and execute the following appcmd commands. These commands inject a precise filtering rule into the web.config file of the default website.

The rule specifically targets the URL path and queries for the string autodiscover.json coupled with an explicit routing address (the @ symbol), which is the hallmark of the ProxyShell bypass technique.

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"filteringRules.[name='BlockProxyShell']"

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"filteringRules.[name='BlockProxyShell'].scanUrl:True"

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"filteringRules.[name='BlockProxyShell'].appliesTo.[fileExtension='.json']"

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"filteringRules.[name='BlockProxyShell'].denyStrings.[string='autodiscover.json']"

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/requestFiltering /+"filteringRules.[name='BlockProxyShell'].denyStrings.[string='@']"

Verifying the Mitigation

After applying the rules, restart the World Wide Web Publishing Service to ensure the new configuration is actively enforced in the w3wp.exe worker processes:

Restart-Service W3SVC -Force

To verify the mitigation is active, attempt to access a harmless but structurally similar URL from an external network connection:

https://mail.yourdomain.com/autodiscover/[email protected]/mapi/nspi

If the IIS Request Filtering is functioning correctly, the server will immediately return an HTTP 404.19 – Not Found error (Denied by filtering rule), rather than a 401 Unauthorized or a 200 OK. This confirms that the malicious proxy routing request is being dropped at the perimeter of the web server, effectively insulating the vulnerable Exchange back-end from the ProxyShell exploit chain.

Warning: This mitigation is strictly a temporary stopgap. It may interfere with legitimate third-party Autodiscover integrations and does not resolve the underlying binary vulnerabilities. Apply the relevant Exchange Server Cumulative Updates (CUs) and Security Updates (SUs) as soon as possible.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.