detecting-email-account-compromise

Detect compromised O365 and Google Workspace accounts via inbox rules, sign-in logs, and OAuth grants.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill detecting-email-account-compromise
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: detecting-email-account-compromise
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/incident-response/detecting-email-account-compromise
Command: npx skills add https://github.com/xalgord/xalgorix --skill detecting-email-account-compromise

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests, msal.

What problem does it solve?

Email account compromise and business email compromise (BEC) often go undetected because attackers hide persistence in inbox forwarding rules, illicit OAuth consent grants, and legacy-protocol sign-ins. This Skill gives SOC analysts a structured procedure to find compromised Microsoft 365 and Google Workspace mailboxes before attackers exfiltrate data or commit payment fraud.

Core Features & Use Cases

  • Inbox Rule Analysis: Enumerate mailbox rules via Microsoft Graph to find external forwarding, deletion rules, and keyword-matching rules targeting terms like "invoice" or "payment".
  • Sign-In Anomaly Detection: Query Azure AD sign-in logs for impossible travel, suspicious locations, and unusual user agents such as python-requests or curl.
  • OAuth Persistence Hunting: Audit consent grants and service principals for apps holding Mail.ReadWrite or Mail.Send permissions that survive password resets.
  • Use Case: After a user reports a suspicious email, an analyst follows the steps to enumerate all three forwarding locations (inbox rules, transport rules, ForwardingSMTPAddress), cross-corroborate sign-ins with follow-on actions, and produce a JSON compromise report with severity ratings.

Quick Start

Investigate whether the mailbox [email protected] shows signs of compromise by checking its inbox rules, recent sign-in locations, and OAuth consent grants.

Frequently Asked Questions about detecting-email-account-compromise

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect a compromised Office 365 email account?

Check three forwarding locations: inbox rules via /users/{id}/mailFolders/inbox/messageRules, transport rules, and the mailbox ForwardingSMTPAddress. Then correlate with Azure AD sign-in logs for impossible travel and suspicious user agents like python-requests.

How to find malicious inbox forwarding rules with Microsoft Graph?

Query the messageRules endpoint for each monitored mailbox and flag rules with ForwardTo or RedirectTo external addresses, DeleteMessage actions, or keyword matching on financial terms like invoice, payment, or wire.

Why does account compromise persist after a password reset?

Illicit OAuth consent grants survive password resets because refresh tokens remain valid. Audit Consent to application events in the Unified Audit Log and review servicePrincipals holding Mail.ReadWrite or Mail.Send permissions.

What permissions are needed to investigate email compromise with Microsoft Graph?

You need an app registration with Mail.Read and AuditLog.Read.All permissions, plus Unified Audit Logging enabled. Azure AD P1/P2 is required for risk detection APIs, and Python 3.9+ with requests and msal handles authentication.

How do I reduce false positives in impossible travel alerts?

Baseline each user's normal ASNs, clients, and known forwarding destinations first. Confirm a hit only when the suspect sign-in ties to a legacy-auth protocol or unusual user agent plus a follow-on action like rule creation or mass mail reads.