Detecting Email Account Compromise
Overview
Email account compromise (EAC) is a prevalent attack vector where adversaries gain unauthorized access to mailboxes to exfiltrate sensitive data, conduct business email compromise (BEC), or establish persistence through inbox rule manipulation. Attackers commonly create forwarding rules to siphon emails, delete rules to hide evidence, or use OAuth tokens for persistent access. Detection relies on analyzing Microsoft 365 Unified Audit Logs, Azure AD sign-in logs for impossible travel or suspicious locations, inbox rule creation events (Set-InboxRule, New-InboxRule), and Microsoft Graph API access patterns. Key indicators include forwarding rules to external addresses, rules that delete or move messages matching keywords like "invoice" or "payment", and sign-ins from unusual user agents such as python-requests.
Prerequisites
- Microsoft 365 with Unified Audit Logging enabled
- Azure AD P1/P2 for risk detection APIs
- Python 3.9+ with
requests,msallibraries - Microsoft Graph API application registration with Mail.Read, AuditLog.Read.All permissions
- Understanding of OAuth2 client credential flows
Steps
- Export audit logs or connect to Microsoft Graph API using MSAL authentication
- Query inbox rules for all monitored mailboxes via
/users/{id}/mailFolders/inbox/messageRules - Analyze rules for external forwarding (ForwardTo, RedirectTo external addresses)
- Detect suspicious rule patterns: deletion rules, keyword-matching rules targeting financial terms
- Query sign-in logs via
/auditLogs/signInsfor unusual locations and impossible travel - Check for suspicious user agent strings (python-requests, PowerShell, curl)
- Identify OAuth application consent grants for suspicious third-party apps
- Correlate findings across users to detect campaign-level compromise
- Generate compromise indicators report with severity scores
Expected Output
A JSON report listing compromised or suspicious accounts, malicious inbox rules detected, impossible travel events, suspicious OAuth grants, and recommended containment actions with severity ratings.
Verification Criteria
Confirm successful execution by validating:
- [ ] All prerequisite tools and access requirements are satisfied
- [ ] Each workflow step completed without errors
- [ ] Output matches expected format and contains expected data
- [ ] No security warnings or misconfigurations detected
- [ ] Results are documented and evidence is preserved for audit
Compliance Framework Mapping
This skill supports compliance evidence collection across multiple frameworks:
- SOC 2: CC7.3 (Incident Identification), CC7.4 (Incident Response), CC7.5 (Recovery)
- ISO 27001: A.16.1 (Security Incident Management)
- NIST 800-53: IR-1 through IR-10 (Incident Response Family)
- NIST CSF: RS.RP (Response Planning), RS.CO (Communications), RC.RP (Recovery Planning)
Claw GRC Tip: When this skill is executed by a registered agent, compliance evidence is automatically captured and mapped to the relevant controls in your active frameworks.
Deploying This Skill with Claw GRC
Agent Execution
Register this skill with your Claw GRC agent for automated execution:
# Install via CLI
npx claw-grc skills add detecting-email-account-compromise
# Or load dynamically via MCP
grc.load_skill("detecting-email-account-compromise")
Audit Trail Integration
When executed through Claw GRC, every step of this skill generates tamper-evident audit records:
- SHA-256 chain hashing ensures no step can be modified after execution
- Evidence artifacts (configs, scan results, logs) are automatically attached to relevant controls
- Trust score impact — successful execution increases your agent's trust score
Continuous Compliance
Schedule this skill for recurring execution to maintain continuous compliance posture. Claw GRC monitors for drift and alerts when re-execution is needed.