---
name: cyberstrikeus/T1070.008_clear-mailbox-data
source: https://app.decimal.ai/s/cyberstrikeus-t1070-008-clear-mailbox-data@1/SKILL.md
source_sha256: 9f95853999e8
---

# T1070.008 Clear Mailbox Data

> **Sub-technique of:** T1070

## High-Level Description

Adversaries may modify mail and mail application data to remove evidence of their activity. Email applications allow users and other programs to export and delete mailbox data via command line tools or use of APIs. Mail application data can be emails, email metadata, or logs generated by the application or operating system, such as export requests.

Adversaries may manipulate emails and mailbox data to remove logs, artifacts, and metadata, such as evidence of Phishing/Internal Spearphishing, Email Collection, Mail Protocols for command and control, or email-based exfiltration such as Exfiltration Over Alternative Protocol. For example, to remove evidence on Exchange servers adversaries have used the <code>ExchangePowerShell</code> PowerShell module, including <code>Remove-MailboxExportRequest</code> to remove evidence of mailbox exports. On Linux and macOS, adversaries may also delete emails through a command line utility called <code>mail</code> or use AppleScript to interact with APIs on macOS.

Adversaries may also remove emails and metadata/headers indicative of spam or suspicious activity (for example, through the use of organization-wide transport rules) to reduce the likelihood of malicious emails being detected by security products.

## Kill Chain Phase

- Defense Evasion (TA0005)

**Platforms:** Linux, macOS, Office Suite, Windows

## What to Check

- [ ] Identify if Clear Mailbox Data technique is applicable to target environment
- [ ] Check Linux systems for indicators of Clear Mailbox Data
- [ ] Check macOS systems for indicators of Clear Mailbox Data
- [ ] Check Office Suite systems for indicators of Clear Mailbox Data
- [ ] Verify mitigations are bypassed or absent (3 known mitigations)
- [ ] Assess detection coverage (1 detection strategies)

## How to Test

### Atomic Red Team Tests

The following tests are from [Atomic Red Team](https://github.com/redcanaryco/atomic-red-team) and provide actionable ways to test this technique:

### Atomic Test 1: Copy and Delete Mailbox Data on Windows

Copies and deletes mail data on Windows

**Supported Platforms:** windows
**Elevation Required:** Yes

```powershell
New-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data\copy" -ItemType Directory -ErrorAction Ignore
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data" -Exclude copy | ForEach-Object { Copy-Item -Path $_.FullName -Destination "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data\copy" -Recurse -Force -ErrorAction Ignore }
Remove-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data\copy" -Recurse -Force -ErrorAction Ignore
```

### Atomic Test 2: Copy and Delete Mailbox Data on Linux

Copies and deletes mail data on Linux

**Supported Platforms:** linux
**Elevation Required:** Yes

```bash
mkdir -p /var/spool/mail/copy && for file in /var/spool/mail/*; do if [ "$(basename "$file")" != "copy" ]; then cp -R "$file" /var/spool/mail/copy/; fi; done && rm -rf /var/spool/mail/copy/*
```

**Dependencies:**

- Create dummy file in /var/spool/mail/ if no files exist

### Atomic Test 3: Copy and Delete Mailbox Data on macOS

Copies and deletes mail data on macOS

**Supported Platforms:** macos
**Elevation Required:** Yes

```bash
mkdir ~/Library/Mail/copy
cp -R ~/Library/Mail/* ~/Library/Mail/copy
rm -rf ~/Library/Mail/copy/*
```

### Atomic Test 4: Copy and Modify Mailbox Data on Windows

Copies and modifies mail data on Windows

**Supported Platforms:** windows
**Elevation Required:** Yes

```powershell
New-Item -Path "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data\copy" -ItemType Directory -ErrorAction Ignore
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data" -Exclude copy | ForEach-Object { Copy-Item -Path $_.FullName -Destination "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data\copy" -Recurse -Force -ErrorAction Ignore }
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Comms\Unistore\data\copy" -File | ForEach-Object { Add-Content -Path $_.FullName -Value "Modification for Atomic Red Test" -ErrorAction Ignore }
```

### Atomic Test 5: Copy and Modify Mailbox Data on Linux

Copies and modifies mail data on Linux

**Supported Platforms:** linux
**Elevation Required:** Yes

```bash
mkdir -p /var/spool/mail/copy; for file in /var/spool/mail/*; do if [ "$(basename "$file")" != "copy" ]; then cp -R "$file" /var/spool/mail/copy/; if [ -f "/var/spool/mail/copy/$(basename "$file")" ]; then echo "Modification for Atomic Red Test" >> "/var/spool/mail/copy/$(basename "$file")"; fi; fi; done
```

**Dependencies:**

- Create dummy file in /var/spool/mail/ if no files exist

### Manual Testing

If Atomic Red Team tests are not applicable, manually verify the technique by:

1. **Identify Attack Surface**: Determine if the target environment is susceptible to Clear Mailbox Data by examining the target platforms (Linux, macOS, Office Suite).

2. **Assess Existing Defenses**: Review whether mitigations for T1070.008 are in place. If defenses are absent or misconfigured, this technique may be exploitable.

3. **Execute Test**: Use tools and methods described in the MITRE ATT&CK page and external references below.

## Remediation Guide

### M1022 Restrict File and Directory Permissions

Protect generated event files that are stored locally with proper permissions and authentication and limit opportunities for adversaries to increase privileges by preventing Privilege Escalation opportunities.

### M1047 Audit

In an Exchange environment, Administrators can use `Get-TransportRule` / `Remove-TransportRule` to discover and remove potentially malicious transport rules.

### M1029 Remote Data Storage

Automatically forward mail data and events to a log server or data repository to prevent conditions in which the adversary can locate and manipulate data on the local system. When possible, minimize time delay on event reporting to avoid prolonged storage on the local system.

## Detection

### Behavioral Detection of Mailbox Data and Log Deletion for Anti-Forensics

## Risk Assessment

| Finding                                 | Severity | Impact          |
| --------------------------------------- | -------- | --------------- |
| Clear Mailbox Data technique applicable | High     | Defense Evasion |

## CWE Categories

| CWE ID  | Title                        |
| ------- | ---------------------------- |
| CWE-693 | Protection Mechanism Failure |

## References

- [Volexity SolarWinds](https://www.volexity.com/blog/2020/12/14/dark-halo-leverages-solarwinds-compromise-to-breach-organizations/)
- [Cybereason Cobalt Kitty 2017](https://cdn2.hubspot.net/hubfs/3354902/Cybereason%20Labs%20Analysis%20Operation%20Cobalt%20Kitty.pdf)
- [mailx man page](https://man7.org/linux/man-pages/man1/mailx.1p.html)
- [ExchangePowerShell Module](https://docs.microsoft.com/en-us/powershell/module/exchange/?view=exchange-ps#mailboxes)
- [Microsoft OAuth Spam 2022](https://www.microsoft.com/en-us/security/blog/2022/09/22/malicious-oauth-applications-used-to-compromise-email-servers-and-spread-spam/)
- [Atomic Red Team - T1070.008](https://github.com/redcanaryco/atomic-red-team/tree/master/atomics/T1070.008)
- [MITRE ATT&CK - T1070.008](https://attack.mitre.org/techniques/T1070/008)