ZeroHour
Palo Alto Unit 42published ()ingested Shawn Westfall

Threat Brief: CVE-2022-41040 and CVE-2022-41082: Microsoft Exchange Server (ProxyNotShell)

Vulnerabilities mentionedAll →

CVEVulnerabilityCVSSEPSSFlagsAffectedExposurePublished
CVE-2021-31207
Security feature bypass in Microsoft Exchange Server (ProxyShell) enables webshell RCE

CVE-2021-31207 is a security feature bypass in Microsoft Exchange Server, classified as an unrestricted file-write issue (CWE-434) that lets an attacker bypass intended restrictions and write files of their choosing to the server. It is the final bug in the ProxyShell chain: chained with the autodiscover SSRF and PowerShell backend elevation flaws, it allows an unauthenticated attacker to reach the Exchange PowerShell API, write arbitrary files such as an ASPX webshell, and execute code with SYSTEM privileges. A successful attacker gains full control of the on-premises Exchange server, including mailbox access, stolen credentials, and a foothold for lateral movement; the bug has been used to deploy ransomware and keyloggers. On-premises deployments of Microsoft Exchange Server (2013, 2016, and 2019 per vendor advisories) are affected, while Exchange Online/cloud mailboxes are not. Exploitation is essentially certain and ongoing: the flaw is in CISA's KEV (added 2021-11-03) with known ransomware use, public ProxyShell PoC/exploit code is available, and EPSS puts the 30-day exploitation probability at 99.8%.

Do: Apply Microsoft's July 2021 security updates for Exchange Server 2013, 2016, and 2019 (or any later security/cumulative update) per vendor instructions, and restrict untrusted access to Exchange's autodiscover and PowerShell endpoints. Hunt for ASPX webshells under the Exchange FrontEnd directories and review IIS logs for autodiscover.json requests chaining PowerShell, since many servers were compromised before patching. Given known ransomware use and KEV listing, treat any server that was unpatched or internet-exposed during the exploitation window as potentially compromised.

6.6100% KEV ransomware PoC
  • microsoft Exchange Server On-premises Microsoft Exchange Server 2013, 2016, and 2019 (per vendor advisory; CISA lists 'Microsoft Exchange Server' generically)
massHundreds of thousands of on-premises Exchange servers (public scans around the July 2021 ProxyShell disclosure showed roughly 400,000-600,000 internet-exposed…
CVE-2021-34473
+1 in the same advisory: …34523
SSRF (CWE-918) in Microsoft Exchange Server Enabling RCE (ProxyShell)

Microsoft Exchange Server contains a server-side request forgery (SSRF, CWE-918) in the Autodiscover service that unauthenticated remote attackers can reach over HTTP. This flaw is the first stage of the widely documented 'ProxyShell' chain, in which the SSRF is combined with privilege escalation and an arbitrary file write in the Exchange PowerShell backend to achieve unauthenticated remote code execution on the server. An attacker who successfully exploits it gains the ability to run code on the Exchange server, and ransomware operators (e.g., Cuba ransomware) leveraged this chain to deploy payloads. Organizations running on-premises Microsoft Exchange Server (2013, 2016, and 2019 per the vendor's advisories) are affected; hosted Exchange Online is a separately managed cloud service. Exploitation is confirmed in the wild: CISA added the flaw to the KEV catalog on 2021-11-03 with known ransomware use, and EPSS assigns it a 100% probability of exploitation within 30 days (100th percentile).

Do: Apply Microsoft's July 2021 (or later) Exchange Server security updates, which include the ProxyShell fixes, to all on-premises servers. If patching is delayed, restrict internet access to the Autodiscover/EWS frontend endpoints and consider the URL Rewrite mitigation Microsoft published for ProxyShell. Given the KEV listing and known ransomware use, treat internet-facing, unpatched Exchange servers as potentially compromised and hunt for webshells, unusual Exchange processes, and suspicious account or mailbox activity.

9.1
group max
100% KEV ransomware PoC
  • Microsoft Exchange Server On-premises Exchange Server deployments not yet patched with Microsoft's July 2021 (or later) security updates; the source data does not enumerate specific vers
masshundreds of thousands of on-prem Exchange servers; public internet scans at the time of disclosure showed roughly 400,000+ internet-exposed Exchange instances,…
CVE-2022-41040
+1 in the same advisory: …41082
Server-Side Request Forgery in Microsoft Exchange Server (ProxyNotShell)

CVE-2022-41040 is a server-side request forgery (SSRF, CWE-918) vulnerability in Microsoft Exchange Server, publicly tracked under the name "ProxyNotShell" together with CVE-2022-41082. It is triggered when an attacker sends crafted HTTP requests to exposed Exchange web endpoints (such as Autodiscover), causing the server to issue attacker-influenced requests to itself. On its own the SSRF coerces authenticated server-side requests, but when chained with the CVE-2022-41082 remote code execution flaw it gives the attacker code execution on the Exchange server, typically followed by web shells, data access, and — in observed campaigns — ransomware deployment. Organizations running on-premises Microsoft Exchange Server are affected; the source data lists only Microsoft Exchange Server and does not specify affected version ranges, and hosted Exchange Online is a separate product not listed here. The vulnerability is being actively exploited in the wild: it was added to CISA's Known Exploited Vulnerabilities catalog on 2022-09-30 with known ransomware use, and EPSS assigns it a 100% probability of exploitation within 30 days; no public PoC is listed.

Do: Apply Microsoft's Exchange Server security updates per vendor instructions immediately, as required by the CISA KEV catalog. As interim mitigation, restrict or block untrusted internet access to Exchange web endpoints (e.g., Autodiscover, OWA, ECP), and review IIS logs for suspicious crafted requests indicating SSRF or the chained CVE-2022-41082 exploitation. Given documented ransomware use, prioritize any internet-facing Exchange server and hunt for web shells and post-exploitation activity.

8.8
group max
100% KEV ransomware PoC
  • Microsoft Exchange Server
mass≈250,000+ internet-exposed Exchange servers (public scans of exposed OWA/ECP/Exchange endpoints)
Full article1,994 words · extracted from unit42.paloaltonetworks.com · click to collapse

Executive Summary

In early August, GTSC discovered a new Microsoft Exchange zero-day remote code execution (RCE) that was very similar to ProxyShell (CVE-2021-34473, CVE-2021-34523 and CVE-2021-31207).

The exploit was discovered in the wild in what appeared to be a SOC investigation into suspicious activity of one of GTSC’s customers. Once they determined the scope of the vulnerabilities, GTSC reported the vulnerability to the Zero-day Initiative (ZDI) to enable further coordination with Microsoft. The vulnerabilities were assigned CVE-2022-41040 and CVE-2022-41082 and rated with severities of critical and important respectively. The first one, identified as CVE-2022-41040, is a server-side request forgery (SSRF) vulnerability, while the second one, identified as CVE-2022-41082, allows remote code execution (RCE) when Exchange PowerShell is accessible to the attacker.

The exploit does require authentication; however, the authentication required is that of a standard user and, based on how easy it is to collect user credentials these days, this is not a high bar to overcome. Microsoft has yet to release a patch for these vulnerabilities. In the meantime, they provided mitigations in a blog responding to GTSC’s disclosure of these vulnerabilities.

Palo Alto Networks customers receive protections from and mitigations for ProxyNotShell in the following ways:

  • Next-Generation Firewalls or Prisma Access with a Threat Prevention security subscription can block sessions related to CVE-2022-41040.
  • A Cortex XSOAR response pack and playbook can automate the mitigation process.
  • Cortex Xpanse can help identify and detect Microsoft Exchange servers that may be a part of your attack surface.
  • Cortex XDR will report related exploitation attempts.
  • XQL queries provided below can be used with Cortex XDR to help track attempts to exploit these CVEs.
  • Malicious URLs and IPs have been added to Advanced URL Filtering.
  • The Unit 42 Incident Response team can provide personalized assistance.

For more details, please see the conclusion.

Details of the Vulnerabilities

GTSC’s SOC discovered the following URL requests in a customer’s Microsoft Internet Information Services (IIS) logs:

The URL requests shown were discovered in a GTSC customer's Microsoft Internet Information Services logs and appear to be identical to ProxyShell requests seen last year.

The URL requests appear to be identical to the ProxyShell requests seen last year. Compare the above request with the following excerpt from Mandiant’s blog reporting on the discovery of ProxyShell last year, and you’d think this must be an unpatched server exploited by ProxyShell.

Excerpt from Mandiant's blog reporting on the discovery of ProxyShell last year. Note the similarity between the requests shown and what was seen with ProxyNotShell.

GTSC reviewed the Exchange server version and confirmed the Exchange servers were up to date and the vulnerabilities were indeed new zero days. GTSC also confirmed the attackers were able to get PowerShell execution during the attack. This also resembles ProxyShell. Once attackers gained access to the server, they installed webshells to obtain persistent access to the network. GTSC reported the vulnerability to the Zero-day Initiative (ZDI) to enable further coordination with Microsoft. The vulnerabilities were assigned CVE-2022-41040 and CVE-2022-41082 and rated with severities of critical and important respectively. The first one, identified as CVE-2022-41040, is a server-side request forgery (SSRF) vulnerability, while the second one, identified as CVE-2022-41082, allows remote code execution (RCE) when Exchange PowerShell is accessible to the attacker.

Please refer to GTSC’s excellent blog for details on the webshells, malware analysis, indicators of compromise (IoCs) and commands discovered during their investigation. Microsoft has stated that the vulnerabilities affect Microsoft Exchange Server 2013, Exchange Server 2016 and Exchange Server 2019. They also state that “Exchange Online has detections and mitigations to protect customers. As always, Microsoft is monitoring these detections for malicious activity and we’ll respond accordingly if necessary to protect customers.”

Current Scope of the Attack

It does appear there are multiple victims of this attack. However, from what has been publicly reported, the attacks still seem to remain isolated. GTSC stated in their blog, “GTSC's direct incident response process recorded more than one organization being the victims of an attack campaign exploiting this 0-day vulnerability.”

Microsoft, in a blog response to GTSC’s, stated “MSTIC observed activity related to a single activity group in August 2022 that achieved initial access and compromised Exchange servers by chaining CVE-2022-41040 and CVE-2022-41082 in a small number of targeted attacks.”

Both GTSC and Microsoft’s observed attacks used the China Chopper webshell and Microsoft’s MSTIC attributes the attacks, with medium confidence, to one attack group. Although the attacks still appear to be isolated, based on the history of ProxyShell and the difficulty of patching Exchange servers, we believe this vulnerability will garner widespread attention from threat groups. Therefore, we expect working exploits and proofs of concept (PoCs) will soon be available to aid in the exploitation of these vulnerabilities. That being said, Unit 42 has not yet seen any evidence of attempted exploitation within our customer telemetry.

Interim Guidance

Microsoft has yet to release a patch for these vulnerabilities. In the meantime, they provided mitigations that rely on the usage of a URL Rewrite rule to identify and block exploitation attempts as well as disabling remote PowerShell access for non-admins.

GTSC provided the same guidance in their blog as well. If you feel you may have been targeted and keep IIS logs, GTSC recommends running the following PowerShell command to search for evidence of attempted exploitation of your Exchange servers:

1

Get-ChildItem-Recurse-Path<Path_IIS_Logs>-Filter"*.log"|Select-String-Pattern'powershell.*autodiscover\.json.*\@.*200'.

Cortex XDR customers can search for signs of exploitation by employing the queries included in the following section of this brief. The queries include evidence of certutil connections to public IPs, evidence of DLL and EXE writes to C:\Users\Public\, evidence of China Chopper webshell activity, and the addition of suspicious files to Exchange directories.

Unit 42 Managed Threat Hunting Queries

The Unit 42 Managed Threat Hunting team continues to track any attempts to exploit these CVEs across our customers, using Cortex XDR and the XQL queries below. Cortex XDR customers can also use these XQL queries to search for signs of exploitation.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

// Description: Detect certutil netcons to public IP addresses. May be observed

//           post-exploit in latest Exchange 0-day attacks for connection checks

config case_sensitive=false

|dataset=xdr_data

|filter event_type=STORY andactor_process_image_name="certutil.exe"and

actor_process_image_command_line contains":8080"

|comp count()by agent_hostname,actor_process_image_name,action_external_hostname,

action_remote_ip,action_remote_port,actor_process_command_line

// Filter out connections to private IP addresses

|alter rfc1918_172=incidr(action_remote_ip,"172.16.0.0/12")

|alter rfc1918_10=incidr(action_remote_ip,"10.0.0.0/8")

|alter rfc1918_192=incidr(action_remote_ip,"192.168.0.0/16")

|filter rfc1918_172=falseandrfc1918_10=falseandrfc1918_192=false

|fields-rfc1918_10,rfc1918_172,rfc1918_192

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

// Description: Detect DLL and EXE writes to Public folder (C:\Users\Public\) on possible

//           Exchange hosts. May be used post-exploit as part of latest Exchange 0-day attacks

config case_sensitive=false

|dataset=xdr_data

|filter event_type=FILE and

(event_sub_type=ENUM.FILE_WRITE orevent_sub_type=ENUM.FILE_CREATE_NEW)and

action_file_extension in("exe","dll")and

action_file_path contains"C:\Users\Public"

|fields event_type,event_sub_type,agent_hostname,actor_effective_username,action_file_path,

action_file_extension,actor_process_image_name,causality_actor_process_image_name

// Show only results on possible Exchange hosts (w3wp.exe process is present)

|join conflict_strategy=right type=inner

(

dataset=xdr_data

|filter(event_type=PROCESS andactor_process_image_name="w3wp.exe")

|comp count(event_timestamp)asw3wp_event_count by actor_process_image_name,agent_hostname

|fields agent_hostname

)asw3wp_list w3wp_list.agent_hostname=agent_hostname

1

2

3

4

5

6

// Detection of China Chopper webshell activity

config case_sensitive=false

|dataset=xdr_data

|filter event_type=ENUM.PROCESS andactor_process_image_name="w3wp.exe"and(action_process_image_command_line contains"&ipconfig&echo"oraction_process_image_command_line contains"&quesr&echo"oraction_process_image_command_line contains"&whoami&echo"oraction_process_image_command_line contains"&c:&echo"oraction_process_image_command_line contains"&cd&echo"oraction_process_image_command_line contains"&echo [E]"oraction_process_image_command_line contains"&echo [S]")

|fields action_process_image_command_line,actor_process_image_path,actor_effective_username,agent_hostname

1

2

3

4

5

6

7

// Detection Suspicious files in Exchange directories

config case_sensitive=falsetimeframe=30d

|dataset=xdr_data

|filter event_type=ENUM.FILE andactor_process_image_name="w3wp.exe"andaction_file_path contains"FrontEnd\HttpProxy"andactor_process_command_line contains"MSExchange"

|fields  actor_effective_username,agent_hostname,actor_process_command_line,action_file_path,action_file_sha256

Conclusion

Based on the amount of publicly available information, the ease of use and the extreme effectiveness of this exploit, Palo Alto Networks highly recommends following Microsoft’s guidance to protect your organization until a patch is issued to fix the problem. Palo Alto Networks and Unit 42 will continue to monitor the situation for updated information, release of proof-of-concept code and evidence of more widespread exploitation.

Palo Alto Networks customers can leverage a variety of product protections and updates to identify and defend against this threat.

Next-Generation Firewalls (PA-Series, VM-Series and CN-Series) or Prisma Access with an Advanced Threat Prevention security subscription can automatically block sessions related to CVE-2022-41040 using Threat ID 91368 (Application and Threat content update 8624).

Cortex XSOAR has released a response pack and playbook for the ProxyNotShell CVEs to help automate and speed the mitigation process.

This playbook automates the following tasks:

  • Collection of Microsoft mitigation tools, detection rules and Microsoft Global Technical Support Center (GTSC) indicators
  • Extraction of these indicators and tagging to incidents
  • Hunting for exploitation patterns using Cortex XDR-XQL queries
  • Hunting for exploitation patterns using the following SIEM products:
    • Azure Sentinel
    • Splunk
    • QRadar
    • Elasticsearch
  • Indicator hunting using PAN-OS, Splunk and QRadar
  • Mitigation actions such as deploying detection rules and recommended workarounds
Portion of the ProxyNotShell Cortex XSOAR playbook illustrating collection and extraction of indicators and rules.
Figure 1. Portion of the playbook illustrating collection and extraction of indicators and rules.
Portion of the ProxyNotShell Cortex XSOAR playbook illustrating SIEM threat hunting.
Figure 2. Portion of the playbook illustrating SIEM threat hunting.
Portion of the ProxyNotShell Cortex XSOAR playbook illustrating Cortex XDR-XQL Threat Hunting.
Figure 3. Portion of the playbook illustrating Cortex XDR-XQL Threat Hunting.

See the Cortex XSOAR page on CVE-2022-41040 & CVE-2022-41082 - ProxyNotShell for details on the pack. To find out about other Cortex XSOAR packs and playbooks, visit our Cortex XSOAR Developer Docs reference page.

Cortex Xpanse has the ability to identify and detect Microsoft Exchange servers that may be a part of your attack surface or the attack surface of third-party partners connected to your organization.

Cortex XDR agent running on version 7.7 with content version 710-19877 and above will report the exploitation attempt of the exploitation chain that we have identified.

To ensure you are receiving alerts and monitoring any exploitation attempts:

  • Verify that you are using Cortex XDR agent version 7.7 (or newer)
  • Verify that your agent is on content update 710-19877 (or newer)
  • Perform an agent heartbeat
  • Restart Microsoft Internet Information Services (IIS) using the command: “iisreset”

A new Behavioral Threat Protection (BTP) rule has been added to notify XDR customers about exploitation attempts:

The alert can be displayed in two forms, depending on whether you enabled ‘Informative BTP Alerts’ in the agent configuration

Alert name Alert Description
Informative BTP Alerts enabled  Webserver Exploitation - 286099623 Exchange ProxyNotShell CVE-2022-41040 variant - Behavioral threat detected (rule: bioc.sync.exchange_proxynotshell_cve_2022_41040)
Informative BTP Alerts disabled Behavioral Threat Detected Behavioral threat detected (rule: bioc.sync.exchange_proxynotshell_cve_2022_41040)

As part of the Cortex XDR multi-layer protection approach, additional already existing Behavioral Threat Protection rules are capable of detecting and preventing the dropping of malicious webshells from a Microsoft Exchange server; those will come into effect until the rule above goes into block mode in the near future.

The malicious URLs and IPs have been released to Advanced URL Filtering and Built-in External Dynamic Lists, respectively.

Prisma Cloud Web-Application and API Security (WAAS) customers receive protections from this threat through the ProxyShell custom rule.

If you think you may have been compromised or have an urgent matter, you can get in touch with the Unit 42 Incident Response team or call:

  • North America Toll-Free: 866.486.4842 (866.4.UNIT42)
  • EMEA: +31.20.299.3130
  • APAC: +65.6983.8730
  • Japan: +81.50.1790.0200

As further information emerges or additional detections and protections are put into place, Palo Alto Networks will update this publication accordingly.

Updated Oct. 11, 2022, at 1:30 p.m. PT.

Text extracted automatically; images, tables and formatting may be missing. Original: https://unit42.paloaltonetworks.com/proxynotshell-cve-2022-41040-cve-2022-41082/