Exchange Mailbox Export via PowerShell
Identifies the use of the Exchange PowerShell cmdlet, New-MailBoxExportRequest, to export the contents of a primary mailbox or archive to a .pst file. Adversaries may target user email to collect sensitive information.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/01/11"
3integration = ["windows"]
4maturity = "production"
5min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
6min_stack_version = "8.14.0"
7updated_date = "2024/10/28"
8
9[rule]
10author = ["Elastic"]
11description = """
12Identifies the use of the Exchange PowerShell cmdlet, New-MailBoxExportRequest, to export the contents of a primary mailbox or archive to a .pst file. Adversaries may target user email to collect sensitive information.
13"""
14false_positives = ["Legitimate exchange system administration activity."]
15from = "now-9m"
16index = ["winlogbeat-*", "logs-windows.powershell*"]
17language = "kuery"
18license = "Elastic License v2"
19name = "Exchange Mailbox Export via PowerShell"
20note = """## Triage and analysis
21
22### Investigating Exchange Mailbox Export via PowerShell
23
24The `New-MailBoxExportRequest` cmdlet is used to begin the process of exporting contents of a primary mailbox or archive to a .pst file. Note that this is done on a per-mailbox basis and this cmdlet is available only in on-premises Exchange.
25Attackers can abuse this functionality in preparation for exfiltrating contents, which is likely to contain sensitive and strategic data.
26
27#### Possible investigation steps
28
29- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
30- Investigate other alerts associated with the user/host during the past 48 hours.
31- Investigate the export operation:
32 - Identify the user account that performed the action and whether it should perform this kind of action.
33 - Contact the account owner and confirm whether they are aware of this activity.
34 - Check if this operation was approved and performed according to the organization's change management policy.
35 - Retrieve the operation status and use the `Get-MailboxExportRequest` cmdlet to review previous requests.
36 - By default, no group in Exchange has the privilege to import or export mailboxes. Investigate administrators that assigned the "Mailbox Import Export" privilege for abnormal activity.
37- Investigate if there is a significant quantity of export requests in the alert timeframe. This operation is done on a per-mailbox basis and can be part of a mass export.
38- If the operation was completed successfully:
39 - Check if the file is on the path specified in the command.
40 - Investigate if the file was compressed, archived, or retrieved by the attacker for exfiltration.
41
42### False positive analysis
43
44- This mechanism can be used legitimately. Analysts can dismiss the alert if the administrator is aware of the activity and it is done with proper approval.
45
46### Response and remediation
47
48- Initiate the incident response process based on the outcome of the triage.
49- If the involved host is not the Exchange server, isolate the host to prevent further post-compromise behavior.
50- Use the `Remove-MailboxExportRequest` cmdlet to remove fully or partially completed export requests.
51- Prioritize cases that involve personally identifiable information (PII) or other classified data.
52- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
53- Review the privileges of users with the "Mailbox Import Export" privilege to ensure that the least privilege principle is being followed.
54- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
55- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
56- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
57"""
58references = [
59 "https://www.volexity.com/blog/2020/12/14/dark-halo-leverages-solarwinds-compromise-to-breach-organizations/",
60 "https://docs.microsoft.com/en-us/powershell/module/exchange/new-mailboxexportrequest?view=exchange-ps",
61 "https://www.elastic.co/security-labs/siestagraph-new-implant-uncovered-in-asean-member-foreign-ministry",
62]
63risk_score = 47
64rule_id = "54a81f68-5f2a-421e-8eed-f888278bb712"
65severity = "medium"
66tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Collection", "Resources: Investigation Guide", "Data Source: PowerShell Logs"]
67timestamp_override = "event.ingested"
68type = "query"
69
70query = '''
71event.category:process and host.os.type:windows and
72 powershell.file.script_block_text : "New-MailboxExportRequest"
73'''
74
75[[rule.filters]]
76[rule.filters.meta]
77negate = true
78[rule.filters.query.wildcard."file.path"]
79"case_insensitive" = true
80"value" = "?:\\\\Users\\\\*\\\\AppData\\\\Roaming\\\\Microsoft\\\\Exchange\\\\RemotePowerShell\\\\*"
81
82[[rule.filters]]
83[rule.filters.meta]
84negate = true
85[rule.filters.query.wildcard."file.path"]
86"case_insensitive" = true
87"value" = "?:\\\\Users\\\\*\\\\AppData\\\\Local\\\\Temp\\\\tmp_????????.???\\\\tmp_????????.???.ps?1"
88
89[[rule.filters]]
90[rule.filters.meta]
91negate = true
92[rule.filters.query.wildcard."file.path"]
93"case_insensitive" = true
94"value" = "?:\\\\Windows\\\\TEMP\\\\tmp_????????.???\\\\tmp_????????.???.ps?1"
95
96[[rule.threat]]
97framework = "MITRE ATT&CK"
98[[rule.threat.technique]]
99id = "T1005"
100name = "Data from Local System"
101reference = "https://attack.mitre.org/techniques/T1005/"
102
103[[rule.threat.technique]]
104id = "T1114"
105name = "Email Collection"
106reference = "https://attack.mitre.org/techniques/T1114/"
107
108[[rule.threat.technique.subtechnique]]
109id = "T1114.001"
110name = "Local Email Collection"
111reference = "https://attack.mitre.org/techniques/T1114/001/"
112
113[[rule.threat.technique.subtechnique]]
114id = "T1114.002"
115name = "Remote Email Collection"
116reference = "https://attack.mitre.org/techniques/T1114/002/"
117
118
119[rule.threat.tactic]
120id = "TA0009"
121name = "Collection"
122reference = "https://attack.mitre.org/tactics/TA0009/"
Triage and analysis
Investigating Exchange Mailbox Export via PowerShell
The New-MailBoxExportRequest
cmdlet is used to begin the process of exporting contents of a primary mailbox or archive to a .pst file. Note that this is done on a per-mailbox basis and this cmdlet is available only in on-premises Exchange.
Attackers can abuse this functionality in preparation for exfiltrating contents, which is likely to contain sensitive and strategic data.
Possible investigation steps
- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Investigate the export operation:
- Identify the user account that performed the action and whether it should perform this kind of action.
- Contact the account owner and confirm whether they are aware of this activity.
- Check if this operation was approved and performed according to the organization's change management policy.
- Retrieve the operation status and use the
Get-MailboxExportRequest
cmdlet to review previous requests. - By default, no group in Exchange has the privilege to import or export mailboxes. Investigate administrators that assigned the "Mailbox Import Export" privilege for abnormal activity.
- Investigate if there is a significant quantity of export requests in the alert timeframe. This operation is done on a per-mailbox basis and can be part of a mass export.
- If the operation was completed successfully:
- Check if the file is on the path specified in the command.
- Investigate if the file was compressed, archived, or retrieved by the attacker for exfiltration.
False positive analysis
- This mechanism can be used legitimately. Analysts can dismiss the alert if the administrator is aware of the activity and it is done with proper approval.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- If the involved host is not the Exchange server, isolate the host to prevent further post-compromise behavior.
- Use the
Remove-MailboxExportRequest
cmdlet to remove fully or partially completed export requests. - Prioritize cases that involve personally identifiable information (PII) or other classified data.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Review the privileges of users with the "Mailbox Import Export" privilege to ensure that the least privilege principle is being followed.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- PowerShell Keylogging Script
- PowerShell Mailbox Collection Script
- PowerShell Share Enumeration Script
- PowerShell Suspicious Discovery Related Windows API Functions
- PowerShell Suspicious Script with Audio Capture Capabilities