Your Agents Are Invisible (Part 1): Onboarding Microsoft-Native Agents and SaaS AI Platforms

Your Agents Are Invisible (Part 1): Onboarding Microsoft-Native Agents and SaaS AI Platforms Agent usage is exploding. Tools for monitoring agents haven't kept up — until now. Agents in Microsoft 365 aren't monitored by default. Here are some tips for using Microsoft Agent 365 and related tools to monitor agents. Solutions discussed in this post: ▸Microsoft Agent 365 provides agent inventory, controls, and monitoring through the M365 admin center. ▸Entra ID features agent identity restrictions via Conditional Access. ▸Defender XDR can track agents through threat detections. ▸Purview finishes off the pack with information protection and compliance. This is part 1 of a two-part series. Part 1 covers the high-level building blocks, onboarding Microsoft-native agents and SaaS AI platforms, and validating the result. Part 2 is the deeper dive: connecting third-party and custom agents to Agent 365 with the SDK. Scope: this post covers onboarding and visibility — getting agents registered, reporting, and huntable. DAVID BROGGY · 2026-06-11 · LAB-VERIFIED AGAINST THE LIVE AGENT 365 BACKEND 01 01 / Getting Started: Agent Use Cases Understand how your organization is using agents and where they will be used. This determines what methods you need for admin controls and monitoring. Use case Where the agent runs Onboarding method Monitoring surfaces Prebuilt Microsoft agents (M365 Copilot agents, Researcher, Analyst) M365 cloud Out of the box — license + connectors Admin center, Defender, Purview Low-code agents built in Copilot Studio M365 cloud / Power Platform Out of the box — license + connectors Admin center, Defender, Purview Custom agents (Azure AI Foundry or your own code) Azure Agent 365 SDK — see Part 2 Admin center, Defender, Purview SaaS AI platforms (Claude Enterprise, ChatGPT Enterprise) Vendor cloud (SaaS) Native connector / marketplace plugin — varies by vendor Admin center, Defender, Purview Developer / CLI agents on workstations Local machines Agent 365 SDK — see Part 2 Admin center, Defender, Purview Standalone AI apps (Claude / ChatGPT Free, Plus, Team) Individual browser (shadow IT) Not onboardable — endpoint telemetry via Defender for Endpoint Defender (network logs), endpoint DLP The first two rows are covered in Onboarding Microsoft-Native Agents below; SaaS platforms and shadow IT have their own section; the SDK rows are covered in Part 2. 02 02 / The Building Blocks Four planes work together. Each has one job, one configuration location, and one place it's used day-to-day: 01 Identity plane — Entra ID Every managed agent is a directory object (an agent identity) with owners, sponsors, permissions, and sign-in logs. This is where governance lives: Conditional Access, risk scoring, least-privilege review. 02 Control plane — M365 admin center The tenant-wide agent registry (inventory, sessions, active users), agent access settings, and the instance approval queue. 03 Telemetry plane — Agent 365 + Defender Agent activity flows through the Agent 365 observability service into Defender's CloudAppEvents hunting table (via the Security-for-AI connectors) and into incidents and alerts. 04 Compliance plane — Purview Audit records, DSPM for AI posture, and DLP over agent interactions. The four planes — identity (Entra), control (M365 admin center), telemetry (Agent 365 + Defender), compliance (Purview). 03 03 / Onboarding Microsoft-Native Agents – Common Steps Copilot Studio and other Microsoft-built agents register their identities and send activity telemetry in the required format automatically. Here are some common points to consider when configuring agent monitoring. 01 License assignment Agent 365 is included in M365 E7 and available as a standalone add-on; assign it in the M365 admin center (Billing > Licenses). Ingestion drops the entire request — still returning 200 — unless at least one user in the tenant has the license assigned. A purchased but unassigned SKU is functionally identical to no license. 02 Defender Security-for-AI connectors Both live in the Defender portal under Settings > Security for AI. The "Microsoft 365" connector feeds activity ingestion into CloudAppEvents, the advanced-hunting table where agent activity lands; with it disconnected, the table is empty. The "Agent 365" connector feeds runtime threat detection — incidents and alerts. Both should be connected. In the lab, telemetry was accepted for days while the disconnected M365 connector kept CloudAppEvents empty. Defender portal > Settings > Security for AI — connect both the Agent 365 and Microsoft 365 connectors. Admin Center: Register your agents With these in place, native agents appear in the M365 admin center Agents blade and register your desired agents. M365 admin center > Agents > All agents — the tenant-wide agent registry. Admin Center: allow users access to agents M365 admin center > Copilot > Settings — allow user access to agents. Choose carefully! 04 04 / Entra ID: Agent Identity and Governance Each managed agent is a first-class identity in Entra — not a user, not an ordinary service principal, but an agent identity with its own governance surface: 01 Inventory the identities Entra ID > Agents > Agent identities lists every agent identity with status, owners, sponsors, and creation date. Reconcile this list against the admin center registry; agents with no owner or sponsor are accountable to no one. 02 Audit the blueprints A blueprint is the parent definition agents are created from. Blueprints configured with broad scopes hand every child agent the same permissions — review blueprints for enumerated, least-privilege scopes before reviewing individual agents. 03 Apply Conditional Access Conditional Access for agent identities can scope to all agent identities with a block control — the high-value pattern blocks on high agent risk, turning an ID Protection risky-agents signal into automatic containment (ID Protection for agents requires Entra ID P2). Build the policy in report-only mode first. Entra admin center > Entra ID > Agents > Agent identities — the agent identity inventory. Entra > Conditional Access > Create new policy from templates — built-in templates for blocking high-risk agent identities, agent users, and assistive agent flows. 05 05 / Purview: Activate Audit for Agent Visibility Purview tracks agent interactions through its Data Security Posture Management (DSPM) for AI setup tasks — activating Microsoft Purview Audit is the required first step. Purview > DSPM > Tasks and actions > Setup tasks — the agent-visibility setup checklist. After the setup tasks: DSPM > AI observability shows agent interaction posture, and DSPM > Discover > Apps and agents lists the AI apps and agents Purview has discovered. 06 06 / Connecting SaaS AI Platforms and Shadow IT Not every third-party AI tool needs SDK work. Enterprise SaaS editions ship varying levels of native integration, and Defender for Endpoint adds a baseline telemetry layer for everything else. AI platform & edition Deployment model Agent 365 (control plane) Defender (CloudAppEvents) Purview (DLP & audit) Claude Enterprise SaaS website / portal Native (via M365 connector / marketplace plugin) Full activity — actions and full user context via the API connector Full scanning — proactive, at rest, and in transit ChatGPT Enterprise SaaS website / portal Partial — visible as a "data source" only Full audit via the Purview-to-Sentinel bridge, plus endpoint telemetry via Defender for Endpoint Full scanning, configured via the Purview Data Map Custom OpenAI agents Azure OpenAI / SDK Full — deep model control Full security telemetry — native AiInteractionEvents table Full logs via SDK hook routing Claude / ChatGPT standalone (Free, Plus, Team) Individual browser (shadow IT) None — unmanaged shadow applications Endpoint network logs only, via Defender for Endpoint network protection Endpoint DLP only (Purview browser extension limits) How logs reach CloudAppEvents CloudAppEvents is fed by Microsoft Defender for Cloud Apps (MDCA). Three independent paths land rows in it: ▸Agent 365 telemetry — agents (native or SDK-onboarded) report to the Agent 365 observability service, which forwards into the table through the Defender Security-for-AI "Microsoft 365" connector (its setup includes the MDCA ingestion). This produces the agent ActionTypes (InvokeAgent, InferenceCall, ExecuteTool*). The SDK is only about getting telemetry into Agent 365 — the Agent-365-to-Defender leg is the same for native and SDK agents. ▸App connectors — MDCA API connectors for SaaS platforms (e.g. the Claude Enterprise connector) deliver full activity with user context, independent of Agent 365. ▸Defender for Endpoint — the MDE-to-MDCA integration forwards endpoint network logs, covering any generative AI app a user touches from a monitored device — including standalone apps that can't be onboarded at all. Endpoint telemetry from Defender for Endpoint When a user on a monitored machine accesses standalone ChatGPT or Claude in a browser, MDE sends the network signals to MDCA. Hunting in CloudAppEvents then shows: ▸the specific user and machine that accessed the tool, ▸the timestamps, URLs, and IP addresses visited, ▸the volume of data uploaded and downloaded during the session. KQL — Surface Endpoint-Driven GenAI Traffic (Defender / CloudAppEvents) CloudAppEvents | where Timestamp > ago(7d) | where ActionType == "Access" | where Application has_any ("ChatGPT", "Claude", "OpenAI") | project Timestamp, Application, AccountDisplayName, IPAddress | sort by Timestamp desc The trade-off: endpoint telemetry never contains the prompt or response text. It shows that a user used the tool and how much data moved — not what was said. Prompt-level visibility requires the Purview Data Map / Sentinel bridge (OpenAI) or the native API connector (Claude Enterprise). 07 07 / Operational Use: Verifying Agents in Defender Agent 365 provides detailed logging to the Defender portal. Use Defender to track all agent activity and create custom threat detections for your agents. Here's an example KQL query for observing activity from a specific agent ID: KQL — Observe Agent Activity (Defender / CloudAppEvents) CloudAppEvents | where Timestamp > ago(1d) | where ActionType in ("InvokeAgent", "InferenceCall", "ExecuteToolBySDK", "ExecuteToolByGateway", "ExecuteToolByMCPServer") | extend d = parse_json(RawEventData) | where tostring(d.TargetAgentId) == "<your-agent-id>" or tostring(d.AgentId) == "<your-agent-id>" | project Timestamp, ActionType, UserId = tostring(d.UserId), AgentId = tostring(d.AgentId), TargetAgentId = tostring(d.TargetAgentId), ConversationId = tostring(d.ConversationId) Some fields of interest: ▸AgentId holds the caller — the calling agent's ID for agent-to-agent calls (agent IDs are listed in the admin center Agents blade), or an all-zeros placeholder when a human starts the run. ▸The invoked agent is in TargetAgentId. ▸A filter on AgentId alone misses every human-triggered InvokeAgent event — filter on both fields. The ActionType values are the Defender-side names of the telemetry span types (the span model is covered in Part 2). What "verified" looks like: rows in CloudAppEvents attributed to the agent and the invoking user, plus session and active-user counts in the admin center Agents blade after the ingestion lag (minutes to hours). HTTP-level success from any sender is not proof — the hunting rows are. Defender > Advanced hunting — agent activity rows; the highlighted human-initiated run shows AgentId as all-zeros with the agent in TargetAgentId. 08 08 / Key Takeaways Summary Start with the use-case map/table Where an agent runs determines its onboarding path: Microsoft-native agents are out of the box; everything else goes through the SDK (Part 2). Agents are not monitored until onboarding is complete Microsoft-native agents become visible only after the tenant is configured (license assignment + Defender connectors). Microsoft-native agents need three things The Agent 365 license assigned to at least one user, both Defender Security-for-AI connectors connected (the M365 connector for activity and hunting, the Agent 365 connector for incidents), and at least one invocation before any activity appears. Govern the identity, not just the telemetry Agent identities live in Entra with owners, sponsors, blueprints, and Conditional Access — ownerless agents and over-scoped blueprints are findings. Enterprise SaaS editions connect; standalone apps don't Claude Enterprise has a native connector, ChatGPT Enterprise connects partially via Purview, and standalone Claude/ChatGPT can't be onboarded — Defender for Endpoint still records who accessed them, from where, and how much data moved, but never the prompt text. Verify in Defender advanced hunting, not dashboards Dashboards lag, and ingestion returns HTTP 200 even when everything is dropped — the CloudAppEvents query is the proof that an agent is actually monitored. Next: Part 2 — connecting third-party and custom agents to Agent 365 with the SDK: the identity model, tenant enablement, telemetry requirements, and validation. / REFERENCES References Microsoft Agent 365 overviewMicrosoft Learn Secure AI agents at scale using Microsoft Agent 365Microsoft Learn Manage agent identities in your organizationMicrosoft Learn Conditional Access for Agent IDMicrosoft Learn Identity Protection for agentsMicrosoft Learn Microsoft Defender for Cloud Apps overviewMicrosoft Learn Microsoft Defender for Endpoint integration with Defender for Cloud AppsMicrosoft Learn Data Security Posture Management for AIMicrosoft Learn PART 1 OF 2 · LAB-VERIFIED FIELD NOTES · IDENTIFIERS ANONYMIZED · SIMPLE-SECURITY.CA

July 10, 2026 · 10 min · David Broggy

Preventing AiTM Attacks and Stopping Token Theft with Microsoft E5

TLDR: skip to the summary at the bottom for quick wins with AiTM. Adversary-in-the-Middle (AiTM) phishing targets the authenticated session token that exists after a user has already completed multi-factor authentication. Once captured, that token gives an attacker full access to M365 services — email, SharePoint, Teams, OneDrive — without ever knowing the user's password, and without triggering another MFA prompt. The March 2026 EvilTokens / Railway.com campaign, documented by Huntress across more than 340 organisations, introduced a variant that bypasses even network-based session controls: rather than routing a victim through a reverse proxy, it abuses the OAuth device code flow — a legitimate Microsoft authentication mechanism — to harvest tokens directly, then uses those tokens to register a device in Entra ID and obtain a Primary Refresh Token (PRT). 01 01 / The Threat Landscape The Core Problem Multi-factor authentication stops password replay. It does not stop token theft. Adversary-in-the-Middle attacks intercept the authenticated session token after MFA succeeds — then replay it from the attacker's infrastructure. The user sees nothing unusual. No failed MFA prompt. No alert. A stolen access token gives full M365 access for hours; a stolen refresh token survives a password reset for days. Every token theft attack follows the same four-phase progression. Understanding each phase is the starting point for mapping the right controls. 01 Lure & Redirect Targeted phishing email delivers a link that routes the victim through an attacker-controlled proxy or device code flow. Highly convincing — Microsoft-branded pages, valid TLS certificates. 02 Token Interception The proxy relays credentials and MFA to Microsoft in real-time, receives the authenticated session cookie, and forwards a clean login experience to the victim. MFA was completed — by the proxy. 03 Persistence & Pivot Attacker replays the access token immediately. Uses the refresh token to register a device, obtain a Primary Refresh Token (PRT), and achieve persistent silent access — surviving password resets. 04 Impact Business email compromise (inbox rules, forwarding), data exfiltration, lateral movement to on-premises systems via hybrid join, financial fraud. Average dwell time before detection: 3–7 days. LURE Phishing email + proxy redirect → INTERCEPT Proxy relays MFA to Microsoft → TOKEN HARVEST Session cookie + refresh token stolen → PERSISTENCE Device reg + PRT survives pwd reset → IMPACT BEC / Exfil / Lateral move 02 02 / Attacker Arsenal These are the active frameworks and phishing-as-a-service platforms observed in the wild. Knowing what attackers are using — and how each tool works — determines which controls are non-negotiable versus layered defences. Evilginx2 / AiTM Proxy Open Source Open-source reverse proxy with automatic session cookie extraction. Widely documented; the reference implementation attackers adapt from. Targets any web-based SSO flow. EvilProxy / PhaaS Phishing-as-a-Service Subscription-based phishing-as-a-service. Targets Apple, Google, Microsoft, and 50+ providers. Operator dashboard, ready-made lure pages. Low technical barrier for attackers. EvilTokens / Railway.com / Device Code March 2026 Campaign March 2026 Huntress-documented campaign. Uses OAuth device code phishing instead of AiTM proxy — bypasses GSA network checks entirely. Chains into device registration + PRT for persistent access. Storm-1167 / PhaaS Microsoft-Tracked Actor Microsoft-tracked threat actor operating a multi-stage indirect proxy AiTM service. Targets financial services and professional services sectors. Known to automate BEC follow-on within minutes of token capture. Modlishka / AiTM Proxy Open Source Polish-origin open-source AiTM tool. Single-binary, no external dependencies. Often deployed on compromised servers or cloud VMs. Targets standard browser auth flows. Caffeine / PhaaS Phishing-as-a-Service PhaaS platform — notable for open self-registration (no referral required). Focuses on Microsoft 365 targets. Provides anti-bot and anti-analysis evasion, geo-fencing, and victim tracking dashboards. 03 03 / The Modern Attack Chain Why This Matters Now Classic AiTM proxy attacks are increasingly blocked by Global Secure Access Strict Enforcement Mode — which validates the client IP against a Microsoft-managed Entra network presence. Attackers adapted: the EvilTokens / Railway.com campaign (March 2026) uses the OAuth device authorization flow instead of a reverse proxy. The user enters a code on a legitimate Microsoft page — no proxy involved. GSA network checks never fire. The stolen refresh token is then used to register a device under the attacker's control, obtain a Primary Refresh Token (PRT), and achieve silent, persistent access to all M365 services — even after the user changes their password. Attack Chain — Device Code Phishing & PRT Pivot The kill chain below shows how an attacker converts a single phishing email into persistent, password-reset-proof access to all M365 services — without ever touching a reverse proxy. 1. PHISHING EMAIL Attacker sends device code link → 2. DEVICE CODE User enters code at microsoft.com ✓ → 3. TOKEN ISSUED Attacker receives refresh token → 4. DEVICE REGISTER Rogue device joins Entra ID → 5. PERSISTENT PRT = silent SSO to all M365 services KEY DIFFERENCE VS CLASSIC AiTM — No reverse proxy used. User authenticates on legitimate Microsoft page. GSA network enforcement does not fire. CA device code block is the primary control. Why the PRT Is the Real Target A Primary Refresh Token (PRT) is a long-lived credential that provides silent single-sign-on to every Microsoft 365 service. It is normally bound to a managed device. When an attacker registers a device using a stolen refresh token and obtains a PRT, they inherit that persistent SSO capability — with no MFA prompt, on their own hardware. A PRT survives a password reset because it is tied to the device registration, not the password. Revoking it requires removing the rogue device registration from Entra ID. 04 04 / The Token Map: What an Attacker Sees First The Local Admin Problem An adversary who gains local administrator access to a managed Mac or Windows endpoint does not need to phish credentials. Every browser cookie database, every MSAL token cache, and — on Windows — LSASS memory itself contain active, replay-capable Microsoft 365 credentials. A tool like M365 Token Inspector (token_inspector.py) maps exactly what is present. The result on a corporate machine is reliably alarming. Running streamlit run token_inspector.py on an active corporate Mac surfaces every Microsoft authentication token across Firefox, Chrome, and Edge simultaneously. Firefox cookies are stored in plaintext SQLite databases — no decryption required. Chrome and Edge cookies are AES-128-CBC encrypted with a key held in macOS Keychain. Retrieving that key requires one Keychain prompt — which an attacker with local admin can trigger silently via a background process. The output is a categorised inventory of every live credential: its expiry window, its host domain, and its classification. On a typical corporate Mac with an active M365 session, expect between 30 and 80 Microsoft cookies — several of them Critical. Token / Cookie Storage Lifetime Risk What an Attacker Does With It estsauthpersistent Browser cookie store (disk) Up to 90 days Critical Replays the full Entra ID authenticated session from any remote host. Grants access to email, Teams, SharePoint, and OneDrive. No MFA prompt fires. No new sign-in event is logged for the replay — it appears as a continuation of the original session. sccauth / sccauthc1 Browser memory / cookie store Session Critical Accesses the Microsoft Defender XDR portal (security.microsoft.com). Attacker can suppress active alerts, close incidents, add AV/EDR exclusions for their tools, and disable MDE sensor policies — blinding the security team while access continues undetected. fedauth / rtfa Browser cookie store (disk) Session / persistent Critical Grants full SharePoint farm access — read, modify, exfiltrate, or delete documents and files across all SharePoint sites and OneDrive. Access patterns are indistinguishable from normal user activity in SharePoint audit logs. MSAL Refresh Token Disk (DPAPI / Keychain encrypted) 90 days (sliding) Critical Survives a password reset. Exchangeable for new access tokens to any M365 service indefinitely within the 90-day window. On Windows, extractable via SharpDPAPI or Mimikatz DPAPI module with local admin. The user's password change does not touch this token. Primary Refresh Token (PRT) Windows LSASS / macOS Keychain 14 days (auto-renewed) Critical Silent SSO to every M365 service. On Windows, extracted from LSASS memory using ProcDump or Mimikatz, then used with AADInternals to generate access tokens for any M365 resource — no MFA, no password, from any attacker-controlled device. ohpauth / ohpauthc1 Browser cookie store Session Critical Full Microsoft 365 portal access. Used to pivot to connected apps, access shared mailboxes, modify user settings, enumerate tenant resources, and exfiltrate data from any service the user can reach via the portal. estsauth (non-persistent) Browser memory Browser session High Short-lived but immediately replayable while the browser is open. Usable for rapid exfiltration tasks — forwarding email rules, downloading OneDrive contents, accessing Teams messages — before the session closes. High-Risk Observation — The 90-Day Replay Window The estsauthpersistent cookie is created whenever a user selects "Keep me signed in" at the Entra login prompt — the default on most corporate Macs. An attacker who extracts this single cookie value from the browser's SQLite database can inject it into any browser and access all M365 services for up to 90 days. There is no re-authentication prompt, no MFA challenge, and no new sign-in event generated in Entra ID logs. The session presents with the user's original IP context from initial login, making anomaly detection unreliable unless the replay occurs from a geographically distant IP or unfamiliar ASN. High-Risk Observation — Going Dark With sccauth The sccauth cookie is the most underappreciated Critical token on the list. It grants access to the Microsoft Defender XDR portal. An attacker who captures it can suppress active detections, close open incidents, add their tools to MDE exclusion lists, and offboard endpoints from Defender monitoring — all from the same portal the security team uses to investigate them. This is how attackers go dark inside a defended environment: not by evading detection initially, but by accessing the security controls themselves and disabling them after they are already inside. A compromised sccauth session will not generate a suspicious sign-in alert, because it looks like an analyst using their own tools. High-Risk Observation — Password Reset Does Nothing for Refresh Tokens MSAL refresh tokens persist in an encrypted file on disk and survive a password reset by design — the token lifecycle is managed by Entra ID server-side policy, not the password. When incident response advises a user to change their password after a compromise, that action alone invalidates nothing an attacker has already captured from the MSAL cache. Revocation requires an explicit server-side action: Revoke-AzureADUserAllRefreshToken via PowerShell, or the "Sign out everywhere" option in myaccount.microsoft.com. Until that is executed, the attacker continues to generate valid access tokens from their captured refresh token. Attack Chain 1 — Local Admin to Full M365 Compromise 1. LOCAL ADMIN Endpoint access gained (any method) → 2. TOKEN SCAN Browser DBs · MSAL cache · LSASS (Win) → 3. CRITICAL TOKENS estsauthpersistent · sccauth · fedauth · PRT → 4. REMOTE REPLAY Cookies injected into attacker browser / C2 → 5. FULL M365 Email · Teams · SP · No MFA · 90-day window NO PHISHING REQUIRED — Local admin = full token access. No credentials stolen, no MFA bypassed — the tokens already exist on disk and in memory from the user's normal session. Attack Chain 2 — Covering Tracks via the Defender Portal (sccauth) 1. sccauth CAPTURED Defender portal session replayed → 2. ALERT SUPPRESSION Active incidents closed, alerts resolved / hidden → 3. AV EXCLUSIONS Attacker tools added to MDE exclusion list → 4. SENSOR DISABLED Endpoint offboarded from MDE policy → 5. SOC IS BLIND Zero telemetry. Attacker operates freely. THE UNDERAPPRECIATED RISK — sccauth is not a data access token — it is a security control access token. An attacker who uses it to disable monitoring can then operate for weeks without triggering a single alert. 05 05 / Attack Scenarios & E5 Controls Each card maps a specific attack scenario to the Microsoft E5 controls that stop it — covering the problem, the solution, and the licensing required. Use these to drive the conversation with your customer around their current gaps. SCENARIO 01 AiTM Proxy — Session Token Theft Token Theft Problem Reverse proxy intercepts the post-MFA session cookie. Attacker replays the token from a foreign IP address. Standard MFA does not prevent replay. Token valid for hours with no further challenge. E5 Controls Global Secure Access + Strict Enforcement — binds sessions to a Microsoft-managed network presence. Token replayed from an external IP is rejected immediately. Continuous Access Evaluation (CAE) — re-evaluates session on every API call. IP-change or policy violation revokes access in under 15 minutes. Entra ID Protection — anomalous token risk signal triggers risk-based CA auto-block on the compromised session. M365 E5 | Entra Suite (GSA) | Medium Effort SCENARIO 02 Device Code Phishing — OAuth Flow Abuse Dev Code Problem Attacker initiates a device code flow, sends the code to the victim. Victim enters code at microsoft.com — a legitimate Microsoft page. Attacker receives access and refresh tokens with no proxy involvement. GSA network enforcement does not fire. E5 Controls CA — Block Device Code Flow — CA policy denying the device_code grant for all users except approved device-constrained roles. Entra ID Protection — Anomalous Token Risk — device code abuse triggers a risk signal; risk-based CA auto-blocks the session. Defender XDR — correlates the device code grant event with subsequent anomalous M365 activity into a single incident. M365 E5 | Low Effort SCENARIO 03 Device Registration + PRT Pivot PRT Abuse Problem Attacker uses a stolen refresh token to register a device in Entra ID and request a Primary Refresh Token. The PRT grants silent SSO to all M365 services from the attacker's own hardware — with no MFA required and no revocation on password reset. E5 Controls MFA for Device Registration — Entra CA policy forces MFA at join time, preventing registration using only a stolen refresh token. Token Protection (Proof-of-Possession) — cryptographically binds the token to the originating device. A stolen token cannot be replayed on a different device. Restrict User-Initiated Device Registration — limit registration to Intune-enrolled managed devices. Defender XDR — Anomalous Device Registration Alert — detection fires when a device is registered from a non-corporate IP or following a suspicious token event. M365 E5 | Medium Effort SCENARIO 04 Refresh Token Persistence After Password Reset Persistence Problem A refresh token remains valid after a password reset unless explicitly revoked. Attackers who captured a refresh token before the reset retain full access — including the ability to request new access tokens indefinitely. Users and admins believe the reset resolved the breach. E5 Controls Revoke All Refresh Tokens — Revoke-AzureADUserAllRefreshToken invalidates all active sessions across every device and app immediately. Risk-Based CA Auto-Revocation — Entra ID Protection high-risk user flag triggers automatic token revocation without manual intervention. Defender XDR Attack Disruption — automatically contains the compromised account and suspends active sessions upon high-confidence attack detection. M365 E5 | Low Effort SCENARIO 05 OAuth App Consent Abuse App Abuse Problem Attacker tricks the user into consenting to a malicious OAuth application. The app receives delegated permissions tied to the user's identity — persisting even after password reset or token revocation, until the app consent itself is removed. E5 Controls Restrict User Consent — CA policy requires admin approval for all third-party OAuth app consent. Admin Consent Workflow — Entra ID admin consent request workflow routes app approvals to designated reviewers. Defender for Cloud Apps — OAuth app anomaly detection flags apps with suspicious permission sets, unusual publisher domains, or consent patterns inconsistent with legitimate software. M365 E5 | Low Effort SCENARIO 06 BEC — Inbox Rule Hijack Post-Compromise Problem Attacker with mailbox access creates forwarding rules or auto-delete rules to hide their activity and intercept financial communications. Rules persist even after the stolen session is revoked. E5 Controls Defender for Cloud Apps — Inbox Rule Anomaly — built-in policy fires when a rule is created that forwards or deletes email matching financial keywords or external domains. Defender XDR Auto-Disruption — automatically disables the compromised account and quarantines suspicious mail rules upon high-confidence BEC detection. Exchange Online Audit Logging — unified audit log captures every inbox rule creation/modification. M365 E5 | Low Effort SCENARIO 07 PaaS Infrastructure & IP Rotation Evasion Evasion Problem Attackers host phishing infrastructure on legitimate PaaS platforms (Railway, Vercel, Cloudflare Workers) to evade IP blocklists. They rotate IPs rapidly, making traditional IP-reputation controls ineffective. E5 Controls GSA Strict Enforcement Mode — validates sessions against the Entra network presence, not IP reputation. PaaS IP rotation is irrelevant. Entra ID Protection — Behavioral Signals — evaluates impossible travel, unfamiliar location, and token properties holistically. Defender XDR Advanced Hunting — custom KQL detects sign-ins from hosting provider ASNs combined with anomalous M365 activity. M365 E5 | Entra Suite (GSA) | Medium Effort 06 06 / Defense Architecture PREVENT Passkeys · Token Binding · Block Device Code → ENFORCE GSA Strict Mode · CAE · Compliant Device CA → DETECT ID Protection · XDR · Sentinel KQL → RESPOND Auto-Disruption · Token Revocation Layer 1 — Prevent Make Tokens Worthless Controls that ensure captured tokens cannot be replayed or bound to attacker devices FIDO2 Passkeys Token Protection Block Device Code Device Reg MFA FIDO2 Passkeys: Phishing-resistant credential — no password to intercept, no OTP to relay. Immune to AiTM by design. Token Protection: Proof-of-possession cryptographically binds the access token to the issuing device. Replay on any other device fails at validation. Block Device Code: Conditional Access policy denies the device code grant type for all non-approved roles. Closes the EvilTokens attack path entirely. Device Reg MFA: CA policy requires phishing-resistant MFA at device registration time. Stolen refresh tokens cannot be used to register rogue devices. Layer 2 — Enforce Block Replay in Real-Time Network and session enforcement that rejects stolen tokens at use GSA + Strict Mode CAE Compliant Device CA GSA + Strict Mode: Global Secure Access anchors every Entra-protected session to a Microsoft-managed network presence. Token replayed from an external IP is rejected. Entra Suite add-on. CAE: Continuous Access Evaluation pushes real-time policy signals to resource providers. IP change or risk elevation revokes access in under 15 minutes. Compliant Device CA: Conditional Access requires Intune device compliance on all M365 sessions. Attacker-registered non-managed devices fail the compliance check. Layer 3 — Detect & Respond Catch What Slips Through Signal correlation and automated containment for attacks in progress ID Protection Defender XDR Defender for Cloud Apps Sentinel ID Protection: Risk-based signals (anomalous token, impossible travel, unfamiliar location) auto-block the session via CA. No analyst required. Defender XDR: Correlates identity, endpoint, email, and cloud signals into a single incident. Auto-disruption suspends compromised accounts on high-confidence detection. Defender for Cloud Apps: Inbox rule anomalies, OAuth app abuse, impossible travel across SaaS services — all correlated with Entra sign-in context. Sentinel: Custom KQL analytics rules for device code grants, anomalous device registrations, and PaaS ASN sign-ins. Playbook automation for incident response. 07 07 / Detection & Response Prevention controls reduce exposure but will not catch every attack. The following Microsoft tools provide the detection and automated response capability needed to identify active token theft and contain it before data is exfiltrated. Entra ID Protection Identity Risk Anomalous Token flags tokens with unusual IP, device, or session properties Impossible Travel detects sign-ins from geographically impossible locations within a session window Risk-Based CA auto-blocks or requires step-up auth on Medium/High risk without analyst action Microsoft Defender XDR Cross-Signal Correlation · Auto-Disruption Cross-Workload Incident stitches identity, endpoint, email, and cloud signals into one unified incident Automatic Attack Disruption suspends compromised user account and active sessions upon high-confidence AiTM classification AiTM Detection native classifier identifies session cookie replay patterns across Entra sign-in telemetry Defender for Cloud Apps SaaS & Cloud Activity Inbox Rule Anomaly built-in policy fires on forwarding or deletion rules targeting financial keywords or external addresses OAuth App Governance flags apps with over-privileged permissions or abnormal consent patterns Impossible Travel (SaaS) extends identity-level impossible travel detection across cloud app activity Defender for Identity Hybrid / On-Premises Lateral Movement detects pass-the-hash, pass-the-ticket, and Kerberos abuse following cloud identity compromise Privilege Escalation flags DCSync, AdminSDHolder modification, and AD group changes inconsistent with user role Hybrid Correlation links on-premises AD events to Entra cloud identity signals for unified hybrid attack view in XDR KQL — Detect Device Code Grant Sign-Ins (Sentinel / SigninLogs) SigninLogs | where AuthenticationProtocol == "deviceCode" | where ResultType == 0 // successful only | project TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName, DeviceDetail, Location | order by TimeGenerated desc KQL — Anomalous Device Registration Following Suspicious Sign-In let riskySignins = SigninLogs | where RiskLevelDuringSignIn in ("high","medium") | project UserPrincipalName, riskTime = TimeGenerated; AuditLogs | where OperationName == "Register device" | extend UPN = tostring(InitiatedBy.user.userPrincipalName) | join kind=inner riskySignins on $left.UPN == $right.UserPrincipalName | where TimeGenerated between (riskTime .. riskTime + 4h) | project TimeGenerated, UPN, DeviceName = tostring(TargetResources[0].displayName) KQL — Inbox Forwarding Rules Created to External Addresses OfficeActivity | where Operation in ("New-InboxRule","Set-InboxRule") | where Parameters has "ForwardTo" or Parameters has "RedirectTo" | extend RuleParams = parse_json(Parameters) | where RuleParams has_any ("@gmail","@yahoo","@outlook.com") or RuleParams !has "@yourdomain.com" | project TimeGenerated, UserId, ClientIP, Parameters 08 08 / MITRE ATT&CK Coverage The table below maps each technique used across the token theft attack chain to its MITRE ATT&CK identifier and the corresponding E5 mitigations. This provides a common framework for discussing coverage with security-aware customers. Technique ID Name Phase E5 Mitigations T1566.002 Phishing: Spear-phishing Link Initial Access Defender for Office 365 Safe Links; user awareness training T1539 Steal Web Session Cookie Credential Access GSA Strict Enforcement; Token Protection; CAE revocation T1550.001 Use Alternate Authentication Material: Application Access Token Defense Evasion / Lateral Movement Token Protection; CAE; Entra ID Protection Anomalous Token signal T1528 Steal Application Access Token (OAuth device code) Credential Access CA policy blocking device code grant; Defender XDR detection T1098.005 Account Manipulation: Device Registration Persistence MFA at device registration; Restrict BYOD registration; Anomalous device reg alert T1556.006 Modify Authentication Process: Multi-Factor Authentication Defense Evasion Privileged Identity Management; MFA method audit; Defender XDR MFA change detection T1114.003 Email Collection: Email Forwarding Rule Collection Defender for Cloud Apps inbox rule anomaly; Exchange audit logging KQL T1078.004 Valid Accounts: Cloud Accounts Persistence / Privilege Escalation Risk-based CA auto-block; Defender XDR auto-disruption; refresh token revocation T1136.003 Create Account: Cloud Account Persistence Entra Privileged Identity Management; admin account audit; creation anomaly alert Licensing All controls above are available within Microsoft 365 E5 or the Microsoft 365 E5 Security add-on, with one exception: Global Secure Access (GSA) is part of the Microsoft Entra Suite, which is a separate add-on (~$12 USD/user/month). GSA provides the strongest single control against token replay. All monitoring tools (Defender XDR, Defender for Cloud Apps, Defender for Identity, Sentinel, Entra ID Protection) are included in M365 E5. ✓ Summary / Key Takeaways & Recommended Actions The controls below represent the highest-impact actions for closing the token theft exposure window. Prioritise by threat coverage and implementation effort — the first three can be deployed with a single Conditional Access policy each. Summary Recommended Control Priorities Control Covers Priority Block Device Code Flow (CA) Eliminates the EvilTokens / OAuth device code phishing path entirely. Single CA policy, low complexity, no user impact in most organisations. Critical Require MFA for Device Registration (CA) Prevents PRT pivot via stolen refresh token. Blocks the persistent access phase even when token theft has already occurred. Critical Risk-Based Conditional Access (Entra ID Protection) Automatically blocks or step-up challenges sessions flagged as anomalous — covers token replay, impossible travel, and unfamiliar sign-in properties without manual intervention. Critical GSA + Strict Enforcement Mode Strongest control against classic AiTM proxy token replay. Binds every session to Microsoft-managed network presence. Requires Entra Suite add-on. High Token Protection (Proof-of-Possession) Cryptographically binds access tokens to the issuing device. Prevents replay on any other hardware. Currently Windows + Exchange/SharePoint only. High FIDO2 / Phishing-Resistant MFA The only MFA method fully immune to AiTM by design. Prioritise for privileged accounts, finance teams, and executives — highest-value targets for token theft campaigns. High Sentinel KQL Analytics + Defender XDR Provides detection coverage for attacks that bypass preventive controls. Device code grants, anomalous device registrations, and inbox rule creation should all have active analytics rules. Medium David Broggy | LevelBlue — April 2026

May 15, 2026 · 19 min · David Broggy

Building an Intentionally Vulnerable LLM App — and How Microsoft Tools Help You Defend Against It

Author: David Broggy Published: 2026-03-12 Tags: MVPBuzz, CyberSecurity, LLM Security, Prompt Injection, Azure AI, OWASP LLM Top 10 What This Covers LLMGoat is a deliberately vulnerable LLM application built for security training. It follows the WebGoat model — an intentionally insecure app used for years to teach OWASP web vulnerabilities — but targets the OWASP LLM Top 10 instead. This post walks through how LLMGoat is built, what each vulnerability looks like in practice, and where Microsoft tools — Azure AI Content Safety, Azure OpenAI, Microsoft Sentinel, and Azure Monitor — fit into a realistic defense. ...

March 12, 2026 · 8 min · David Broggy
Microsoft AMA Troubleshooter script

Microsoft AMA Troubleshooter script

I recently had an issue with a new linux syslog server that was using Arc and had the AMA service enabled by a data collection rule in Sentinel. I could see the Sentinel DCR (data collection rule) had been pushed out but the AMA agent wasn’t forwarding logs back up to Sentinel. I suspected traffic was getting blocked but I wasn’t sure how to validate it. This script will extract the Sentinel Workspace ID and perform a network connection test that simulates the connection from AMA to the data collection point or ODS(operational data store). ...

July 23, 2025 · 5 min · David Broggy