Update 11/08/2022: the update has been published in the security bulletin of November
Update 12/10/2022: the security update does not contain the patch for the vulnerabilities described in this post, you must continue to apply the workarround https://techcommunity.microsoft.com/t5/exchange-team-blog/released-october-2022-exchange-server-security-updates/ba-p/3646263
Update 11/10/2022: the patch will be dropped today at 6PM GMT
Last Thursday night (french night), as always, critical vulnerabilities were announced affecting Microsoft Exchange, all supported versions.
The vulnerabilities were found by a Vietnamese Blue Team (GTSC) who discovered them being exploited in the wild against its customers: https://gteltsc.vn/blog/warning-new-attack-campaign-utilized-a-new-0day-rce-vulnerability-on-microsoft-exchange-server-12715.html
It’s a chain of two vulnerabilities allowing remote control of Exchange, without authentication:
- SSRF (CVE-2022-41040), allowing to bypass the authentication with the Autodiscover feature
- Execution of PowerShell code (CVE-2022-41082), by calling PowerShell Remoting from the Autodiscover configuration file
As with the vulnerability named ProxyShell, for this one, named ProxyNotShell, the problem comes from the automated discovery feature of a user’s email settings, the (in)famous “AutoDiscover”.
As this feature is used to find a user’s information to make their life easier when configuring their email access, it is accessible without any authentication. It is possible to pass an “Email” parameter containing… an email address that Exchange will use to find the user’s parameters.
In theory, Exchange will only process the request if the domain of the email is that of the Exchange (name@domain.com) and will retrieve a JSON file containing the configuration information.
But there seem to be several problems:
If the email address contains a “?” instead of the “@” at sign, then Exchange will still retrieve the JSON file using what the “name” contains (name@domain.com) by adding it to the domain which will be passed directly as a parameter (I don’t have the details of why it works yet)
Exchange will look for a JSON file on the Internet and interpret its content, I guess that’s where the second vulnerability is located, which allows PowerShell to be executed.
Exploit
The exploit for the SSRF (CVE-2022-41040) was released Saturday morning and is widely used in the wild but for now, without the code execution.
There are several ways to check your Exchange. The simplest one seems to be:
"https://MY-SERVER-EXCHANGE.com/autodiscover/autodiscover.json?@outlook.com/&Email=autodiscover/autodiscover.json%3f@MON-DOMAINE-MAIL.com"
By replacing:
MY-SERVER-EXCHANGE.com by the FQDN of your Exchange server, like mail.mycompany.com
MY-DOMAIN-MAIL.com by your mail domain name such as mycompany.com
If you get a 400 error with a JSON containing an error message, then you are vulnerable.