THREAT-BEC-OAuthDeviceCode IBM QRadar · QRadar

Detect Business Email Compromise via OAuth Device Code Flow Phishing in IBM QRadar

OAuth Device Code Flow phishing is a prevalent Business Email Compromise (BEC) technique actively used by Scattered Spider, Storm-2372, and nation-state actors including Midnight Blizzard. The attacker sends a phishing message containing a Microsoft device code (a short alphanumeric code from https://microsoft.com/devicelogin), social-engineered to appear as an IT helpdesk request, MFA enrollment notification, or remote support session. When the victim enters the code, the attacker receives a valid OAuth access token and refresh token for the victim's Microsoft 365 account — with no password required. The attacker then has full access to email, Teams, SharePoint, OneDrive, and any M365 service the victim is licensed for. Refresh tokens may persist for 90 days, providing long-term access even after password reset. This technique bypasses MFA entirely because the device code flow is a legitimate Microsoft authentication mechanism.

MITRE ATT&CK

Tactic
Credential Access Collection

QRadar Detection Query

IBM QRadar (QRadar)
sql
SELECT
  DATEFORMAT(starttime, 'YYYY-MM-dd HH:mm:ss') AS EventTime,
  sourceip AS SourceIP,
  username AS Username,
  LOGSOURCENAME(logsourceid) AS LogSource,
  "Operation",
  "AuthenticationDetails",
  "Parameters",
  CASE
    WHEN "Operation" = 'UserLoggedIn' AND "AuthenticationDetails" ILIKE '%deviceCode%' THEN 'DEVICE_CODE_AUTH'
    WHEN "Operation" IN ('New-InboxRule', 'Set-InboxRule') AND "Parameters" ILIKE '%ForwardTo%' THEN 'INBOX_FORWARD_RULE'
    WHEN "Operation" IN ('New-InboxRule', 'Set-InboxRule') AND "Parameters" ILIKE '%DeleteMessage%' THEN 'INBOX_DELETE_RULE'
    ELSE 'OTHER'
  END AS DetectionType
FROM events
WHERE
  LOGSOURCETYPEID = 397
  AND starttime > NOW() - 86400000
  AND (
    ("Operation" = 'UserLoggedIn' AND "AuthenticationDetails" ILIKE '%deviceCode%')
    OR (
      "Operation" IN ('New-InboxRule', 'Set-InboxRule')
      AND ("Parameters" ILIKE '%ForwardTo%' OR "Parameters" ILIKE '%DeleteMessage%' OR "Parameters" ILIKE '%RedirectTo%')
    )
  )
ORDER BY starttime DESC
high severity high confidence

QRadar AQL detecting OAuth device code authentication and suspicious inbox rule creation in O365 audit logs.

Data Sources

IBM QRadar O365 DSMMicrosoft 365 Defender via QRadar

Required Tables

events

False Positives & Tuning

  • Legitimate device enrollment
  • IT administrator inbox rule configuration
Download portable Sigma rule (.yml)

Other platforms for THREAT-BEC-OAuthDeviceCode


Testing Methodology

Validate this detection against 2 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1OAuth Device Code Flow Token Request (Simulated Phishing)

    Expected signal: Azure AD Sign-in logs record a DeviceCode flow initiation. When user enters the code, AADSignInLogs records a successful authentication with AuthenticationProtocol=deviceCode.

  2. Test 2Create BEC Inbox Forwarding Rule via Exchange Online PowerShell

    Expected signal: O365 Unified Audit Log records New-InboxRule operation with ForwardTo parameter for the authenticated user.

Unlock Pro Content

Get the full detection package for THREAT-BEC-OAuthDeviceCode including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections