Removes the CVE-2026-42897 EEMS mitigation from OWA web.config on Exchange servers with the July 2026 SU, clearing its side effects
This Automox Worklet™ removes the CVE-2026-42897 mitigation that the Exchange Emergency Mitigation Service (EEMS) adds to the Outlook Web Access (OWA) web.config on Exchange servers. The mitigation, M2.1.0, is an IIS URL Rewrite outbound rule named EEMS M2.1 OWA CSP - outbound and a precondition named EEMS M2.1 OWA SPA HTML shell - precondition.
CVE-2026-42897 is a cross-site scripting vulnerability in Exchange Server OWA. Microsoft addressed it in the June 2026 Security Update (SU) but recommended keeping the mitigation in place. Its July 2026 SU release post tells administrators to remove the M2.1.0 IIS rules after they install that update. The update doesn't remove them on its own.
The Worklet reads each server's Exchange build first and removes the two elements only when the build includes the July 2026 SU or a later update. Use this Worklet once you've installed the July 2026 SU on your Exchange Mailbox servers.
Microsoft disclosed CVE-2026-42897 on May 14, 2026, and released the M2.1 mitigation through EEMS as an interim fix. Servers with EEMS enabled, the default setting, applied it automatically. CISA added the CVE to its Known Exploited Vulnerabilities catalog on May 15, 2026. Microsoft lists these OWA known issues while the mitigation is in place:
OWA Print Calendar might not work.
Inline images might not display correctly in the recipient's OWA reading pane.
Published calendars might fail with error 500.
OWA Light (the URL ending in /?layout=light) doesn't work properly.
The OWACalendar.Proxy health set might show unhealthy and raise alerts in your Exchange monitoring tools.
Microsoft says these issues should be resolved once you install the July 2026 SU and remove the mitigation. This Worklet makes the same two deletions as Microsoft's documented M2 rollback procedure.
Exchange Server 2016 and 2019 get the July 2026 SU only through the Period 2 Extended Security Update (ESU) program. Microsoft says you can keep the mitigation on servers you can't update. The Worklet's build check leaves those servers alone, so one policy can target every Exchange server.
Evaluation phase: The script reads MsiInstallPath from HKLM\SOFTWARE\Microsoft\ExchangeServer\v15\Setup in the 64-bit registry view and looks for FrontEnd\HttpProxy\owa\web.config under that path. It reads the Exchange build from Bin\ExSetup.exe and compares it with the July 2026 SU build for that update line: 15.2.2562.45 for Exchange Server SE RTM, 15.2.1748.48 for Exchange Server 2019 Cumulative Update 15 (CU15), 15.2.1544.43 for Exchange Server 2019 CU14, and 15.1.2507.71 for Exchange Server 2016 CU23. A build from a newer CU passes the check, and a build from an older CU doesn't.
When the build passes, the script parses web.config and searches system.webServer/rewrite/outboundRules for the M2.1 rule and its precondition. It exits 1 (non-compliant) when either element is present and 0 when neither is. It also exits 0 when Exchange isn't installed, there's no OWA web.config, the build is below the July 2026 SU, or the script can't read the Exchange Setup registry key, the ExSetup.exe version, or web.config. The script logs those read errors as a WARNING.
Remediation phase: The script repeats the evaluation checks and changes nothing unless the server is non-compliant. You can run it on its own with FixNow. It copies web.config byte for byte to %ProgramData%\amagent\WorkletCache\53e65287-5214-5084-b6ea-e37d397d3215 as owa_web.config.<yyyyMMdd-HHmmss>.bak and writes the Exchange build to a matching .build file. If the backup fails, it exits 1 before touching web.config.
It then uses .NET XmlDocument to delete only the EEMS M2.1 OWA CSP - outbound rule and the EEMS M2.1 OWA SPA HTML shell - precondition element, along with the whitespace that indented them. The rewrite, outboundRules, and preConditions sections stay in place.
The script saves the file as UTF-8 and keeps or omits the byte order mark to match the original. If the save fails, it writes the original bytes back and exits 1. A final check re-runs the evaluation logic and exits 1 unless it reports compliant.
Windows Server 2016, Windows Server 2019, Windows Server 2022, or Windows Server 2025, with PowerShell 5.1 or later
Exchange Server SE RTM, Exchange Server 2019 CU14 or CU15, or Exchange Server 2016 CU23, with the July 2026 SU or later installed.
The Mailbox role, which provides the OWA web.config. Edge Transport and Management Tools-only installs have no OWA web.config, so the Worklet logs them as NOT APPLICABLE and exits 0.
An Exchange install path in the MsiInstallPath value under HKLM\SOFTWARE\Microsoft\ExchangeServer\v15\Setup
Write access to the Exchange installation folder and %ProgramData%. The Automox agent runs Worklets as SYSTEM, which has both.
No required variables. Two optional switches sit at the top of the remediation script, both $false by default: $dryrun = $true logs each change without writing anything, and $rollback = $true restores the most recent backup.
After remediation, the OWA web.config on each Mailbox server with the July 2026 SU or later no longer contains the EEMS M2.1 OWA CSP - outbound rule or the EEMS M2.1 OWA SPA HTML shell - precondition element, and evaluation exits 0. Servers below the July 2026 SU log NOT APPLICABLE and keep the mitigation. Saving web.config makes IIS restart the OWA application, so users with OWA open can see a brief interruption. The Worklet doesn't run iisreset or restart any Exchange service.
The Activity Log shows the web.config path, the Exchange build, the backup file, a RESULT line confirming the removal, and a final NOTE with this server's command for blocking the mitigation if EEMS re-applies it: Set-ExchangeServer -Identity <server> -MitigationsBlocked @("M2.1.0"). To undo the removal, first remove the server's group from the policy that removed the rules. Then create a policy for that group from the catalog Worklet, set $rollback = $true in its remediation code, and run it with Run Policy. The script restores the most recent backup only when the server's Exchange build still matches the build saved with it, and otherwise exits 1 without writing anything.
Loading...
Consider Worklets your easy button
An Automox Worklet™ is a Bash or PowerShell automation that takes action on Windows, macOS, and Linux endpoints at scale. It handles everything from configuration and software management to named-CVE mitigations deployed within hours of disclosure, including vulnerabilities that have no patch yet, are configuration-based, or that a vendor won't fix.
Every Automox-published Worklet is human-reviewed, and customers control where, when, and how it runs.
Mitigation at AI speed
Frontier-model AI is finding vulnerabilities faster than most teams can track, and most of what it finds isn't immediately patchable. Finding isn't fixing. Worklets turn discovery into action.

AUTOMOX + WORKLETS™
Uncover new possibilities with simple, powerful automation.
By submitting this form you agree to our Master Services Agreement and Privacy Policy
By submitting this form you agree to our Master Services Agreement and Privacy Policy.
Already have an account? Log in