security analyst security skill risk: medium
Email Account Compromise Detection Procedures
Provides overview, prerequisites, and nine analysis steps for detecting compromised O365 and Google Workspace accounts via inbox rules, sign-in logs, and OAuth grants, ending with…
- Policy sensitive
- Human review
SKILL 4 files · 2 folders
SKILL.md
---
name: detecting-email-account-compromise
description: "Detect compromised O365 and Google Workspace email accounts by analyzing inbox rule creation, suspicious sign-in"
---
# 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.
## When to Use
- When investigating security incidents that require detecting email account compromise
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
## Prerequisites
- Microsoft 365 with Unified Audit Logging enabled
- Azure AD P1/P2 for risk detection APIs
- Python 3.9+ with `requests`, `msal` libraries
- Microsoft Graph API application registration with Mail.Read, AuditLog.Read.All permissions
- Understanding of OAuth2 client credential flows
## Steps
1. Export audit logs or connect to Microsoft Graph API using MSAL authentication
2. Query inbox rules for all monitored mailboxes via `/users/{id}/mailFolders/inbox/messageRules`
3. Analyze rules for external forwarding (ForwardTo, RedirectTo external addresses)
4. Detect suspicious rule patterns: deletion rules, keyword-matching rules targeting financial terms
5. Query sign-in logs via `/auditLogs/signIns` for unusual locations and impossible travel
6. Check for suspicious user agent strings (python-requests, PowerShell, curl)
7. Identify OAuth application consent grants for suspicious third-party apps
8. Correlate findings across users to detect campaign-level compromise
9. 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.
REQUIRED CONTEXT
- Microsoft 365 Unified Audit Logs
- Azure AD sign-in logs
- inbox rule data via Microsoft Graph API
EXPECTED OUTPUT
- Format
- json
- Schema
- json · compromised or suspicious accounts, malicious inbox rules detected, impossible travel events, suspicious OAuth grants, recommended containment actions with severity ratings
- Constraints
-
- JSON report listing compromised accounts
- include malicious inbox rules, impossible travel events, suspicious OAuth grants
- include recommended containment actions with severity ratings
SUCCESS CRITERIA
- Generate compromise indicators report with severity scores
CAVEATS
- Dependencies
-
- Microsoft 365 with Unified Audit Logging enabled
- Azure AD P1/P2 for risk detection APIs
- Python 3.9+ with `requests`, `msal` libraries
- Microsoft Graph API application registration with Mail.Read, AuditLog.Read.All permissions
- Understanding of OAuth2 client credential flows
- Missing context
-
- Input format or sample data/logs to analyze
- Exact output JSON schema or example
- Google Workspace equivalent queries or APIs
- Ambiguities
-
- Description cuts off mid-sentence at 'suspicious sign-in'
- Mentions Google Workspace in title/overview but provides no steps or details for it
QUALITY
- OVERALL
- 0.70
- CLARITY
- 0.85
- SPECIFICITY
- 0.70
- REUSABILITY
- 0.60
- COMPLETENESS
- 0.65
IMPROVEMENT SUGGESTIONS
- Add input placeholder such as 'Given the following audit logs: [LOGS]'
- Expand steps with parallel Google Workspace sections or note Microsoft-only scope
- Define the precise JSON structure and fields expected in the report
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR SECURITY ANALYST
- Ransomware Network Indicators Analyzer security analyst security
- APT TTP Mapping with MITRE Navigator security analyst security
- Linux Persistence Mechanisms Analyzer security analyst security
- Azure AD Lateral Movement KQL Detector security analyst security
- Kerberos Golden Ticket Forgery Detector security analyst security
- LOLBAS Abuse Detection with Sigma Rules security analyst security
- Shadow IT Cloud Usage Detector security analyst security
- Registry Run Key Persistence Detection Guide security analyst security
- Detect Risky OAuth Consent Grants in Entra ID security analyst security
- Windows Service Installation Threat Hunter security analyst security
- Web Server Log Intrusion Analyzer security analyst security
- RDP Brute Force Event Log Analyzer security analyst security
- Rekall Memory Forensics Artifact Extractor security analyst security
- Azure Activity Logs Threat Analyzer security analyst security
- Scapy Network Packet Analysis Guide security analyst security
- TLS Certificate Transparency Log Analyzer security analyst security
- Cobalt Strike Malleable C2 Profile Analyzer security analyst security
- Credential Stuffing Auth Log Analyzer security analyst security
- MISP Threat Intelligence Sharing with PyMISP security analyst security
- MISP Threat Landscape Analysis Guide security analyst security
- Malicious Scheduled Task Sysmon Detector security analyst security
- Kerberos Pass-the-Ticket Attack Detector security analyst security
- NTLM Relay Attack Event Log Analyzer security analyst security
- Linux Memory Forensics with LiME and Volatility security analyst security
- Insider Data Exfiltration DLP Analyzer security analyst security