Atlantiraptor Docs

Microsoft 365 and Entra ID breach hunting

Atlantiraptor hunts a customer’s Microsoft 365 tenant from the server, alongside the endpoint hunts: sign-ins, Entra ID directory changes, the Exchange, SharePoint and OneDrive audit log, OAuth apps and mailbox rules. Everything is read-only; nothing in the tenant is changed.

Code vql/server/cloud (m365_graph(), m365_audit(), geo_distance())
Artifacts artifacts/definitions/Cloud/M365/
Credential secret type Microsoft 365 Creds (tenant_id, client_id, client_secret)
Tests go test ./vql/server/cloud/ runs every hunt against recorded-shape Microsoft API answers in vql/server/cloud/fixtures/m365

What it finds

Every hunt returns the same columns, Time, Severity, Detection, User, IPAddress, Location, Device, Details, so results from several hunts read as one findings list.

Artifact Finds Needs
Cloud.M365.SignIns sign-in from a new country, impossible travel, successful legacy authentication, high-risk sign-ins Entra ID P1/P2
Cloud.M365.TokenTheft one session used from several countries or networks (stolen cookies, AiTM phishing), Entra ID Protection token detections P1/P2; P2 for the detections
Cloud.M365.PasswordSpray password spraying, a successful sign-in from a spraying address, brute force P1/P2
Cloud.M365.MFAChanges MFA methods added or removed; critical when a sign-in from a new country follows free tier; P1/P2 for the follow-up
Cloud.M365.PrivilegedChanges admin roles granted, domain federation changed, Conditional Access deleted or disabled, partner access added free tier (7 days)
Cloud.M365.AppChanges secrets added to apps, permissions granted, app owners added free tier (7 days)
Cloud.M365.OAuthApps third-party apps holding mail/file/directory permissions today, BEC tool watchlist
Cloud.M365.InboxRules current inbox rules that forward outside, delete, hide mail, or have blank names
Cloud.M365.MailForwarding audit log: forwarding, inbox and transport rules, mailbox delegation, impersonation audit log (7 days)
Cloud.M365.MassDownload accounts downloading hundreds of files in an hour audit log (7 days)
Cloud.M365.ExternalSharing many anonymous links or external invitations, sharing to personal mail audit log (7 days)
Cloud.M365.CompromiseAssessment all of the above in one collection
Cloud.M365.Monitor server event: collects all of the logs continuously and raises alerts

Device is the Entra device name of the sign-in when the device is registered. Use it to go from a suspicious sign-in to the laptop: Rapid hunt the host, or open its triage.

Shared single-record rules (role names, risky OAuth scopes, Exchange cmdlets) live in Cloud.M365.Rules and are used both by the hunts and by the monitor.

Retention, and why to run the monitor

Microsoft keeps very little:

  • Entra sign-ins and directory audit events: 7 days on the free tier, 30 days with P1/P2.
  • The Office 365 Management Activity API serves the last 7 days of the unified audit log, and only from the moment its subscription was started.

Cloud.M365.Monitor (Server Events) polls every 5 minutes and keeps every record on the Atlantiraptor server, so evidence is still there months later, and it raises alerts in the shared alert queue as changes happen (default: high and critical). Start it for each customer tenant on day one; the first run starts the audit subscriptions and Microsoft takes up to 12 hours to deliver the first audit content.

Setting up access

Once, for Atlant (multi-tenant app)

In the Entra admin centre of Atlant’s own tenant:

  1. App registrations > New registration: name “Atlantiraptor cloud hunting”, supported account types Accounts in any organizational directory (multitenant). No redirect URI is needed.
  2. API permissions > Add a permission, all of type Application:
    • Microsoft Graph: AuditLog.Read.All, Directory.Read.All, MailboxSettings.Read, IdentityRiskEvent.Read.All
    • Office 365 Management APIs: ActivityFeed.Read
  3. Certificates & secrets > New client secret. Store the value in Atlant’s vault; it is shown once. Note the Application (client) ID.

A customer who would rather not consent to Atlant’s app can register the same app in their own tenant (single tenant) and give Atlant its client ID and secret instead.

Per customer

  1. The customer’s Global Administrator (or Privileged Role Administrator) opens https://login.microsoftonline.com/<customer-tenant-id>/adminconsent?client_id=<client-id> and accepts. This creates the app in their tenant with the permissions above.
  2. Check the unified audit log is on (Microsoft Purview > Audit; it is on by default for most tenants).
  3. In Atlantiraptor, Secrets > Microsoft 365 Creds > Add: name it after the customer, fill in the customer’s tenant ID (the GUID; the Management API does not accept the domain name), Atlant’s client ID and secret. Grant the secret to the users who run the hunts, and to the user who configures Cloud.M365.Monitor.
  4. Run Cloud.M365.CompromiseAssessment with M365Secret set to the secret’s name, and add Cloud.M365.Monitor under Server Events.

If a hunt logs “lacks a permission”, “not consented” or “needs an Entra ID P1 or P2 licence”, the hint in the message says which of the steps above is missing.

VQL

SELECT * FROM m365_graph(secret="contoso", path="/auditLogs/directoryAudits",
    time_field="activityDateTime", start=now() - 86400)

SELECT * FROM m365_audit(secret="contoso", content_type="Audit.Exchange",
    start=now() - 3 * 86400)
WHERE Operation =~ "InboxRule"

m365_graph() only issues GET requests to graph.microsoft.com, follows @odata.nextLink, and with follow=TRUE keeps polling with an overlap and drops repeats by id. m365_audit() lists content in 24-hour windows (the API’s limit), clamps the start to 7 days, reads each content blob once, and adds the common audit fields as NULL when a record lacks them. Both retry throttling (429, honouring Retry-After) and 5xx answers, cache tokens per credential, and refuse paging links that point anywhere but Microsoft, so a token cannot be sent elsewhere.

Edit this page on GitHub

© 2026 Atlant Security EOOD. Atlantiraptor is free software under the GNU Affero General Public License v3. It is based on Velociraptor by Velocidex, and keeps its copyright notices. Velociraptor is a trademark of its owner; Atlantiraptor is not affiliated with or endorsed by it.