How to Detect Compromised Microsoft 365 Accounts
How to Detect Compromised Microsoft 365 Accounts
Account compromises are increasing in frequency and sophistication. Attackers understand that stolen Microsoft 365 credentials provide access to email, Teams, SharePoint, OneDrive, and the entire Microsoft ecosystem. For MSPs and MSSPs, detecting compromised accounts quickly is critical—a single compromised admin account can lead to lateral movement across an entire tenant.
This guide provides practical techniques to detect account compromise and investigate suspicious activity in Microsoft 365.
Understanding Account Compromise Indicators
Before diving into detection methods, understand common compromise indicators:
- Unusual sign-in locations: Accounts accessed from countries they’ve never connected from before
- Impossible travel: Account access from two locations too far apart geographically to be possible
- Unusual sign-in times: Access during off-hours from users who normally work business hours
- Bulk email activity: Sudden spike in email sends, often phishing or malware distribution
- File access anomalies: Unusual file downloads or access to sensitive SharePoint sites
- Mail forwarding rules: Rules created to forward all email to external addresses
- Administrative changes: Role assignments or security policy modifications by compromised accounts
- Device changes: Sudden changes in device type, location, or OS
Detection Method 1: Azure AD Sign-In Logs Analysis
Where to Look:
- Navigate to Azure AD > Sign-in logs
- You’ll see all sign-in activity across your tenant
Key Filters to Apply:
Filter by Risk Level:
- Click Sign-in risk level column header to sort by risk
- High-risk sign-ins are flagged by Azure AD’s risk engine
- Review all medium and high-risk attempts immediately
Filter by Location Anomalies:
- Set Date range to last 30 days
- Export to Excel (Show: 250 results)
- Identify unique countries in Location column
- Compare against known user locations
Look for:
- First-time countries (especially high-risk nations)
- Geographically impossible logins
- VPN/Proxy countries your organization doesn’t operate in
Filter by Device Information:
- Click Device info column
- Look for unmanaged devices or unusual device types
- Compromised account attackers often access from personal devices
Detection Method 2: Azure AD Anomalous Activity Alerts
Azure AD Premium P2 includes automated anomaly detection:
- Navigate to Azure AD > Identity Protection > Overview
- Review Risky users and Risky sign-ins dashboards
- View detected anomalies including:
- Atypical travel alerts
- Sign-ins from anonymous IP addresses
- Sign-ins from malware-infected devices
- Unfamiliar sign-in properties
Investigate Risky User:
- Click user to view details
- Review timeline of detections
- Check all sign-ins from suspicious locations
- Look for lateral movement attempts
The risk engine is sophisticated—investigate every P2 detection, as they often precede account takeover.
Detection Method 3: Exchange Online Audit Logs
Email-based compromise indicators are often the most revealing:
Enable Mailbox Auditing:
- Exchange Admin Center > Compliance > Audit
- Ensure Mailbox auditing is on by default is enabled
- Verify all users have mailbox auditing enabled
Review Suspicious Email Activity:
- Exchange Admin Center > Compliance > Audit > Mailbox audit log search
- Search for specific user
- Filter operations: MailboxLogin, SendAs, SendOnBehalf, Create
- Look for:
- Logins from unusual locations/times
- SendAs activity (email sent as the user but from attacker)
- Unusual folder access patterns
Check Mail Forwarding Rules:
- Exchange Admin Center > Mail flow > Rules
- Review all forwarding rules
- Look for rules forwarding mail to external addresses
- Check rule creation timestamp and creator
- Disable suspicious rules immediately
Compromised accounts frequently have forwarding rules sending copies of all email to attacker-controlled addresses—this is a critical detection indicator.
Investigate Inbox Rules (Client-Side):
For thorough investigation, check client-side Inbox Rules:
- Use PowerShell to query all user mailboxes
- Command:
Get-Mailbox -ResultSize Unlimited | Get-InboxRule | Where-Object {$_.ForwardTo -ne $null -or $_.RedirectTo -ne $null} - Review results for unexpected forwarding
Detection Method 4: Microsoft Defender for Identity
If clients have E5 licenses, Defender for Identity provides behavioral analysis:
- Access Defender for Identity portal in Microsoft 365 Defender
- Navigate to Identity > Entity insights
- Look for alerts:
- Suspicious modification of group membership
- Suspicious creation of service principal
- Impossible travel alerts
- Atypical bulk operations
- Account enumeration attempts
Defender for Identity uses machine learning to detect behavioral anomalies even before explicit signs of compromise.
Detection Method 5: File Access and Sharing Anomalies
Compromised accounts often exfiltrate data:
SharePoint Activity Monitoring:
- SharePoint Admin Center > Active sites
- Click site, view Activity tab
- Look for:
- Unusual bulk downloads
- Access from new devices/locations
- Sharing of sensitive documents to external addresses
File-Level Auditing:
- Compliance Center > Audit > Start recording user and admin activity
- Search specific user’s file activities
- Filter operations: FileAccessed, FileDownloaded, FolderCreated
- Identify suspicious patterns
OneDrive Sharing Anomalies:
- Review OneDrive Sharing Links in admin center
- Look for shares to external email addresses
- Check share creation timestamp
- Verify against user’s normal behavior
Detection Method 6: Unusual Administrative Activity
Compromised admin accounts can modify security policies:
Check Recent Admin Changes:
- Azure AD > Audit logs
- Filter Activity: Add user to role or Modify directory role
- Verify all recent admin assignments
- Check if users have explained unfamiliar role assignments
Monitor Security Policy Changes:
- Review Conditional Access policy modifications
- Check for disabled MFA requirements
- Verify no one has disabled advanced threat protection
- Audit changes to authentication methods
Attackers often disable security controls to maintain persistent access.
Automated Detection with Sentinel
For enterprise clients, implement Azure Sentinel for sophisticated detection:
- Deploy Microsoft Sentinel workspace
- Connect Azure AD sign-in logs and Audit logs
- Create alert rules for:
- Multiple failed logins followed by success
- Sign-in from impossible travel location
- High-risk user performing administrative actions
- Bulk mail forwarding rule creation
Sentinel provides machine learning-based detection that identifies novel attack patterns.
Incident Response Steps
If you detect a compromised account:
Immediate Actions (Within 1 Hour):
- Reset user password immediately
- Revoke all active sessions (Azure AD > Sessions)
- Disable MFA methods and force re-enrollment
- Remove from privileged groups
- Alert the user and their manager
Investigation (Next 4 Hours):
- Analyze full sign-in timeline (past 30 days)
- Identify all locations and devices used
- Check for forwarding rules and sharing anomalies
- Review mailbox delegation changes
Remediation (Next 24 Hours):
- Delete all suspicious forwarding/inbox rules
- Revoke problematic sharing links
- Force MFA re-enrollment
- Scan user’s devices for malware
- Review data exfiltration scope
Reporting (Ongoing):
- Document timeline of compromise
- Estimate scope of data access/exfiltration
- Report to compliance and legal teams
- Implement changes to prevent recurrence
Best Practices for MSPs
- Proactive Monitoring: Review sign-in logs weekly, not just when breaches occur
- Risk-Based Approach: Prioritize investigation of high-risk indicators first
- Automated Alerting: Set up alerts for specific indicators rather than manual review
- User Communication: Train users to recognize compromise (unusual sent items, password change notifications)
- Documentation: Maintain detailed logs of all investigations for compliance
Conclusion
Detecting compromised Microsoft 365 accounts requires systematic analysis of multiple data sources. By implementing these detection methods, you:
- Identify account compromises within hours, not days
- Prevent lateral movement and data exfiltration
- Minimize incident impact
- Maintain compliance with regulatory requirements
Your ability to rapidly detect and respond to compromises directly protects your clients’ entire Microsoft 365 environments.
Ready to assess your Microsoft 365 security posture? Run a free security assessment at 365 Security Assessment.