Die Exchange Mitigation EM1, welche am Wochenende durch Microsoft veröffentlicht wurde, dichtet die Exchange Zero-Day Schwachstelle ProxyNotShell (CVE-2022-41040) nur unzureichend ab und lässt sich einfach umgehen. Problem ist ein „@“ Zeichen im Reg-Ex Pattern, welches die Regel zu sehr präzisiert. Durch leichte Anpassungen lässt sich somit die Reg-Ex umgehen. Somit wird die Regel nicht mehr angewendet und die Schwachstelle trotzdem ausnutzen:
Microsoft has not yet distributed an updated version of the rule via Exchange Mitigation, so a separate rule should be created in addition to the rule configured by Exchange Mitigation.
The rule can be configured according to this article, but the pattern must be adapted:
.*autodiscover\.json.*Powershell.*
Your own rule then looks like this:
Also the Microsoft published script to install URL Rewrite and configure the rule, still has the wrong pattern:
However, there is a new recommendation from Microsoft: RemotePowerShell should be switched off for all non-administrative users. Unfortunately, RemotePowerShell is allowed for all users in the default setting:
Get-User | ft name,RemotePowerShellEnabled
So if you now disable RemotePowerShell for all users, all newly created users will have it enabled again. I have therefore created a small script that deactivates RemotePowerShell for all users, except for members of a specific AD group:
#Allowed AD Group for RemotePowerShell:
$AllowedGroup = "AllowRemotePowerShell"
$AllUsers = get-mailbox -resultsize Unlimited | Get-User -ResultSize Unlimited | select SamAccountName,RemotePowerShellEnabled | where {$_.RemotePowerShellEnabled -eq $true}
$AllowedUsers = Get-ADGroupMember $AllowedGroup -Recursive | ForEach-Object {Get-User -Identity $_.SamAccountName | select SamAccountName,RemotePowerShellEnabled}
#Enable RemotePowerShell for allowed Users
foreach ($AllowedUser in $AllowedUsers) {
if ($AllowedUser.RemotePowerShellEnabled -eq $False) {
Set-User $AllowedUser.SamAccountName -RemotePowerShellEnabled $true
}
}
#Disable RemotePowerShell for all Users
foreach ($User in $AllUsers) {
if ($AllowedUsers.SamAccountName -notcontains $User.SamAccountName) {
Set-User $User.SamAccountName -RemotePowerShellEnabled $false
}
}
#Display RemotePowerSthell State
$RemotePowerShellState = get-mailbox -resultsize Unlimited | Get-User -ResultSize Unlimited | select SamAccountName,RemotePowerShellEnabled
$RemotePowerShellState
Das Script könnte beispielsweise zyklisch per Windows Aufgabenplanung ausgeführt werden, in diesem Fall wird RemotePowerShell für alle Mitglieder der Gruppe „AllowRemotePowerShell“ aktiviert und für alle anderen Benutzer deaktiviert (Das Script muss in einer administrativen Exchange Management Shell gestartet werden)
Das Script konnte ich bisher nur in meiner Testumgebung testen und mit der „heißen Nadel gestrickt“, daher ist Vorsicht geboten. Ich habe das Script auch auf GitHub veröffentlicht, falls jemand mitwirken möchte:
No security update for the ProxyNotShell vulnerability has yet been published. It is therefore necessary to continue waiting until the vulnerability is finally closed. All of these measures are only intended as a workaround and should therefore be checked carefully.