<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christopher Brumm on Medium]]></title>
        <description><![CDATA[Stories by Christopher Brumm on Medium]]></description>
        <link>https://medium.com/@chris-brumm?source=rss-a236d29b3f98------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RFXeFmvBoUzA0BGd.jpg</url>
            <title>Stories by Christopher Brumm on Medium</title>
            <link>https://medium.com/@chris-brumm?source=rss-a236d29b3f98------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 10:01:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chris-brumm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Moving my blog!]]></title>
            <link>https://chris-brumm.medium.com/moving-my-blog-9ae7f90b11fc?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ae7f90b11fc</guid>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Sat, 21 Sep 2024 17:25:15 GMT</pubDate>
            <atom:updated>2024-09-21T17:25:15.252Z</atom:updated>
            <content:encoded><![CDATA[<p>-&gt; <a href="https://chris-brumm.com/">https://chris-brumm.com</a></p><p>Hi to all my followers on Medium!</p><p>After 4 years blogging here I’ve decided to move to my own blog based on GitHub Pages and Hugo. The main reason for this are the limits of the editor.</p><p>I think I will leave the content here (and move it subsequently when I have spare time 😂).</p><p>New blog posts will only be published on my new blog (and there are already some about Global Secure Access).</p><p>Here is the blog: <a href="https://chris-brumm.com/">https://chris-brumm.com/</a></p><p>Here is the RSS feed: <a href="https://chris-brumm.com/index.xml">https://chris-brumm.com/index.xml</a></p><p>Hope to see you there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ae7f90b11fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microsoft Entra MFA Fraud Deep Dive]]></title>
            <link>https://chris-brumm.medium.com/microsoft-entra-mfa-fraud-deep-dive-7764fd8f76ad?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/7764fd8f76ad</guid>
            <category><![CDATA[entra]]></category>
            <category><![CDATA[itdr]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mfa]]></category>
            <category><![CDATA[identity]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Sat, 07 Oct 2023 12:05:10 GMT</pubDate>
            <atom:updated>2023-10-07T12:16:03.383Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, Microsoft released the new feature <a href="https://learn.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-mfasettings#report-suspicious-activity"><strong>Report suspicious activity</strong></a> for Entra ID. Since I see this feature as a significant improvement and have faced some challenges with the old feature in the past, I have decided to delve deeper into the topic and share my findings here.</p><p>Now, you might be wondering what makes this feature special. After all, Microsoft has long provided the ability to reject authentication through the Authenticator app and phone call and report fraudulent attempts in Entra ID.</p><p>The difference is that the new feature integrates the valuable signal of a user reporting a fraudulent attempt into Entra ID Protection and the Detection and Response environment, which can trigger automated responses. Microsoft is currently driving the integration of <a href="https://www.microsoft.com/en-us/security/business/solutions/identity-access">identity and access management (IAM)</a> features and <a href="https://www.microsoft.com/en-us/security/business/solutions/extended-detection-response-xdr">extended detection and response (XDR)</a> features under the term <a href="https://www.microsoft.com/en-us/security/business/solutions/identity-threat-detection-response">identity threat detection and response (ITDR)</a>.</p><h3>A brief comparison of the old and new solutions</h3><p>Since we are dealing with a compromised password in the case of a reported fraudulent attempt, I have always recommended the following over the years:</p><ul><li>[ ] Enable the feature.</li><li>[ ] Enable automatic blocking of users for further MFA attempts.</li><li>[ ] Provide an email address of your SOC or identity operations team for notifications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*QvcfCJ3PaBZAzS9Dq3T1og.png" /><figcaption>MFA fraud alert configuration</figcaption></figure><p>However, this feature does have its weaknesses, which is why I am glad that Microsoft has recently made improvements.</p><p>The following issues have always bothered me:</p><ul><li>When a user is blocked, there is no notification or adjustment of the error message. It simply appears as if MFA failed.</li><li>The blocking only applies to further second-factor MFA challenges with the Authenticator app or phone call. The user itself is not blocked, and logins without MFA or with Windows Hello or FIDO are still possible.</li><li>Unlocking can only be done by admins with the Global Admin or Authentication Policy Admin role. No self-service option for the user.</li><li>The email notification to the IT was not integrated with other systems like Microsoft 365 Defender or Microsoft Sentinel to directly generate alerts/incidents. However, it could be built in Sentinel through the audit log.</li><li>It was also possible to report a fraudulent attempt during a self-service password reset. This resulted in someone else being able to trigger the MFA challenge without authentication, putting a well-trained user in a situation where they locked themselves out.</li></ul><p>The new feature “Report suspicious activity” addresses these weaknesses, along with the ability to scope the feature. Now we have an integration into Entra ID Protection, which generates a high-risk alert for the user when a fraud is reported, giving this signal much more influence. If an Entra ID P2 license is available and the appropriate configurations are enabled, the following will occur:</p><ul><li>The user receives an error message clearly stating that they have been blocked.</li><li>The user is effectively blocked, Refresh Tokens will be revoked and existing sessions are also terminated by Continuous Access Evaluation (see below).</li><li>Self-remediation is possible for the user via self-service password reset.</li><li>We have multiple options for generating alerts in Entra ID Protection, which can also be integrated into M365 Defender and MS Sentinel (and should be).</li><li>If only the new feature is used, fraud cannot be triggered during a self-service password reset.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGEMf3LWDXKoRGjlCvCGtA.png" /><figcaption>Report suspicious activity configuration</figcaption></figure><p>This means that the eager reader (who has enabled the policies for User Risk) can now stop reading and simply enable the new feature and disable the old one.</p><h3>MFA Fraud and Entra ID Protection</h3><p>Entra ID Protection is a very powerful feature, and describing it in full detail would exceed the scope of this blog. Therefore, we will focus on the concrete use case of the impact of a high-risk alert generated by the fraud alert.</p><p>First and foremost, the most important effect of the high-risk alert is that the user risk is set to high:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*3PVXPyRbULDlLik3WI4zxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*1vyQLgUaXHhXIvoQma898Q.png" /><figcaption>Risk Detection: User reported suspicious activity and the Risky User Details after a User reported suspicious activity alert</figcaption></figure><p>By the way, the suspicious activity reported by the user is not detected as a risky login, but as an offline detection in Entra ID Protection. We have to establish a connection with a sign-in (if there is one) ourselves (see below). There may also be an “Unfamiliar sign-in properties” alert generated in this context with the failure reason “Authentication failed during strong authentication request,” but these are two completely separate detections.</p><h3>Protection: Risk-based Access Control</h3><p>For User Risk to have an impact on the issuance of new tokens in Entra ID, two things are needed:</p><ul><li>An Entra ID P2 license (this is also necessary to generate the alarm).</li><li>A User Risk policy or a Conditional Access policy.</li></ul><p>The Conditional Access policy to enforce a secure password change for a high-risk user may look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*w3QwHkAC_D0lTJywqkwm2Q.png" /><figcaption>Example for a User Risk policy in Conditional Access</figcaption></figure><p>However, in heterogeneous environments, the impact of a high user risk status for a user depends heavily on the architecture and configuration of the environment. In short: The more modern your access management is and the better it is connected to Entra ID, the greater the impact!</p><p>Here are a few examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDsw6U5D-zjvYu0fbNqKbQ.png" /><figcaption>User Risk impact — view <a href="https://gist.github.com/crmhh/b606fe24bd29059dfec0942cfbe378bc">raw table</a></figcaption></figure><h3>Session Disruption:</h3><p>In addition, there is the possibility to disrupt sessions before the expiration of the access token lifetime using Continuous Access Evaluation, as reporting a fraud attempt via Authenticator is one of the triggers for the critical event <a href="https://learn.microsoft.com/en-us/azure/active-directory/conditional-access/concept-continuous-access-evaluation#:~:text=High">High user risk detected by Azure AD Identity Protection</a>.</p><p>Currently, this only applies to Office 365 services, but the announcement that Microsoft’s SSE solution will support Global Secure Access for private and public access and Microsoft’s efforts to establish the Continuous Access Evaluation Protocol as a general standard will greatly enhance this feature.</p><blockquote><a href="https://www.linkedin.com/in/fabianbader/">Fabian Bader</a> has written a wonderful deep dive blog on CAE: <a href="https://cloudbrothers.info/en/continuous-access-evaluation/">https://cloudbrothers.info/en/continuous-access-evaluation/</a></blockquote><h3>Self-Remediation</h3><p>The password reset enforced by the policy solves the problem of the compromised password, resets the user risk, and allows the user to regain access.</p><h3>Coexistence</h3><p>According to the <a href="https://www.notion.so/Review-Azure-RBAC-5371927920d2418fa792c3aed6bfd19f?pvs=21">documentation</a>, the two features can be operated in parallel:</p><blockquote><strong><em>Report suspicious activity</em></strong><em> and the legacy </em><strong><em>Fraud Alert</em></strong><em> implementation can operate in parallel. You can keep your tenant-wide </em><strong><em>Fraud Alert</em></strong><em> functionality in place while you start to use </em><strong><em>Report suspicious activity</em></strong><em> with a targeted test group.</em></blockquote><blockquote><em>If </em><strong><em>Fraud Alert</em></strong><em> is enabled with Automatic Blocking, and </em><strong><em>Report suspicious activity</em></strong><em> is enabled, the user will be added to the blocklist and set as high-risk and in-scope for any other policies configured. These users will need to be removed from the blocklist and have their risk remediated to enable them to sign in with MFA.</em></blockquote><p>Since the two settings of the old feature are dependent on each other, the following configuration options and resulting effects arise:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRk6_uVszbqGr_6slNJ66Q.png" /><figcaption>Fraud Submission Coexistence options -&gt; view <a href="https://gist.github.com/crmhh/525ac38d616eeefaedb9cfdae22a4586">raw table</a></figcaption></figure><p>And the graphical version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oU4bDW7UQR4aVsV4noY4YA.png" /></figure><h3>Built-In Alerting</h3><p>As mentioned above, an EID P2 license is required to use the feature, as the “User Reported Suspicious activity” alarm is a premium alert.</p><p>Entra ID Protection distinguishes between risk detections that occur:</p><ul><li>Within the context of a sign-in (online)</li><li>Independently of a sign-in (offline)</li></ul><p>If these detections are not directly mitigated, they will increase the current user risk level, which can take on the values none, low, medium, and high.</p><p>Identity Protection has a built-in notification feature that is automatically activated for some roles but can also have other email addresses from ticketing, monitoring, or SIEM systems added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHXLSSovKkXVSIYaM4FJdQ.png" /><figcaption>Entra ID Protection notification configuration</figcaption></figure><h3>Integration with M365D and Sentinel</h3><p>Attacks are usually complex and not limited to identity alerts alone. Therefore, we should do everything possible to contextualize the alarms that occur and use tools such as the <a href="https://www.lockheedmartin.com/en-us/capabilities/cyber/cyber-kill-chain.html">Cyber Kill Chain</a> and the MITRE ATT&amp;CK Framework: our scenario falls under <a href="https://attack.mitre.org/techniques/T1621/"><strong>Multi-Factor Authentication Request Generation</strong></a> in <a href="https://attack.mitre.org/tactics/TA0006">Credential Access</a>.</p><p>It makes sense to integrate the alerts from Entra ID Protection into M365D and Microsoft Sentinel in order to respond appropriately.</p><blockquote>💡 For me, regarding the Entra ID Protection alerts, an important realization was: <em>While the notifications occur directly in</em> Entra ID Protection <em>based on reaching a defined user risk level, detections are passed on to M365D and Sentinel as alerts.</em></blockquote><p>In M365D, you can choose how many alerts from Identity Protection should be integrated. The default (and sensible value in most production environments) is <em>High-impact alerts only</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wsXAnadeBYRvusWDnNd-nA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*4ei91-vXJKIgspelaXvdPQ.png" /><figcaption>Entra ID Protection integration in Microsoft 365 Defender</figcaption></figure><p>For this use case, I would like to point out that in the default configuration, automatic alert creation in M365D unfortunately does not occur because the list of alerts is not based on the risk level but curated by Microsoft: <strong>High Impact ≠ High Severity</strong></p><p>The integration with Sentinel can now be done either directly through the dedicated Identity Protection Connector or through the M365D Connector. For the reasons mentioned above, I agree with Microsoft’s recommendation to use the M365D Connector.</p><p>It is important to note that even when using the M365D Connector, the Identity Protection Connector must be enabled to retrieve all metadata. However, the Analytic Rule (ANR) should be disabled for alert generation to avoid duplicate alerts.</p><blockquote>For those who want to understand the integration of Entra ID Protection and M365D in detail, I recommend reading this excellent blog by Sami Lamppu: <a href="https://samilamppu.com/2022/11/22/azure-ad-identity-protection-integration-with-microsoft-security-solutions/">Azure AD Identity Protection Integrations with Microsoft Security Solutions</a></blockquote><h3>Custom Detection</h3><p>If you have been reading attentively up to this point, you may have noticed the following: We now have Entra ID Protection alerts in M365D and Sentinel, but we may not be aware of the reported MFA fraud because it is not considered a high-impact detection by Microsoft, and no alert is generated for switching to high risk.</p><p>Fortunately, Sentinel is very flexible in creating alarms. Let’s take a look at some useful approaches to build our own detections to fill this gap.</p><h3>Sentinel Alerts for High Risk Users</h3><p>In addition to the mentioned connectors, it is possible and recommended to integrate the Risk Data tables into Sentinel. The table <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aadriskyusers"><strong>AADRiskyUsers</strong></a> provides us with an overview of which users currently have an active risk level of “high”.</p><pre>AADRiskyUsers<br>| where RiskLevel == &quot;high&quot;<br>| where RiskState in(&quot;atRisk&quot;, &quot;confirmedCompromised&quot;)</pre><h3>Sentinel Alerts for the Risk Event “User Report suspicious activity”</h3><p>In the table <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aaduserriskevents"><strong>AADUserRiskEvents</strong></a>, we can directly filter for the event.</p><pre>AADUserRiskEvents<br>| where RiskEventType == &quot;userReportedSuspiciousActivity&quot;<br>| where RiskState == &quot;atRisk&quot;</pre><p>Please note that my queries here are just a starting point. You can find more information on how to effectively work with tables, for example, here: <a href="https://learnsentinel.blog/2021/08/05/streaming-azure-ad-risk-events-to-azure-sentinel/">https://learnsentinel.blog/2021/08/05/streaming-azure-ad-risk-events-to-azure-sentinel/</a></p><h3>Sentinel Alerts for the old and new Fraud Report variants</h3><p>Things get more interesting when the old feature is active in addition to the new one, as we only receive events from Entra ID Protection for the new feature. (This can be useful, for example, if only a portion of users have a P2 license).</p><p>In this case, the <a href="https://learn.microsoft.com/en-us/azure/active-directory/reports-monitoring/reference-audit-activities#azure-ad-mfa-azure-mfa">Audit Log</a> can help us. There are events that can be used to generate alerts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TUkdYjEzlYpfuy2gTJa5Cw.png" /></figure><p>The event generated depends on the configuration affecting the user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Ytm0yNCivokVYXLs8rDBQ.png" /></figure><p>If both features are active, both a “Fraud reported — *” and a “Suspicious activity reported” event will occur.</p><pre>// Fraud Detected?<br>AuditLogs<br>  | where OperationName has_any (&quot;Fraud reported&quot;, &quot;Suspicious activity reported&quot;)<br>  | mv-expand TargetResources<br>  | evaluate bag_unpack(TargetResources)<br>  | extend _UserPrincipalName = tolower(tostring(column_ifexists(&quot;userPrincipalName&quot;, &quot;&quot;)))<br>  | extend UserId = tostring(column_ifexists(&quot;id&quot;, &quot;&quot;))<br>  | project-rename FraudTimestamp=TimeGenerated</pre><h3>In what context was the fraud attempt reported?</h3><p>It is also interesting to know if the fraud report was triggered in response to a sign-in or a self-service password reset (SSPR), as we can infer a compromised password in the case of a sign-in, while SSPR can occur completely unauthenticated until the fraud report is made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JT74NvcncbQfi1b-ft3USA.png" /><figcaption>Related Events — view <a href="https://gist.github.com/crmhh/78473902142b8e19a92718cfd0843c02">raw table</a></figcaption></figure><p>Note: This clarification is only necessary if the old feature is still active, as only then can a fraud report occur during SSPR. You can check in your Logs what was the trigger:</p><pre>// Fraud Report while SignIn?<br>SigninLogs<br>    | where Status.errorCode == 500121<br>    | extend _UserPrincipalName = tolower(UserPrincipalName)<br>    | project-rename SignInTimestamp=TimeGenerated, RelatedActorIP=IPAddress<br><br>// Fraud Report while SSPR?<br>AuditLogs<br>    | where ResultReason == &quot;User started the mobile app notification verification option&quot;<br>    | extend _UserPrincipalName = tolower(tostring(TargetResources[0].userPrincipalName))<br>    | extend RelatedActorIP = tostring(parse_json(tostring(InitiatedBy.user)).ipAddress)<br>    | project-rename SSPRTimestamp=TimeGenerated</pre><p>The three queries can then be combined to quickly assess whether the trigger was a SignIn or an SSPR — and adjust the severity of the incident if desired.</p><pre>// Fraud Detected?<br>let FraudEvent= AuditLogs<br>| where OperationName has_any (&quot;Fraud reported&quot;, &quot;Suspicious activity reported&quot;)<br>| mv-expand TargetResources<br>| evaluate bag_unpack(TargetResources)<br>| extend _UserPrincipalName = tolower(tostring(column_ifexists(&quot;userPrincipalName&quot;, &quot;&quot;)))<br>| extend UserId = tostring(column_ifexists(&quot;id&quot;, &quot;&quot;))<br>| project-rename FraudTimestamp=TimeGenerated;<br>// Fraud Report while SignIn?<br>let SignInFraudEvent = FraudEvent<br>| join kind=leftouter (SigninLogs<br>    | where Status.errorCode == 500121<br>    | extend _UserPrincipalName = tolower(UserPrincipalName)<br>    | project-rename SignInTimestamp=TimeGenerated, RelatedActorIP=IPAddress<br>    ) on _UserPrincipalName<br>| where SignInTimestamp between ((FraudTimestamp - 3m) .. (FraudTimestamp + 3m))<br>| extend FraudType = &quot;SignIn&quot;<br>| summarize RelatedEvents = make_set(CorrelationId1) by FraudTimestamp, _UserPrincipalName, OperationName, ResultDescription, FraudType, RelatedActorIP;<br>// Fraud Report while SSPR?<br>let SSPRFraudEvent = FraudEvent<br>| join kind=leftouter (AuditLogs<br>    | where ResultReason == &quot;User started the mobile app notification verification option&quot;<br>    | extend _UserPrincipalName = tolower(tostring(TargetResources[0].userPrincipalName))<br>    | extend RelatedActorIP = tostring(parse_json(tostring(InitiatedBy.user)).ipAddress)<br>    | project-rename SSPRTimestamp=TimeGenerated<br>    )on _UserPrincipalName<br>| where SSPRTimestamp between ((FraudTimestamp - 3m) .. (FraudTimestamp + 3m))<br>| extend FraudType = &quot;SSPR&quot;<br>| summarize RelatedEvents = make_set(CorrelationId1) by FraudTimestamp, _UserPrincipalName, OperationName, ResultDescription, FraudType, RelatedActorIP;<br>union SignInFraudEvent, SSPRFraudEvent</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRqpVFVbtC0aBfTpJrEUow.png" /><figcaption>Sample Results of the query, including attributes for the related event (type, IP, CorrelationId)</figcaption></figure><h3>Response</h3><p>The following questions arise when considering the response:</p><p>Do we assume the password has been compromised?</p><ul><li>Is the new feature active? Has the password already been changed through SSPR?</li><li>Have there been any other alerts regarding the user or their device?</li><li>Are there endpoints that can be accessed with single-factor authentication?</li></ul><p>Based on the answers to these questions and the assessment by the analyst, the following responses are recommended:</p><ul><li>Ignore the alarm as it was triggered within the context of a failed SSPR.</li><li>Force a password reset in the AD for the user, for example, through an MDI action.</li><li>Take extensive measures for a compromised user (e.g., locking the account, isolating the device).</li></ul><h3>Summary</h3><p>In summary, I wanted to say:</p><ul><li>As long as we have passwords, they can be stolen or guessed, which is why an user reporting a fraud attempt is a very valuable signal that should be addressed.</li><li>The new feature has several advantages and addresses several weaknesses of the old feature.</li><li>The seriousness of a compromised password depends largely on whether additional factors are required for access everywhere.</li><li>Enable alerting and be prepared to act on those alerts.</li></ul><p>For a better understanding and as a future reference I’ve also created a graphical overview of the different alerting options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9f_Zqrm8NVe73mRsQ8w5bg.png" /><figcaption>Overview alerting options</figcaption></figure><blockquote>In addition I’d like to thank my friends and colleagues <a href="https://www.linkedin.com/in/thomasnaunheim/">Thomas</a> and <a href="https://www.linkedin.com/in/fabianbader/">Fabian</a> for discussing the topic and reviewing this post.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7764fd8f76ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing an advanced Authentication Methods Dashboard]]></title>
            <link>https://chris-brumm.medium.com/implementing-an-advanced-authentication-methods-dashboard-bcb83ebbef95?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcb83ebbef95</guid>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[logic-apps]]></category>
            <category><![CDATA[azure-active-directory]]></category>
            <category><![CDATA[mfa]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Wed, 11 Jan 2023 13:04:35 GMT</pubDate>
            <atom:updated>2023-01-11T13:04:35.967Z</atom:updated>
            <content:encoded><![CDATA[<p>in Azure Active Directory</p><h3>Problem:</h3><p>Strong authentication is one of the core pillars of any (cloud) security strategy and various functions rely on the authenticity of the accessing users. So it makes a lot of sense to work on this topic continuously.</p><p>Azure Active Directory now offers various options for improving the strength of authentication, but one of the big challenges is rolling these out across the board with as little disruption as possible.</p><h4>Stage 1: Any second factor</h4><p>There are many good reasons to start an “MFA rollout”, but in my projects the triggers are often</p><ul><li><strong>an upcoming rollout of new devices</strong><br>New devices can at the same time paradoxically be both the cause and the solution for stronger authentication, since a register/join of the devices and a setup of Windows Hello require strong authentication on the one hand. On the other hand, the Authenticator app (on mobile devices) and Windows Hello (on notebooks) are core components for strong authentication.</li><li><strong>a redesign of the conditional access ruleset</strong><br>In addition to a good admin concept and enterprise app management, the key to a secure AAD is a strong conditional access ruleset. Often, an audit (or a breach) reveals that the current evolved ruleset is not optimal and redesign is necessary. I strongly believe that enforcement of MFA is an integral part of a good CA ruleset.</li></ul><p><em>The first goal in an MFA rollout for me is coverage, as setting up a second factor dramatically increases the security of the account.</em></p><h4>Stage 2: A really strong authentication</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*S2r1_MCeU4FFnvzjaRudaw.jpeg" /><figcaption>*Authenticator App with Number Matching</figcaption></figure><p>Experience shows us that it is not appropriate to stop after the initial rollout. It is too easy for an attacker to spam his victim with calls after a guessed or captured password (MFA fatigue) or to phish the token code directly.</p><p>An ambitious but achievable goal is to have only the Authenticator app with number matching, Windows Hello and FIDO2 keys for all users at the end of the rollout. In combination with a conditioanal access policy that requires device compliance, this is a (currently) robust foundation.</p><p>To achieve this goal, there are two components that help me a lot:</p><ul><li>Recently, Windows Hello can be set up with a Temporary Access Pass without any further MFA methods. This makes the rollout much easier.</li><li>For registered devices (even without Windows Hello), a confirmation, e.g. via Authenticator App, does not have to take place for every login, since an MFA imprinting in the token usually happens even after successful strong authentication.</li></ul><p>However, on the way to my goal, I ask myself a few questions:</p><ul><li>Which users have not registered any MFA method yet?</li><li>Which Authentication Methods are used by your users?</li><li>Which Authentication Methods are registered by your users?</li></ul><p>Fortunately, the AAD already contains the Authentication methods report which answers the questions and in small environments the problem is largely solved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jAiCnglNfDhZRxum.png" /></figure><p>In large environments, however, it is usually not sufficient to look at the totality of all users and so these questions arise for individual groups of users. Additionally the questions arise:</p><ul><li>How effective are my measures to improve the situation?</li><li>How big is the impact if I prohibit weaker methods (for example with Authentication Strength)?</li><li>In which locations / departments / … is my rollout going well?</li><li>What is the percentage of accounts that require exceptions or special handling, such as service accounts or teams rooms systems?</li></ul><h3>Solution:</h3><p>For a complex rollout, I need a flexible tool that allows me to examine the current situation for individual user groups and display trends.</p><p>The use of workbooks, instead of e.g. PowerBI, is ideal here, as the workbooks are already integrated into the existing admin interface and the existing administration concept takes effect.</p><p>Workbooks have the possibility to use APIs and Log Analytic Workspaces as data sources. In order to have a good performance even with a high number of users, I have decided to rely exclusively on log analytics and to have the necessary data written periodically by a logic app. This also enables a historization of the data, which allows us, for example, to display a progression over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UQMRSoLniHeXDYvY8UxwlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NX-__pCZzT1fNR9HfuE9Ug.png" /></figure><h3>Implementation:</h3><p>The following components are needed for the solution:</p><ul><li>Log Analytics Workspace with ingested SignIn Log should already be there (requires AAD P1)</li><li>Logic App of type consumption (not Standard) including an API connection and a Managed Identity.</li><li>Workbook as Dashboard</li></ul><h4>Logic App:</h4><p>For the required Logic app to work it also needs:</p><ul><li>for accessing the Graph API we need to create and authorize a managed identity. Read rights to users, groups and authentication methods are required.</li><li>a connector to the Log Analytics Workspace with write permissions.</li></ul><blockquote>Since these two components need to be customized to the tenant, my instructions currently call for creating them manually before importing the Logic. If anyone knows how to automate this step, I would appreciate any tips.</blockquote><p>Step 1: Create a new empty consumption based Logic App in your favorite Resource Group and give it a reasonable name according to your naming conventions, like <em>PullAuthMethodsToLATablebyGroup</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*NFLOJzjHxB3OKR-LaVH5Rg.png" /></figure><p>Step 2: Enable the System Assigned Managed Identity for the new Logic App and grant permissions. Use “Object (principal) ID” as $miObject.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*nO8gP6811CNe1HJ8KFigkA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb541feb7462086505398b8a6f097846/href">https://medium.com/media/eb541feb7462086505398b8a6f097846/href</a></iframe><p>Step 3: Create a new Log Analytics Connection via a Send Data Action, switch to Logic App Code View and copy the values of the azureloganalyticsdatacollector in the connections section of the parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*tchyGkGbSWwIFJdFykLqJQ.png" /></figure><p>Step 4: Import the Logic from my repo, insert the copied values of the azureloganalyticsdatacollector, insert your first group ids and start the initial run.</p><p><a href="https://github.com/crmhh/CAWorkbooks/blob/main/PullGroupsToLATable.LogicApp">CAWorkbooks/PullGroupsToLATable.LogicApp at main · crmhh/CAWorkbooks</a></p><h4>Dashboard</h4><p>While your Logic App is running you can just import and save the dashboard. In my <a href="https://medium.com/@chris-brumm/advanced-workbooks-for-conditional-access-9efa73b4a575">previous blog</a> I described how to do it.</p><p><a href="https://github.com/crmhh/CAWorkbooks/blob/main/MFAMethodsPerGroupConfigandUsage.workbook">CAWorkbooks/MFAMethodsPerGroupConfigandUsage.workbook at main · crmhh/CAWorkbooks</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcb83ebbef95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Workbooks for Conditional Access]]></title>
            <link>https://chris-brumm.medium.com/advanced-workbooks-for-conditional-access-9efa73b4a575?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/9efa73b4a575</guid>
            <category><![CDATA[conditional-access]]></category>
            <category><![CDATA[zero-trust]]></category>
            <category><![CDATA[azure-active-directory]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Fri, 22 Apr 2022 09:27:53 GMT</pubDate>
            <atom:updated>2024-03-20T14:14:26.668Z</atom:updated>
            <content:encoded><![CDATA[<p>Advancing the builtin Workbooks for Conditional Access</p><p>In my recent projects, I have made extensive use of the <a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Workbooks">Conditional Access insights and reporting workbook</a> to prepare for the rollout of a defined conditional access ruleset.</p><p>A Workbook is effectively a Configurable Dashboard and only has the requirement that the AAD logs are sent to a Log Analytics Workspace.</p><p>However, if you try to rollout as quietly as possible in a larger environment — as I’ve been doing a lot lately — you’ll find a few optimization possibilities. I would like to share some of them here.</p><blockquote>Please note that all dashboards only contains users / sessions for which the policy was already in effect at the time.</blockquote><h3>A silent rollout</h3><p>As a starting situation, imagine the following scenario:</p><ul><li>You have defined, tested and piloted your new waterproof CA rule set that requires Hybrid Joined or Compliant Devices.</li><li>Now you want to do a rollout in waves across, for example, different departments or sites, while generating as little support effort as possible.</li><li>In order to detect problems early on, you have configured a report-only policy in addition to your productive policy that precedes the rollout by a few weeks.</li></ul><h4>Interactive vs. non-interactive Sign-Ins</h4><p>Lately I see more and more users without (or with only very little) sign-in logs. This is a really good sign, because no interactive sign-ins means that we have a very stable state and users rarely have to type in their password.</p><p>However, related to a conditional access rollout and the conditional access insights and reporting workbook described above, this is tricky:</p><p>By default, the workbook only works with the AAD sign-in logs, meaning: just because you don’t see any errors in the logs doesn’t mean that there wouldn’t be any if all devices had to log in again.</p><p>Especially tricky here are devices like older Skype / Teams Phones that are not (can not) be managed via Intune. After a single login, the devices can renew their token literally forever. One of the few reasons why a device needs to re-enroll is if the CA policies for the enrolled user change.</p><p>Unfortunately, this is a recipe for disaster: In the Sign-In Logs area of the user you can see the Non-Interactive Sign-Ins of the user but not in the Workbook.</p><p>For this reason, I set to work rebuilding the Conditional Access Workbook to work with the Non-Interactive Sign-In as well.</p><p>The <a href="https://github.com/crmhh/CAWorkbooks/blob/main/config/workbooks/CAInsightsNonInteractive.workbook">CAInsightsNonInteractive.workbook</a> is 1:1 the normal CA Insights workbook but shows Non-Interactive sign-ins instead.</p><p><a href="https://github.com/crmhh/CAWorkbooks/blob/main/CAInsightsNonInteractive.workbook">CAWorkbooks/CAInsightsNonInteractive.workbook at main · crmhh/CAWorkbooks</a></p><blockquote>You should be careful with the time period here, because there is quite a lot of data in the Non-Interactive Sign-Ins.</blockquote><h4>Combined Sign-Ins</h4><p>The next logical step was to include a KQL query created by <a href="https://twitter.com/fabian_bader">Fabian Bader</a> that combines and homogenizes both logs.</p><p>The workbook <a href="https://github.com/crmhh/CAWorkbooks/blob/main/config/workbooks/CAInsightsCombined.workbook">CAInsightsCombined.workbook</a> is 1:1 the normal CA Insights workbook but combines both sign-in logs</p><p><a href="https://github.com/crmhh/CAWorkbooks/blob/main/CAInsightsCombined.workbook">CAWorkbooks/CAInsightsCombined.workbook at main · crmhh/CAWorkbooks</a></p><p>Here is a comparison of the three workbooks at the same time for a policy for browser access. We see clear differences in the numbers of users in this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WO6ay6mJsgtH6uiHU50aqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXA3ZUMTyd4XHz8dIphGEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*El5ih5Om8QEvQQRDplYJyA.png" /></figure><h3>The final step to All Users</h3><p>With the help of the new workbooks, we have now been able to convert all departments / sites one by one and are now preparing for the last big leap to All Users.</p><ul><li>But how far do we have to jump?</li><li>Who has fallen through the cracks?</li><li>How many function users log on to the AAD?</li></ul><p>To be able to answer these questions, I have now created another workbook, which only gives us the missing users. For each policy in our scenario there is now an additional report-only policy that is scoped to All Users.</p><h4>Production vs. Report-Policy</h4><p>The workbook <a href="https://github.com/crmhh/CAWorkbooks/blob/main/config/workbooks/CompareConditionalAccessPolicies.workbook">CompareConditionalAccessPolicies.workbook</a> allows a comparison between the current and a report-only target policy (then already scoped to All Users) and outputs only the users that are not yet included in the active policy.</p><p>Here is the Workbook in action. I select the current Prod Policy (1) and the desired Report Policy (2) and see in the report only the users that would have been covered <strong>only</strong> by the Report Policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y3MFzbgNv0ulqjMGGTv0UQ.png" /></figure><h4>Also for Non-Interactive Sign-Ins</h4><p>The <a href="https://github.com/crmhh/CAWorkbooks/blob/main/config/workbooks/CompareCAPolicyNonInteractive.workbook">CompareCAPolicyNonInteractive.workbook</a> does the same but with the non-interactive logs.</p><blockquote>Due to the fact that this workbook queries both logs for each widget and joined I recommend to work only with very short periods, otherwise the loading times are very long.</blockquote><h3>Importing the workbooks</h3><p>For an import</p><ul><li>you need write permissions in a resource group</li><li>just press New in the Workbooks section of the AAD</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*k3BEcOC-h2rUPHIggZDnug.jpeg" /></figure><ul><li>use the Advanced Editor (1) and insert as Gallery Template (2) the content from GitHub 1:1 (3)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*lxpwIj9VseiYKZBAgM18VA.jpeg" /></figure><p>After that you will see the workbook in the “Recently modified workbook” section (sometimes you have to select Subscription+RessourceGroup)</p><h3>More Workbooks?</h3><p>Check out the work of <a href="https://danielchronlund.com/2022/04/21/a-powerfull-conditional-access-change-dashboard-for-microsoft-sentinel/">Daniel Chronlund</a> and <a href="https://github.com/microsoft/ConditionalAccessforZeroTrustResources/tree/main/Workbooks">Claus Jesperson</a> — I’m a big fan 🤗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9efa73b4a575" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Response Actions in Microsoft Defender for Identity]]></title>
            <link>https://chris-brumm.medium.com/response-actions-in-microsoft-defender-for-identity-9a8de5362d0e?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a8de5362d0e</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[defender-for-identity]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[microsoft-defender]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Tue, 05 Apr 2022 09:09:56 GMT</pubDate>
            <atom:updated>2022-04-05T09:20:44.836Z</atom:updated>
            <content:encoded><![CDATA[<p>A first look…</p><p>Last week Microsoft <a href="https://techcommunity.microsoft.com/t5/security-compliance-and-identity/microsoft-defender-for-identity-response-actions/ba-p/3271716?s=09&amp;utm_source=pocket_mylist">announced</a> the general availability of Response Actions in MDI. This was preceded by the possibility to configure action accounts with <a href="https://docs.microsoft.com/en-us/defender-for-identity/whats-new#defender-for-identity-release-2169">release 2.169</a> in January.</p><p>Since this is a long-awaited feature of mine, I didn’t hesitate to look into it a bit — here is my report about it.</p><h3>What does the feature do?</h3><p>MDI has been more of a watcher in Active Directory in the past. Mainly logs from the domain controllers and traffic from network cards are analyzed and information from the AD and the member servers (SAM-R) is collected and analyzed. Even if an attack is detected, MDI does not intervene.</p><p>This should now change (a little) with the Response Actions: MDI is enabled to make changes to the AD.<br>Initially, this is limited to disabling user accounts and forcing a password change in the Active Directory — but the potential for further use cases is enormous.</p><h3>What problem does this feature solve?</h3><p>With Microsoft Defender, Microsoft provides us with an extended detection and response solution which, among other things, has the idea (together with Microsoft Sentinel) of providing a central portal for the security operations teams.</p><p>Many attacks are currently focused on the OnPrem environments and of course the Active Directory there — so it makes sense that the SecOps teams are able to act from a central location here as well.</p><h4>Example: Credential Phishing</h4><p>A practical example are credential phishing attacks. Although there are various very effective countermeasures (MFA, Safe Links, Windows Hello,…), it happens again and again that we are alerted, e.g. by alarms in Defender, that a user has clicked on a link that may have led to the user’s credentials being compromised.</p><p>Until now, it was only possible to mark this user as compromised in the AAD, thus setting the user risk to high and forcing the (hopefully) configured user risk policy to force the user to perform a password reset at the next logon to the AAD. Disabling a hybrid user was not even possible at this point and for AD-only accounts we had no recourse at all.</p><p>After setting up the new feature, it is now possible to force the user in Active Directory to change the password and to deactivate him if necessary. This is possible for AD-only, hybrid and also for AAD-only accounts (and guests).</p><h3>Implementation</h3><p>Microsoft has published a <a href="https://docs.microsoft.com/en-us/defender-for-identity/manage-action-accounts">guide</a> for the implementation which is a good foundation. If you have already used MDI, you should meet all the requirements for this feature. The only change is that Group Managed Service Accounts (gMSA) are now mandatory for this feature.</p><p>In the first production implementations I did, I didn’t assign permissions for the group-managed service account domain root level, but only on selected OUs and with groups, and preferred using Powershell over the GUI.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b4a5a21da7bf872aa16233c0935f8b7/href">https://medium.com/media/4b4a5a21da7bf872aa16233c0935f8b7/href</a></iframe><blockquote>Note: You will need one account per forest!</blockquote><p>The now created and authorized account is still stored in the MDI and after some waiting the feature is usable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ultDzPYDFNEUWHMxPDQktw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*rI8xYrxS0-joyQgG6XTCtg.png" /></figure><h3>How can I use the feature?</h3><p>As announced by MS, the new features can only be used in the <a href="https://security.microsoft.com/">Security Portal</a> (that means not in the <a href="https://portal.cloudappsecurity.com/">MCAS</a> or <a href="https://portal.atp.azure.com/">MDI</a> Portal).</p><p>For testing I use the following accounts:</p><ul><li>Ernie is an AD only user</li><li>Big Bird is an AAD only user</li><li>Bert is a synchronized hybrid user</li><li>Google Guest is a guest user</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*e_24BVIkFn6QI7EqSXEtLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*fk1TvMU0ai8tNNJzJRKY5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*SABFmuyVW9zfmpYmI3_Q1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*4kmbu6OG3l0B-_uNwaV0Cg.png" /></figure><p>The first thing to notice is that all users can be disabled, but only for the AD (and hybrid) users a password reset can be triggered at this point.</p><blockquote>I have observed that in the beginning, especially in larger ADs, it can take a while for the feature to work.</blockquote><h3>What happens if I disable a user?</h3><p>After clicking Disable Users, a warning is followed by a confirmation. But be careful: this confirmation only says that the process has been initiated — not that it has been performed successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*G2VZEOfKtcA0z7-M-rx5WQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*osEVj50XQ-TyJWEeuxHRnQ.png" /></figure><p>After a short time, these actions can be seen as jobs in the Action Center history:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPIrZyCe7P6UEm2VLKQxeg.png" /></figure><h4>Active Directory and Hybrid User:</h4><p>If the user originates in AD, MDI will take action and try to disable the user account. If successful, this will result in events <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4725">4725: A user account was disabled</a> and <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4738">ID 4738: A user account was changed</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*151QVkirQEAMXhjRDuimZg.png" /></figure><p>Here is a suitable <a href="https://techcommunity.microsoft.com/t5/ask-the-directory-services-team/advanced-xml-filtering-in-the-windows-event-viewer/ba-p/399761">XML Filter in Event Viewer</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a40a8cc50dd04970ef973271156aa5ec/href">https://medium.com/media/a40a8cc50dd04970ef973271156aa5ec/href</a></iframe><p>Especially if you have many DCs it makes sense to collect the logs centrally. My tool of choice is Microsoft Sentinel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-MdTwSiqU1jtZuLKFPnXg.png" /></figure><p>Alternatively, the data is also available (not as detailed and with significantly more delay, but better prepared) in the Advanced Hunting of the Defender:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Wb4suq9-ieYfKvq6csfDQ.png" /></figure><h4>Azure Active Directory and Guest User:</h4><p>If the user originates in AAD or is a Guest User, MDCA will take action and try to disable the user account. This results in two entries in the AAD <a href="https://docs.microsoft.com/en-us/azure/active-directory/reports-monitoring/reference-audit-activities">Audit Log</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9dAbv3P-bublS5ChRBRUQ.png" /></figure><p>Of course, these logs can also be queried in Sentinel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRLP-0Tb85u7dnKxYKAhgw.png" /></figure><h3>What happens if I force a password reset?</h3><p>Currently the Force Password Reset Action is only available for AD and Hybrid users in the Security Portal. A reset also results in an event 4738 which can be displayed with the above filter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*63wPm9nNQhP6AMtNevVRZg.png" /></figure><p>In Sentinel, it is quite easy to filter using %%1794. (Apparently this is the code for &lt;never&gt;):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aD4hjc7ZrORNDqLMa5WUkw.png" /></figure><h3>Anything else I need to know?</h3><h4>Be careful with Password Never Expires!</h4><p>During testing I noticed that the password reset did not work for all users. The reason was the flag “Password never expires”, which prevents the flag “User must change password at next logon” from being set. If you try to set the flag via PowerShell you will get an appropriate error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*42Ic5g0mn-eP6srU5xZ2dQ.png" /></figure><p>Unfortunately, MDI does not report an error for this action. Means: there is a success both when triggering the action and in the Action Center. In addition, this is also only noticeable in the event logs by the missing event 4738 (see above). So you should really test this feature and check if you have user accounts with “Password never expires” in your environment.</p><h3>Which Permissions do I need to use this feature?</h3><p>I have not yet found any documentation on the permissions required — so here are my observations:</p><ul><li>With the Security Admin role, the described feature is fully usable.</li><li>With the Security Operator role (and MDE RBAC enabled) you can see the users from AAD but not the AD-only users.</li><li>As a security operator you get Disable User displayed but then an error message.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*LY9likBKJmEvTj5P73X3Hw.png" /></figure><h3>Are there automation options?</h3><p>In Defender you can can use both described methods as action in your custom detections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbOkSo8d-YGtmqu1O1YwZg.png" /></figure><h3>Read on:</h3><ul><li>DirTeam — <a href="https://dirteam.com/sander/2022/03/23/howto-programmatically-add-a-microsoft-defender-for-identity-action-account-to-active-directory/">HOWTO: Programmatically add a Microsoft Defender for Identity Action Account to Active Directory</a></li><li>MS Sec Blog— <a href="https://techcommunity.microsoft.com/t5/security-compliance-and-identity/microsoft-defender-for-identity-response-actions/ba-p/3271716?s=09&amp;utm_source=pocket_mylist">Microsoft Defender for Identity Response Actions</a></li><li>MS Docs — <a href="https://docs.microsoft.com/en-us/defender-for-identity/manage-action-accounts">Microsoft Defender for Identity action accounts</a></li><li>Huy Kha — <a href="https://identityandsecuritydotcom.files.wordpress.com/2020/08/kql_internals_hk.pdf">KQL Internals</a></li></ul><p>And last but not least thanks to <a href="https://twitter.com/fabian_bader">Fabian</a> for the review 😘</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a8de5362d0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logic Apps and Azure Active Directory]]></title>
            <link>https://chris-brumm.medium.com/logic-apps-and-azure-active-directory-a3857c9e3951?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3857c9e3951</guid>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 15:06:11 GMT</pubDate>
            <atom:updated>2022-02-09T08:17:34.905Z</atom:updated>
            <content:encoded><![CDATA[<p>Securing the Logic App trigger and using Managed Identities</p><h3>Table of Content</h3><ol><li><a href="#3abe"><strong>Intro</strong></a></li><li><a href="#32ea"><strong>Architecture overview</strong></a></li><li><a href="#6ecd"><strong>Basic structure</strong><br></a><a href="#b000">Step 1: Creation of the Logic App (+Testing)<br></a><a href="#f8d3">Step 2: Preparation of the app registrations (+Testing)</a></li><li><a href="#3566"><strong>Some learnings on App Registrations</strong><br></a><a href="#66dc">App Roles vs. API Permissions<br></a><a href="#c0b7">App ID URI and Redirect URI<br></a><a href="#2514">V1 and V2 Endpoints<br></a><a href="#70e1">Certificate-based authentication</a></li><li><a href="#1b08"><strong>Access Control</strong><br></a><a href="#dbde">Step 3: Authorization Policy and Role Filter<br></a><a href="#22f2">Step 4: Restrict Access</a></li><li><a href="#f984"><strong>Outbound Connections</strong><br></a><a href="#4cd8">Step 5: A Managed Identity for the Logic App</a><br><a href="#9b80">Step 6: HTTP Calls in the Logic App</a></li><li><a href="#0db0"><strong>Summary</strong></a></li></ol><h3>1. Intro</h3><p>I’ve been using Logic App more often lately to automate various things and since I’m also doing sensitive things with it, I’ve spent quite a bit of time looking at how I can secure the Logic Apps.</p><p>In my opinion, one weak point is that the HTTP trigger is only secured with a shared access signature by default. This means that anyone with knowledge of the URL of the trigger can call the Logic app and try to abuse it for their own purposes. There are good ways to secure this trigger better and I will show in this blog what is possible here in cooperation with Azure Active Directory.</p><p>Logic Apps have a good integration with Azure AD and I like to make use of it. Here’s a quick overview of useful use cases:</p><ul><li>When a logic app works against MS Graph, it is best practice to use a managed identity. This can be a system-assigned or one or more user-assigned identities.</li><li>To secure the trigger of a Logic App with OAuth by an Authorization Policy, an App Registration for the Logic App is required. This app can be used for filtering on the authorization policy and for assigning permissions.</li><li>So that the trigger can then be called by another service, a service principal, i.e. an app registration, is also required for the client.</li></ul><h3>2. Architecture overview</h3><p>The system that calls the Logic App (in my demo this is a PowerShell session or Postman) logs on to Azure AD as the <strong><em>TriggerDemoClient</em></strong>. This login is done via a previously created client secret.</p><p>As a trigger client app, a token for the app <strong><em>TriggerDemoClient</em></strong> is requested from Azure AD. Since <strong><em>TriggerDemoClient</em></strong> is entitled to a (predefined) App Role of <strong><em>TriggerDemoServer</em></strong>, the token contains the corresponding role as a claim.</p><p>With this token as Authorization Header the trigger of the Logic App is called. The Authorization Policy defined there checks at the token</p><ul><li>the issuer → i.e. whether the token was issued by the own tenant.</li><li>the audience → i.e. whether the token was issued for <strong><em>TriggerDemoServer</em></strong>.</li></ul><p>The token is then available to the workflow in the Logic App and can be evaluated there with some effort. First, the trigger checks whether a bearer token is present and then passes it on to the further logic or rejects the connection. The content of the role claim in the token is of particular interest here, but depending on the logic, other claims can of course also be interesting.</p><p>The Logic App itself runs under a managed identity with which it can then access the Azure Active Directory via REST using the MS Graph, for example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*cKWBKa9RP9_z0aEYcR9Uuw.png" /></figure><h3>3. Basic structure</h3><h4>Step 1: Creation of the Logic App</h4><p>Creating a Logic App is straightforward and can be done via the Azure Portal, for example. The only important thing is that everything described here only works with the Consumption Based version, since the “standard” version does not support login via OAuth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*68SjRrHpEioOVMxhGC1kpw.png" /></figure><p>For the first tests, I create a new empty workflow that contains only an HTTP trigger and a response action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*E3TbQdwW5J96g5mMdGVn5g.png" /></figure><h4>Test trigger with PowerShell</h4><p>The first test calls the trigger with the shared access signature and passes a JSON as the body.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/875520f562139be390e56f305c7a0ec8/href">https://medium.com/media/875520f562139be390e56f305c7a0ec8/href</a></iframe><h4>Test trigger with Postman</h4><p>In Postman it makes sense to first create an environment in which all URIs and IDs are stored:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8IyM9KoKRekYjcvjKWDqg.png" /></figure><p>Then, as per PowerShell, the Logic App trigger is called and a JSON is passed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2B1yJy2BpBRhUHVM94Tbw.png" /></figure><h4>Step 2: Preparation of the app registrations</h4><p>For our scenario, two app registrations are needed in AAD:</p><ul><li>An app that represents the Logic App that is logged in to and to which the permissions are assigned. -&gt; TriggerDemoServer</li><li>An app for the client component that is used to log in and to which the permissions are assigned -&gt; TriggerDemoClient</li></ul><p>The creation of app registrations can be done well and easily in the portal but for traceability and reproducibility I will configure it where appropriate in this blog via PowerShell. Per Powershell the apps can be created easily with this script (mostly stolen <a href="http://blog.octavie.nl/index.php/2017/09/13/creating-azure-ad-app-registration-with-powershell-part-1">here</a>) which does the following:</p><ul><li>Creation of the App Registration</li><li>Creation of the Service Principal</li><li>Configuration of the executing user as owner</li><li>Optional: Create a secret (for TriggerDemoClient)</li><li>Optional: Set the AppID URI (for TriggerDemoServer)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7798df3d0db6f42b7da11aa9c4ad9da6/href">https://medium.com/media/7798df3d0db6f42b7da11aa9c4ad9da6/href</a></iframe><ul><li>I create the app TriggerDemoServer with an AppID URI in the format <strong>api://AppID</strong>. I discuss what that is and why we need it below.</li><li>I create the app TriggerDemoClient with a secret for now. Whether you want to keep this or switch to a certificate later depends on your calling app and will be discussed below.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8425a8c6bd5a392ce60b13951aed77de/href">https://medium.com/media/8425a8c6bd5a392ce60b13951aed77de/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iByUi677uNsnAXVEhYRIdg.png" /></figure><p>The result can then be viewed in the App Registrations and Enterprise Applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ij8u1y-RiE8oIW6xDotrgw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IUDEQYTMOMRhfUKrBV9Nw.png" /></figure><p>The next step is to define a role on the TriggerServerDemo app and assign it to the TriggerClientDemo. This is relatively simple in the portal but a bit more complex via Powershell. Fortunately I am not the first one who wants to automate something like this and I can rely on good scripts. 😁</p><p>There is a very good <a href="https://gist.github.com/psignoret/45e2a5769ea78ae9991d1adef88f6637">script</a> by <a href="https://twitter.com/psignoret">Philippe Signoret</a> for defining roles on an app. Fortunately, my script from above directly outputs the object of the app registration which I pass to this script via a variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afa806bf4c052d26985d22fd42f68b5b/href">https://medium.com/media/afa806bf4c052d26985d22fd42f68b5b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8vcRxMCfXMmpCJfHWcyQg.png" /></figure><p>For assigning the role I just created, I found a <a href="https://gist.github.com/your-azure-coach/65d715aaa9a0fcdc0237b8c98a61279d#file-aad-apply-role-assignments-ps1">script</a> on this great <a href="https://yourazurecoach.com/2020/09/29/scripting-azure-ad-application-roles-assignments/">Blog</a> by <a href="https://twitter.com/ToonVanhoutte?t=-ELJfbtEwJ7JYe__6F3jww&amp;s=09">Toon Vanhoutte</a>. Since I wanted to use the <a href="https://gist.github.com/your-azure-coach/65d715aaa9a0fcdc0237b8c98a61279d#file-aad-apply-role-assignments-ps1">script</a> “as-is”, I prefer to script around it a bit and create the needed JSON for the definition temporarily.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e1914d772e9073c919be7306ae2a2f1/href">https://medium.com/media/7e1914d772e9073c919be7306ae2a2f1/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nuPKnRazECi29fkLPzuPAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzxJjG-drOHYCrzJOL_5Jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gb14RhXaMpYLr-2wQ4ZjHQ.png" /></figure><h4>Test login with PowerShell and examination of the token</h4><p>To check if the creation of the apps, the roles and the permissions worked, it is useful to log in as a client app and request a token for the server app. This script does that and copies the token to the clipboard (for the next step).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d462ec9ee45fc7c58629d779aa767213/href">https://medium.com/media/d462ec9ee45fc7c58629d779aa767213/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZroygNz2DDMt9ez9UcQQZQ.png" /></figure><p>Before you start to build filters for the tokens in the next step it is very useful to deal a little bit with the token and to know in case of doubt (for example if something is not running) where you can look at the current token.</p><p>For token investigation, there are several web-based tools that promise not to remember the tokens. My favorite is: <a href="https://jwt.ms/">https://jwt.ms/</a></p><p>At this example token, the Audience (1), the Issuer (2) and the Role Claim (3) can be examined very well by this tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbhQKSDvqJP0nIjyMno-UQ.png" /></figure><h3>4. Some learnings on App Registrations</h3><p>While dealing with the question of how to configure the necessary app registrations, I learned a few things that I would like to share here. First of all, however, I would like to point out what I consider to be a particularly useful feature: the Integration Assistant directly at the App Registration. After selecting the Application Type, various recommendations are displayed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVVBLiViy6Vyj8ei_BQWAg.png" /></figure><h4>App Roles vs. API Permissions:</h4><p>For me, assigning rights to apps to apps was quite confusing at first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*ttDk-aSW9DCaxnRKNGVyAA.png" /></figure><p>The definition of rights to an app takes place in different places depending on the type of permission:</p><ul><li>If it is a delegated permission — meaning a user is involved — the menu item <strong><em>Expose to AP</em></strong>I is used.</li><li>If it is an App Permission — meaning the call by another service principal — the menu item <strong><em>App Roles</em></strong> is used.</li></ul><p>If an app should get permissions to another app — for example MS Graph — this is configured in the menu item <strong><em>API permissions</em></strong> regardless of whether it is delegated or app permissions.</p><h4>App ID URI and Redirect URI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*KiJ7fj3xDdUj4sSirBD17w.png" /></figure><p>There are two different attributes for URIs on an app registration. Depending on the use case, these should be configured or not.</p><p>Redirect URIs are used to restrict which (URIs of) applications can use this application registration for login. Redirect URIs is an important security feature for web apps that prevents an attacker from stealing authentication tokens (see <a href="https://platinumdogs.me/2016/04/25/understanding-the-oauth2-redirect_uri-and-azure-ad-reply-url-parameters/">here</a>). However, since the scenario I described uses a so-called <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow">client credential flow</a> (without the authorization part), no redirect URI is needed. There are no redirects or callbacks in the scenario. <br><strong>For all web applications, for example with browser access, it is very important that the redirect URIs are configured correctly.</strong></p><p>An Application ID URI is a property of the Application Registration and is used to request tokens for this app — similar to an SPN in AD. An App ID URI can be used in various formats (see <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/security-best-practices-for-app-registration#appid-uri-configuration">here</a>) and must be globally unique for multi-tenant apps. Although you can also simply use the App ID to request tokens, it is best practice to define and use this URI, e.g. to simplify later migrations.</p><h4>V1 and V2 Endpoints</h4><p>I decided to use the V2 endpoints for TriggerDemoServer App. A comparison of the two versions can be found <a href="https://matthijs.hoekstraonline.net/2020/04/27/v1-and-v2-identity-and-access-tokens-with-azure-active-directory/">here</a> and <a href="https://nicolgit.github.io/AzureAD-Endopoint-V1-vs-V2-comparison/">here</a>.</p><p>For this, the <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-app-manifest#accesstokenacceptedversion-attribute"><em>accessTokenAcceptedVersion</em></a><em> </em>parameter in the App Registration manifest must be changed to 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*7oYvWjdMkoZreDMq9sWcIg.png" /></figure><p>For further handling, the main difference is that some claims in the tokens have slightly different values:</p><pre>V1: <br>Issuer -&gt; <a href="https://sts.windows.net/">https://sts.windows.net/</a>{tenantId}/<br>Audience -&gt; App ID URI</pre><pre>V2:<br>Issuer -&gt; <a href="https://login.microsoftonline.com/">https://login.microsoftonline.com/</a>{tenantId}/v2.0<br>Audience -&gt; AppId of TriggerServerDemo</pre><h4>Certificate-based authentication</h4><p>If the client app supports it, it makes a lot of sense to use a certificate to log in to the client app instead of the app secret. Although I don’t go into it in this blog, here are the PowerShell sample snippets to log in with a certificate and create one for upload (via GUI).</p><p>Login as Service Principal with Powershell and Cert:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ddc3b66cc4f7df204617fd9c367616d/href">https://medium.com/media/7ddc3b66cc4f7df204617fd9c367616d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YC3wNGRx9PrXAMcjK3JRMw.png" /></figure><p>Creation and export of a new client cert with Powershell:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1cd6f7c8ce384859d009dacc1c0dd62/href">https://medium.com/media/c1cd6f7c8ce384859d009dacc1c0dd62/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S2r2abhCdyLmiykGFoYZOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipIOhPhua9CzedErMI-waQ.png" /></figure><h3>5. Access Control</h3><h4>Step 3: Authorization Policy and Role Filter</h4><p>Azure AD does not issue tokens for an app if the user / service principal does not have an assignment for it. But if we don’t care to check the audience of the token, I can send any Bearer token for another (V2) app to the Logic app and it will accept it.</p><p>The Authorization Policy the defines that the value of the claim Issuer has to be <a href="https://login.microsoftonline.com/0f642f1e-8030-465d-91cf-5252c6ca581b/v2.0"><strong><em>https://login.microsoftonline.com/[TenantID]/v2.0</em></strong></a><strong><em> </em></strong>(1)<strong><em> </em></strong>and the value of the claim Audience has to be the <strong><em>AppID</em></strong> (2) of the TriggerDemoServer App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*H5HTXH1BEHqWJwKM8x8E9Q.png" /></figure><p>At the trigger of the app it is enabled that the Authorization Header is passed to the Logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*MdSlJoDjr9FuPmCbVReWuA.png" /></figure><p>A role is defined in the Logic App (1) which is after the extraction (2) compared with Role Claim in the token (3). Depending on the presence of the role, either the request body (4) or a permission denied (5) is returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsrZBEMUh8zDkT0F28VxcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*2SNBW9JMSpV742XyNw9yMw.png" /></figure><p>I took the process for unpacking the token (2) from a sensational <a href="https://gotoguy.blog/2020/12/31/protect-logic-apps-with-azure-ad-oauth-part-1-management-access/#:~:text=If%20we%20want%20to%20decode%20that%20Bearer%20token%20to%20get%20a%20look%20into%20the%20payload%20claims%2C%20we%20can%20achieve%20that%20with%20some%20custom%20expression%20magic.%20Add%20a%20Compose%20action%20to%20the%20Logic%20App%20and%20use%20the%20following%20custom%20expression%3A">blog</a> by <a href="https://twitter.com/JanVidarElven">Jan Vidar Elven</a>. Especially the part with the modulo function is very important (and cost me a lot of time because I first had another solution that didn’t always work…).</p><blockquote>Alternatively, you can copy the basic workflow logic <a href="https://gist.github.com/crmhh/fbedfbf0a370a63e233926e66fd6bc32">here</a>.</blockquote><h4>Test trigger with PowerShell and OAuth Authentication</h4><p>Now that all the components are in place, we’ll test them before moving on:</p><ul><li>Login as Client App with Connect-AzAccount</li><li>Get a Bearer Token for the Server App with Get-AzAccessToken</li><li>Trigger the Logic App with Invoke-RestMethod</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53f60348e8ea7dd7e9103c092904c608/href">https://medium.com/media/53f60348e8ea7dd7e9103c092904c608/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UL_hzvyoNYaj6d4ul1GJ0Q.png" /></figure><h4>Test trigger with Postman and OAuth Authentication</h4><p>With Postman we need two action. But before we start it is a good idea to create an environment to store all the IDs, secrets and URLs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*aX6IDjlA9OkoaCUOgtwKGg.png" /></figure><p>The first step is getting a Bearer Token for the Server App:</p><ul><li>Send GET to <a href="https://login.microsoftonline.com/%7B%7BTenant-ID%7D%7D/oauth2/token">https://login.microsoftonline.com/{{Tenant-ID}}/oauth2/token</a></li><li>Set Header Content-Type: application/x-www-form-urlencoded</li><li>Set Body grant_type: client_credentials</li><li>Set Body client_id and client_secret with your credentials</li><li>Set Body ressource to the Server App</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TMV6fZNEe_WqhWJBaFS3Uw.png" /></figure><p>The second step is the Trigger of the Logic App</p><ul><li>Send POST to the URL of your HTTP (without the SAS)</li><li>Set Authentication to Bearer Token and insert the token from step 1</li><li>Set Header Content-Type: application/json</li><li>Set Body to Raw:JSON and insert your JSON</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HWtGvGZcywDUVCIIfi-uVA.png" /></figure><p>The procedure for filing with Postman is also <a href="https://docs.microsoft.com/en-us/rest/api/servicebus/get-azure-active-directory-token#use-postman-to-get-the-azure-ad-token">described in the MS docs</a>.</p><h4>Step 4: Restrict Access</h4><p>Beyond enabling OAuth authentication, it is possible and reasonable to take further measures to secure the trigger.</p><h4>Conditional Access for Workloads</h4><p>A new conditional access feature for regulating workload identities has recently been added. Here we do not have all the options we know from Conditional Access, but it is possible to restrict from which IP ranges access can take place. In the sign-in logs of the AAD we also see the (blocked) retrieval (1) of an access token from the client application (2) to the server application (3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*LCCdA_CWWPx9vm0oQ8HKiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*fipYFNcipciTHQ62jZuGEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*Xm2uXCKmVgPYw_ubsXPlcw.png" /></figure><h4>Access control configuration</h4><p>In addition, the Logic App can be configured from which IP addresses (1) the trigger can be called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AvVEEHeTDsg_KznncqaiZw.png" /></figure><p>This effectively prevents logging in with an exported (stolen) token:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0fK5M9ocram5Ru4JzqAe8g.png" /></figure><h4>Trigger condition</h4><p>Now that we have enabled OAuth authentication and secured all entities involved, it remains to ensure that logging in via the shared access signature is no longer possible.</p><blockquote>In my example workflow, checking for the role in a SAS already results in an error, but it makes sense to prevent this directly at the trigger.</blockquote><p>The whole topic is super explained in this b<a href="https://securecloud.blog/2021/02/09/deep-diver-hardening-authentication-and-authorization-between-logic-apps-and-api-management/">log</a> by <a href="https://twitter.com/SantasaloJoosua">Joosua Santasolo</a>. As described by Joosua, this trigger condition ensures that a login is only possible with OAuth:</p><pre>@startsWith(triggerOutputs()?[&#39;headers&#39;]?[&#39;Authorization&#39;],&#39;Bearer&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*fBmH15UTQ-LYzVugXqy4Lg.png" /></figure><h3>6. Outbound Connections</h3><p>To complete our picture from above, we still need access from the workflow to other apps. For me this is often MS Graph, but of course you can also trigger other Logic apps with it.</p><h4>Step 5: A Managed Identity for the Logic App</h4><p>Logic Apps can use managed identities and you should always use them if possible. Managed eliminates credential management and all the risks associated with it.</p><blockquote>Due to the unfortunately quite high delay in granting permissions, I prefer to work with User Assigned Permissions rather than System Assigned Permissions. Additionally, the same Managed Identity can be used in multiple Logic Apps (useful for troubleshooting) and I can more easily implement a naming convention. MS has a good overview on the topic <a href="https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview">here</a>.</blockquote><p>Since the management of the (User Assigned) Managed Identities via GUI is only partially possible and quite confusing I think it is the best option to always do all steps via PowerShell (at least until that has gotten better).</p><p>The permissions (often <a href="https://docs.microsoft.com/en-us/graph/permissions-reference">on the graph</a>) of the Logic App sum up by the called functions. That means it makes sense to create a spreadsheet containing the used calls (look for POST, PUT, PATCH) and the necessary possible permissions.</p><p>This allows on the one hand a good selection and on the other hand it gives the reasoning for the necessary permissions. For example, I always ask for the exact function that needs the requested permissions when I am asked to release them in the AAD. I took the main part of the script from <a href="https://gist.github.com/LauraKokkarinen/081a7e27d50e90a06ca80eaeb5fb357a#file-add-mi-permissions-to-graph-ps1">here</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12a3774e407a3f0e380b74c2378a918b/href">https://medium.com/media/12a3774e407a3f0e380b74c2378a918b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6xHztraCn4PH34aOIsBUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXUtauleHbCtNayAo_WVJQ.png" /></figure><h4>Step 6: HTTP Calls in Logic Apps</h4><p>Although there are many pre-built connectors I mainly use the HTTP action to address other APIs, because the connectors often (for example the AAD connector) do not use the managed identity but a function user (stored as API Connection) and also often work with too high permissions (to be generically usable).</p><p>To use the managed identity in the HTTP action, you need to connect the account to your Logic App and select the managed identity after selecting the authentication type and specify the resource to log in to (the App ID URI).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*4OgReP8FNrW2XiwRn5rMPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*NCU8Kf3ycVbcqNUxmOzBKA.png" /></figure><p>In my workflows, an HTTP action is almost always followed by a Parse JSON action to process the output. The schema can be easily created by using the output of the Graph Explorer as a sample payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*WalMyp0v3hlfN5o89yb2LA.png" /></figure><p>I also got into the habit of writing the required values from the outputs into variables. On the one hand this increases the clarity and on the other hand it reduces the complexity a bit, because many values are unexpectedly an array and have to run through a loop before they can be used. The graphical designer also inserts this loop automatically. Here is an example for querying the tenant ID:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*NzmJDVS3UTteqPwPXQ2nGQ.png" /></figure><h3>7. Summary (Logic App + Azure AD = 💘)</h3><p>There are great ways to increase the security level of the trigger. The implementation is also done quickly if you understand how it works — I hope this blog will help with that.</p><p>Finally, here is a small visualization of the effectiveness of the different options to use the trigger 😉:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*-NnT6dAl5kEQyew6N0kf5A.jpeg" /></figure><h3>Acknowledgements:</h3><p>I don’t think anything discussed in this blog has not already been described by someone else (probably better). I have only collected the things and tried to bring my perspective on it.</p><p>I have tried to link all sources directly in the text, but at this point I would like to highlight people I have learned from:</p><ul><li>Thomas Naunheim was my sparring partner for many of the topics covered here. We discussed many details and I learned a lot from and with him.</li><li>This blog series (<a href="https://t.co/ByDYIvAU5L">1</a>, <a href="https://t.co/TPLw8Amq4X">2</a> and <a href="https://t.co/Vmoj7o9lqj">3</a>) by <a href="https://twitter.com/JanVidarElven">Jan Vidar Elven</a> really opened my eyes and got me started.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3857c9e3951" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disable Password Expiration for Service Users in Azure AD]]></title>
            <link>https://chris-brumm.medium.com/disable-password-expiration-for-service-users-in-azure-ad-bca6c24d1c88?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/bca6c24d1c88</guid>
            <category><![CDATA[azure-active-directory]]></category>
            <category><![CDATA[logic-apps]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Sat, 18 Sep 2021 12:47:54 GMT</pubDate>
            <atom:updated>2021-09-18T12:47:54.848Z</atom:updated>
            <content:encoded><![CDATA[<h4>with a Logic App running at least privileges</h4><p><a href="https://chris-brumm.medium.com/how-to-migrate-from-pass-through-authentication-to-password-hash-sync-7f798b37bb30">Recently I had the challenge</a> to set a Password Policy for a lot of Service Users in Azure Active Directory to enable a migration from Pass-through Authentication to Password Hash Sync.</p><h3>First attempt with the AAD standard methods</h3><p>The first prototype of my Logic app was built very quickly and I knew again why I like Logic apps so much 😍:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*cbbOx6UZAUQEVutsC-squg.png" /><figcaption>Picture 1: The first attempt</figcaption></figure><p>On closer inspection, however, I noticed that my quickly created Logic app with the ready-made actions from the <a href="https://docs.microsoft.com/en-us/connectors/azuread/">AAD connector</a> clashed quite strongly with my ideas about the required rights.</p><p>If you create a Logic App as a Global Admin that uses the AAD connector actions, you will quickly find yourself in a Consent Dialog that asks for the following permissions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*8L0n-75h7SOlJGJr4TMJ1w.png" /><figcaption>Picture 2: The permissions for the AAD connector 😲</figcaption></figure><p>In order to reduce the rights, I shortly considered creating a function user that only has the role of user admin — but then I quickly discarded this, as it all felt rather wrong to me.</p><h3>The least privilege version</h3><p>Slightly shocked by the handling of administration rights, I looked around for alternatives — thanks again for your advice <a href="https://twitter.com/Thomas_Live?s=20">Thomas </a>— and then built a version that uses the HTTP method and the managed identity of the Logic App.</p><p>Compared to a functional user, the managed identity offers the advantages of being bound to this Azure resource and being able to be authorized very granularly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*yEhDhKeYjMoHxrWFSWqVbw.png" /><figcaption>Picture 3: The permissions we really need</figcaption></figure><h3>Step by Step Guide</h3><h4>A group for the service user</h4><p>The basis for my Logic App is an AAD group. Since there is of course a consistent naming convention for the service accounts, a dynamic group can be used in my case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*44I2NIWnJZn2DqjiGwTY3A.png" /><figcaption>Picture 4: Dynamic group for service user</figcaption></figure><h4>A new Logic App</h4><p><a href="https://docs.microsoft.com/en-us/azure/logic-apps/quickstart-create-first-logic-app-workflow">Create a Logic App</a> like in this example. If you create a new LA the system assigned managed identity is already enabled. You can check this and get the object ID in the section identity of the LA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*44gyo3ZFh1tUa1C_pZc8zw.png" /><figcaption>Picture 5: System assigned managed identity</figcaption></figure><h4>Permissions</h4><p>The next step is to assign the permissions we really need (see picture 3):</p><ul><li><em>User.ReadWrite.All </em>-&gt; to set the Password Policy</li><li><em>GroupMember.Read.All </em>-&gt; to read the group members</li></ul><p>Unfortunately, it is not yet possible to assign these permissions via GUI, but fortunately there is <a href="https://gist.github.com/LauraKokkarinen/081a7e27d50e90a06ca80eaeb5fb357a#file-add-mi-permissions-to-graph-ps1">this script</a> by <a href="https://twitter.com/LauraKokkarinen?s=20">Laura Kokkarinen</a> that solves the problem.</p><p>Simply fill the variables <em>$miObjectID</em> with the object ID of the managed identity and <em>$permissionsToAdd</em> with the above-mentioned permissions.</p><h4>Some logic for the Logic App</h4><p>The last step is to add some logic to the Logic App. My goal at this point was to read out the memberships of a given group and set the password policy for each service user if not already set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*VHLeRw5SF4BVBS7XXLtcIw.png" /><figcaption>Picture 6: The better approach</figcaption></figure><p>The big difference to the first version is that instead of the AAD actions, the HTTP action is now used. This allows us to use the managed identity, but requires us to deal a little with the MS Graph (<a href="https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&amp;tabs=http">Group Members</a>, <a href="https://docs.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&amp;tabs=http">Get User</a> and <a href="https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&amp;tabs=http">Update User</a>) and the use of the Parse JSON action to make the result evaluable.</p><p>The system-assigned managed identity can then simply be selected in the HTTP action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*FGq-JkCKr79ra9I5CdfE8w.png" /><figcaption>Picture 7: Authentication in HTTP action</figcaption></figure><p>If you want to use my example you can download it on <a href="https://github.com/crmhh/stuff/blob/main/setPWPolicyforServiceUsers">GitHub</a> — you just have to insert the ID of your group into the variable <em>ServiceUser</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bca6c24d1c88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to migrate from Pass-through Authentication to Password Hash Sync]]></title>
            <link>https://chris-brumm.medium.com/how-to-migrate-from-pass-through-authentication-to-password-hash-sync-7f798b37bb30?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f798b37bb30</guid>
            <category><![CDATA[phs]]></category>
            <category><![CDATA[azure-active-directory]]></category>
            <category><![CDATA[hybrid-identities]]></category>
            <category><![CDATA[aadc]]></category>
            <category><![CDATA[identity]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Sat, 18 Sep 2021 12:44:42 GMT</pubDate>
            <atom:updated>2021-09-18T12:48:47.545Z</atom:updated>
            <content:encoded><![CDATA[<h4>…and replace the AD security functions that blocked you so far!</h4><p>The migration from Active Directory Federation Services (ADFS) to Password Hash Sync (PHS) is well documented by Microsoft and in various blogs. Since there are also many good reasons for the ADFS replacement, it really makes sense that the focus is on this. Especially since the migration from Pass-through Authentication (PTA) is very simple in comparison.</p><p>However, a migration from PTA to PHS also offers some advantages and the previously existing limitations are largely no longer present. So it is worthwhile to start this migration to have the following advantages:</p><ol><li>Support for leaked credential detection and AAD Domain Services</li><li>Full integration with AAD Connect Health</li><li>AAD auth independent from availability of OnPrem environment</li></ol><p>For the general procedure, the <a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/plan-migrate-adfs-password-hash-sync">migration guide for ADFS to PHS</a> (+<a href="https://aka.ms/ADFSTOPHSDPDownload">Whitepaper</a>) offers a lot of useful information that can also be used here.</p><h3>Why was PTA chosen in the first place?</h3><p>Before migrating something, it is always a good idea to find out why the decision was made at that time. In my experience (apart from gut feeling 😉) the main argument for PTA was usually the requirement to use<strong> AD security policies</strong>. The MS documentation says:</p><blockquote>If you need to apply, user-level Active Directory security policies such as account expired, disabled account, password expired, account locked out, and sign-in hours on each user sign-in, Azure AD requires some on-premises components.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NI2drTHphymxfZtS.png" /><figcaption><a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/media/choose-ad-authn/azure-ad-authn-image1.png">https://docs.microsoft.com/en-us/azure/active-directory/hybrid/media/choose-ad-authn/azure-ad-authn-image1.png</a></figcaption></figure><p>Now Microsoft has upgraded a bit in this field and with a little effort you can use many of the functions with PHS and additionally use the above mentioned advantages.</p><h3>Which and how can the AD Security functions be replaced?</h3><p>Before we look at the individual functions in detail, I would like to ask “Do you really need all of them? What were the reasons you introduced these features back then?”</p><p>Most institutions like <a href="https://securityboulevard.com/2021/03/nist-password-guidelines-2021-challenging-traditional-password-management/">NIST</a>, UKs <a href="https://www.ncsc.gov.uk/collection/passwords/updating-your-approach#:~:text=The%20NCSC%20is%20working%20to,control%20and%20identity%20management%20approach.">NCSC</a> or the <a href="https://www.heise.de/security/meldung/Passwoerter-BSI-verabschiedet-sich-vom-praeventiven-Passwort-Wechsel-4652481.html">German BSI</a> have e.g. changed their stance on periodic password changes, externals can now be conveniently onboarded as guests, and in AAD there are features like Access Packages and Access Reviews to manage accounts and permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*XeGhGihR4ieJvzm5kkzpzw.png" /></figure><h4>A: Account Lockout</h4><p>Account Lockout was and is an effective feature in Active Directory to prevent Brute Force Attacks because you can throttle the login trials. If you have not yet configured a lockout policy, my recommendation is to do so and also implement Microsoft Defender for Identity to make these attacks more difficult and <a href="https://docs.microsoft.com/en-us/defender-for-identity/compromised-credentials-alerts">to detect</a> them.</p><p>In Azure Active Directory there is also an Account Lockout Policy but there it is only one of the many tools to protect the identities. Azure MFA and Identity Protection are way more effective in preventing Brute Force Attacks and also other — meanwhile much more common — attacks like Password Spraying.</p><p>With PTA (as with ADFS) there is the requirement to align lockout policies, otherwise it is easy for AD accounts to be locked out externally by failed login attempts (by attackers). In simple terms, this means that it is necessary to configure a more restrictive policy on the AAD than on the AD. (<a href="https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-password-smart-lockout">Detailed description</a>)</p><p>On the subject of account lockout, the migration fundamentally improves the situation, as it is now no longer necessary to align the policies in AD and AAD to prevent AD accounts from being locked out externally.</p><p>So if you have a strict policy configured here it can be relaxed a bit — in my opinion there are much more effective measures in AAD to protect the accounts than account lockout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*IOXBY22MqVxVDZyALj5iZA.jpeg" /></figure><h4>B: Logon hours</h4><p>The logon hour feature allows logons only at certain times of the week. This can be done either to increase security or, for example, to implement labour health and safety regulations. An example of both is to enforce that employees can only log on during their working hours.</p><p>While I see much better defence methods for security (Azure MFA, Password Protection, Microsoft Defender for Identity,…) the regulations issue can probably only be solved organisationally or maybe an approach like described <a href="https://www.linkedin.com/pulse/restrict-office-365-access-during-certain-time-frames-brian-jensen/">here</a> can work (fortunately I never had to implement that so far).</p><h4>C: Account Expiration</h4><p>For this part, Microsoft only points out that it would be useful to implement a PowerShell script that disables accounts that are expired. I have written a <a href="https://github.com/crmhh/stuff/blob/main/DisableExpiredUsers.ps1">simple script</a> (with lots of stolen snippets 🙃) to do that job which can run as a scheduled task in your AD.</p><p>To get a first idea how many user are affected in which locations just use this:</p><pre>get-aduser -filter * -properties Name, PasswordNeverExpires, CN| Where-Object {$_.PasswordNeverExpires -and $_.Enabled} `<br> | Select-Object @{Label=&#39;ParentContainer&#39;;Expression={$_.Distinguishedname -replace &quot;CN=$($_.cn),&quot;}} `<br> | Group-Object -Property ParentContainer ` <br> | Select-Object Name,Count `<br> | Out-GridView</pre><p>Alternatively, of course, it may make sense to adapt the process and use access reviews in the future, for example.</p><blockquote>A short excursion: You should take the opportunity to check whether your expired/disabled users might still be consuming licenses. AAD does not know expired users and disabled users do not automatically lose their licenses. A possible approach if you use Group Based Licensing (👍) would be to extend my script to remove all relevant groups…</blockquote><h4>D: Password Expiration</h4><p>After switching to PHS, we no longer have a direct connection between the two directories. Now it is “just synchronized” and the authentication on the AAD is completely independent of the AD.</p><p>The basic problem with Password Expiration is very well described by <a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-password-hash-synchronization#password-expiration-policy">Microsoft</a>:</p><blockquote><em>If a user is in the scope of password hash synchronization, by default the cloud account password is set to Never Expire. You can continue to sign in to your cloud services by using a synchronized password that is expired in your on-premises environment. Your cloud password is updated the next time you change the password in the on-premises environment.</em></blockquote><p>The solution for the problem is then also described directly at the same point. However, since this solution has only been available since the end of 2019, many may have opted for PTA at that time.</p><p>To get the same function regarding password expiration with PHS you need</p><ul><li>same password policies in AD and AAD (default 90 days)</li><li>Password Writeback to catch situations where the user is prompted by AAD to change the password.</li></ul><p>Regarding a migration from PTA to PHS it is very useful to implement this before the first synchronization of the password hashes, otherwise a change cycle has to be waited until the adaptation takes effect.</p><blockquote>In the planning it is very important to note that the AD flag “Password never expires” is not synchronized and has no effect in the AAD.</blockquote><p>This means that if you synchronize service or functional users that have this flag set, you need to create a solution for these accounts. My first advice in this case is to check if these accounts need to be synced at all or can be taken out of sync. To check this, a <a href="https://cloudtech.nu/2020/05/03/export-azure-ad-last-logon-with-powershell-graph-api/">script</a> from <a href="https://twitter.com/danne_alden?s=20">Daniel Aldén</a> has proven itself to me. I only modified it a bit to filter for the prefix SVC.</p><p>Your options for the rest of the service users are:</p><ul><li>change your approach on periodic password changes and skip this topic (my favorite 😍).</li><li>create a script to find the users with the flag and change the password policy in AAD to never expire. Here is a very simple snippet:</li></ul><pre>Get-Content ServiceUser.txt | foreach { Set-AzureADUser -ObjectID &lt;User Object ID&gt; -PasswordPolicies &quot;DisablePasswordExpiration&quot;</pre><ul><li>use a dynamic group and a logic app to set DisablePasswordExpiration. As this is a bit beyond the scope of this blog post, <a href="https://chris-brumm.medium.com/disable-password-expiration-for-service-users-in-azure-ad-bca6c24d1c88">I have explained the procedure in a separate post</a>.</li></ul><p>If you’ve decided to keep the periodic change and after you took care for your service / function users you can changes the default behavior for synchronized users with the following CMDlet:</p><pre>Set-MsolDirSyncFeature -Feature EnforceCloudPasswordPolicyForPasswordSyncedUsers</pre><p>The next time the password hash is changed, the DisablePasswordExpiration attribute is automatically removed and the default policy takes effect. In our migration this should be done before you enable PHS.</p><h3>How do I proceed reasonably with the migration?</h3><p>As always with identity migrations, it makes sense to be well prepared and to deal with all topics to the extent that you understand exactly how the current and future solution works. A cut-over plan including rollback is also recommended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*OZ_bCjTPKj1ozK5oeX1-3Q.png" /></figure><h3>Step 1: Preparation</h3><p>This is the most important step — take your time for it!</p><h4>Take care for the AD Security Features you want to replace</h4><p>As described above, PTA may have some AD security features in use that cannot be mapped 1:1 in AAD or require additional preparations. It is important to have made decisions and preparations for these topics before switching on PHS.</p><h4>Extend Permissions of the AADC Account in AD</h4><p>Azure AD Connect will need additional permissions for enabling PHS and Password-Writeback. I’ve made very good experiences with the module shipped with AADC . If you’re not familiar with the module see Samis Blog on the topic:</p><p><a href="https://samilamppu.com/2018/11/15/azure-ad-connect-changing-adds-connector-account/">Azure AD Connect - Change ADDS Connector Account</a></p><p>Here is my script for granting the permissions:</p><pre>#Modules<br>Add-WindowsFeature RSAT-AD-PowerShell<br>Add-WindowsFeature RSAT-ADDS-Tools<br>Import-module ActiveDirectory<br>Import-Module &quot;C:\Program Files\Microsoft Azure Active Directory Connect\AdSyncConfig\AdSyncConfig.psm1&quot;</pre><pre># Vars<br>$accountName = &quot;ADDSConnectuser&quot;<br>$ForestDN = &quot;OU=xxx,DC=xxx,DC=xxx&quot;<br>$domain = (Get-ADDomain).Forest</pre><pre>#Grant Permissions for PHS (Domain Admin needed)<br>Set-ADSyncPasswordHashSyncPermissions -ADConnectorAccountName $accountName -ADConnectorAccountDomain $domain</pre><pre>#Grant Permissions for PW Writeback<br>Set-ADSyncPasswordWritebackPermissions -ADConnectorAccountName $accountName -ADConnectorAccountDomain $domain -ADobjectDN $ForestDN</pre><h4>Implement Password Writeback</h4><p>After assigning the permissions in AD, only the feature has to be activated in AADC. The whole process is described in <a href="https://docs.microsoft.com/en-us/azure/active-directory/authentication/tutorial-enable-sspr-writeback#enable-password-writeback-in-azure-ad-connect">this tutorial from Microsoft</a> — but actually only consists of activating the checkbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*xxndB4qPLGXvc-Q_.png" /></figure><h4>Overview of the current Tenant and AADC setup and more</h4><p>Before you move on to the next step, make yourself familiar with the current AADC environment. Which version AADC are you running? Is maybe an update reasonable before the change? (yes — it is!)</p><p>And you should also review what you have implemented so far and look at the tools you need, such as the <a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/tshoot-connect-password-hash-synchronization">troubleshooting tool</a>.</p><p>Also, I highly recommend having a look at the logs to see when something changes or gets out of hand. For monitoring we have the following tools:</p><ul><li>The logs on the AADC in the Event Viewer or in Monitor / Sentinel</li><li><a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/tshoot-connect-pass-through-authentication#collecting-pass-through-authentication-agent-logs">Tracing Logs in the File Systems of the agents</a></li><li>The Synchronization Service Manager at the AADC</li><li>Azure AD Connect Health</li></ul><p>All error messages in these tools should be removed or at least known before(!) the migration.</p><h3>Step 2: Enable PHS</h3><p>The activation of PHS can and should (!) be done <strong>additionally</strong> before the change of the authentication. Especially for larger environments this makes a lot of sense — since according to <a href="https://aka.ms/ADFSTOPHSDPDownload">MS documentation</a> “only” ~20,000 password hashes per hour are synchronized.</p><p>The whole process is described in <a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/plan-migrate-adfs-password-hash-sync#step-1-enable-password-hash-synchronization">this tutorial from Microsoft</a> — but actually only consists of activating the checkbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*AgwbSb624z-rfkRh.png" /></figure><p>The best way to find out if the hashes have been successfully synchronized is:</p><ul><li>Check for error messages (see above). If e.g. permissions are still missing this can be found in the event log of the AADC.</li><li>Use of the <a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/tshoot-connect-password-hash-synchronization">troubleshooting tool</a> in AADC</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6f4YzEnNzhoEZgTTIVAdw.png" /></figure><h3>Step 3: Transition to producion</h3><p>Now that all preparations have been completed, a date for the changeover can be planned. With good planning, the change itself is no longer a major challenge. It is important to know:</p><ul><li>What is the impact of change?</li><li>How does the Change work?</li><li>How do I recognize success?</li><li>How to make a rollback in an emergency?</li></ul><h4>What is the impact of change?</h4><p>Compared to the migration of ADFS, many things remain completely unchanged:</p><ul><li>Domains in AAD stay managed — no conversion needed</li><li>Branding and Seamless SSO is already in place</li><li>Look &amp; Feel for the users</li><li>Password complexity policy is defined for all synced user in Active Directory</li><li>All clients that log on directly to Azure AD and have a Primary Refresh Token or log on from the internal LAN and use Seamless Single-Sign On are completely unaffected by the change.</li></ul><p>Only authentication processes that are forms-based are affected That means the better your SSO works, the less users will notice even if there are problems. However, there should be no downtime as planned!</p><h4>How does the Change work?</h4><p>This is a very simple change in the GUI. If there is a staging server, the change does not need to be made there as well, since AADC makes the change in AAD and each server reads the current configuration there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/0*6QFOpYV3BReLq6zc.png" /></figure><h4>How do I recognize success?</h4><ul><li>The obvious point is that authentication works.</li><li>You should see less entries in the t<a href="https://docs.microsoft.com/en-us/azure/active-directory/hybrid/tshoot-connect-pass-through-authentication#collecting-pass-through-authentication-agent-logs">racing Logs in the File Systems of the agents</a>.</li></ul><h4>How to make a rollback in an emergency?</h4><p>If unexpected things happen and you decide to roll back, you just have to reset the sign-on method in the wizard. As described above, this is a setting in the AAD that is set by the AADC and a swing to the staging server is pointless.</p><p>By changing the authentication method, the PTA Agent on the AADC server was also uninstalled — this will be reinstalled by the rollback.</p><p>However, before you initiate a rollback, you should spend some time troubleshooting — preferably first with the tool integrated in AADC described above. Actually, not much can go wrong and it is probably only a small thing.</p><h3><strong>Step 4: Decommission of the PTA Agents</strong></h3><p>If everything goes well and you feel safe you can simply uninstall the other (both) PTA agents — after 10 days the objects will be deleted in the AAD as well.</p><h3>Conclusion</h3><p>At first glance, the migration seems almost too simple. On closer inspection, however, challenges can arise depending on the size and use of the AD security features. Ideally, this should lead you to rethink your policies and configurations and cut out old habits. Migration is simple, low-risk and worthwhile — so it’s a good idea!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f798b37bb30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My learnings on Microsoft Defender for Endpoint and Exclusions]]></title>
            <link>https://medium.com/codex/my-learnings-on-microsoft-defender-for-endpoint-and-exclusions-ddacf2fdd047?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddacf2fdd047</guid>
            <category><![CDATA[defender]]></category>
            <category><![CDATA[mdes]]></category>
            <category><![CDATA[antivirus]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Wed, 04 Aug 2021 18:59:54 GMT</pubDate>
            <atom:updated>2021-08-07T03:54:04.331Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2t2flsakHH0C5tWB" /><figcaption>Photo by <a href="https://unsplash.com/@ashkfor121?utm_source=medium&amp;utm_medium=referral">Ashkan Forouzani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Whenever I’ve had to deal with AV solutions in recent years, the topic of exclusions has always come up at some point. Usually, it was always quickly agreed that the best way to deal with exclusions is not to use them 😉. Nevertheless, I have only come across a few companies that did not have exclusions and it is always assumed to be a project risk not to migrate them when it comes to switching to a new solution.</p><blockquote>To be clear, my recommendation is to use every opportunity to get rid of (old) exceptions and not migrate anything that has not been proven to cause problems with the new solution.</blockquote><p>However, it is always good to know your enemy and have a plan in case you are forced to use exclusions. So in this blog I will try to show what kinds of exclusions there are, what risks they entail and how to implement them in a practical way.</p><h3>What is an Exclusion and why should I care?</h3><p>Virus scanners such as Microsoft Defender AV (MDAV) have the job of detecting malware and neutralizing it. Due to the spread of Windows, this has been an ongoing issue since the 90s. While in the beginning there was a strong focus on signatures / patterns of known malware, this topic has recently become less and less important, because the viruses have been mutating for some time (like real viruses) and do so much faster than the vendors can update their signatures. Modern solutions such as Microsoft Defender for Endpoint (of which Defender AV is a part) have a wide range of detection methods in addition to signature detection and rely on machine learning and behavior monitoring methods for detection, among other things.</p><p>Malware detection by MDAV can be performed through various mechanisms. In addition to the various scheduled or on-demand scans (Quick, Full, Custom), real-time protection is also active. Real-Time Protection <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/run-scan-microsoft-defender-antivirus?view=o365-worldwide">reviews files when they are opened and closed, and whenever a user navigates to a folder</a>.</p><p>Like any other AV solution, there is of course the possibility to create (classic) exclusions in MDAV for files, folders, processes, and process-opened files. These are stored in the registry on the endpoint and the exclusions from a GPO can be easily displayed via Powershell.</p><p>An exclusion prevents the corresponding files or processes from being detected as malware by Defender during the scan and by Real-Time Protection, and countermeasures (such as a quarantine) from being initiated.</p><h4>Since this behavior is rather bad in the first place, the question arises: Why do exclusions exist at all?</h4><p>Unfortunately, many manufacturers have a list of exclusions that are “<em>necessary</em>” or “<em>recommended</em>” for the software to work. Since every admin can remember a situation where the AV agent was a bit overambitious, this is a very difficult discussion. Here are a few examples of required exclusions: <a href="https://docs.microsoft.com/en-us/troubleshoot/mem/configmgr/recommended-antivirus-exclusions">SCCM</a>, <a href="https://www.veeam.com/kb1999">VEEAM</a>, <a href="https://docs.microsoft.com/en-us/exchange/antispam-and-antimalware/windows-antivirus-software?view=exchserver-2019">Exchange</a>, <a href="https://helpdesk.kaseya.com/hc/en-gb/articles/229014948-Anti-Virus-and-Firewall-Exclusions-and-Trusted-Apps">Kaseya</a>, <a href="https://support.microsoft.com/en-us/topic/how-to-choose-antivirus-software-to-run-on-computers-that-are-running-sql-server-feda079b-3e24-186b-945a-3051f6f3a95b">MS SQL</a> — Microsoft has even a <a href="https://social.technet.microsoft.com/wiki/contents/articles/953.microsoft-anti-virus-exclusion-list.aspx">list of the exclusion lists</a> 😂</p><h4>Okay there seems to be reasons — What specifically is the problem with Exclusions?</h4><p>Every exclusion weakens our defense and every weakness that an attacker knows, can guess or read offers him a good opportunity. For example, if I know that the software distribution paths are excluded on all systems, this is a good place to put the tools for the next steps of my attack and run them from there.</p><blockquote>Our task is to challenge the necessity of any exclusion on any system and thus reduce it.</blockquote><h3>Which types of exclusions are available in Microsoft Defender for Endpoint?</h3><p>Before we start looking at the different types of exclusions, it is important to understand that MDAV is part of Microsoft Defender for Endpoint (MDE) but can also be used on its own. In terms of exclusions, this means that there are methods that are limited to MDAV and methods that cover the entire suite.</p><blockquote>I strongly recommend using MDE, as this massively increases the protection and enables various of the features described here. A virus scanner alone — even if it is very good — is unfortunately no longer sufficient today.</blockquote><h4>Exclusions in Defender Antivirus</h4><p>In MDAV there are the following types of exclusions:</p><ul><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-extension-file-exclusions-microsoft-defender-antivirus?view=o365-worldwide">exclusions based on file name, extension and folder location</a></li><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-process-opened-file-exclusions-microsoft-defender-antivirus?view=o365-worldwide">exclusions for files opened by processes</a></li></ul><p>These exclusions can be managed in several ways. Besides the tools described later, such as Intune, there are the following local options:</p><ul><li>Creation of a local policy</li><li>Using the Windows Security GUI</li><li>Powershell with the CMDlet Add-MpPreference</li></ul><p>The easiest way to display all exclusions is the CMDlet Get-MpPreference (but for reading the exclusions you need to be local admin).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*fy2oHKY7g7rU4XsP3Wt_fw.png" /></figure><p>Since these exclusions are also stored in the registry on the endpoint they also can be displayed by reading the corresponding keys via Powershell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfcPsSDci1AvgN_ZQotGZg.png" /></figure><blockquote>Interestingly, the key in the local hive can no longer be read on a Windows 11 system. I assume this is a hardening measure by Microsoft.</blockquote><p>If you’re using <strong>process exclusions</strong> these points are remarkable in my opinion:</p><ul><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-process-opened-file-exclusions-microsoft-defender-antivirus?view=o365-worldwide#:~:text=When%20you%20add%20a%20process,to%20the%20file%20exclusion%20list">When you add a process to the process exclusion list, Microsoft Defender Antivirus won’t scan files opened by that process, no matter where the files are located. The process itself, however, will be scanned unless it has also been added to the file exclusion list.</a></li><li>The exclusions only apply to <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-real-time-protection-microsoft-defender-antivirus?view=o365-worldwide">always-on real-time protection and monitoring</a>. They don’t apply to scheduled or on-demand scans.</li></ul><h4>Auto Exclusions in Defender Antivirus</h4><p>In addition to the exceptions configured by the admin, Auto Exclusions still come into play for (2016/2019) servers <strong><em>depending on the role of the server </em></strong>if not disabled. For a domain controller, for example, exceptions are active for the NTDS database, the transaction log files, the NTDS working folder and support files.</p><p>Some notes on this (useful feature):</p><ul><li>These exclusions are not displayed in the above lists</li><li>They apply only to Real-Time Protection — not to scheduled or on-demand scans</li><li>The auto exclusion feature works only for the default installation location of the server roles</li><li>more info here:<br><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-server-exclusions-microsoft-defender-antivirus?view=o365-worldwide">Configure Microsoft Defender Antivirus exclusions on Windows Server | Microsoft Docs</a></li></ul><h4>Exclusions in other parts of MDE</h4><p>Besides AV there are several other components that can prevent the execution of files and functions in files. They all have in common that whitelisting by a custom indicator is possible.</p><ul><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/overview-endpoint-detection-response">endpoint detection and response (EDR)</a></li><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/attack-surface-reduction">attack surface reduction (ASR) rules</a> — see t<a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/enable-attack-surface-reduction?view=o365-worldwide#exclude-files-and-folders-from-asr-rules%20https://techcommunity.microsoft.com/t5/microsoft-defender-for-endpoint/demystifying-attack-surface-reduction-rules-part-2/ba-p/1326565">his great blog</a> about ASR.</li><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/controlled-folders">controlled folder access</a></li></ul><h4>Custom indicators</h4><p>Microsoft Defender for Endpoint provides centralized management of <a href="https://www.sans.org/reading-room/whitepapers/forensics/ioc-indicators-compromise-malware-forensics-34200">Indicators of Compromise (IoCs)</a> in the <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/manage-indicators?view=o365-worldwide">Custom Indicators</a> section. IoCs are actually intended to detect known malicious patterns and have them blocked, for example, by security products such as MDE.</p><p>In addition to the Alert and Alert+Block actions, the Custom Indicators section also includes the Allow action, which can be used for whitelisting. The whitelisting of files is not done by a path or filename but by hashes. Besides files it is also possible to create entries for IPs &amp; URLs and certificates.</p><p>The file hashes can be created in MD5, SHA-1 or SHA-256. Although each of these algorithms is significantly more secure than a file or folder name, the SHA-256 hash should be used because <a href="https://www.avira.com/en/blog/md5-the-broken-algorithm">a collision is significantly less likely</a> due to the length of the hash (32 bits). If you use the GUI, you will also get a warning when entering MD5 hashes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*fyQ-ufeEFDZHIC1DnlxQsA.png" /></figure><p>So far, I have not been able to read out the custom indicators that are effective on a system — this then reduces the probability of an intentional collision to almost 0.</p><p>The creation of a Custom Indicator can be done with the <em>Active Remediation Actions permission</em> via the GUI or via <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/post-ti-indicator?view=o365-worldwide">API</a>. By using the API, this process can also be embedded well into a process with e.g. tickets, documentation and releases.</p><h3>What are the best tools to manage exclusions?</h3><p>The selection of the right tool(s) is strongly dependent on the circumstances and has a strategic component. <br>Means: If I have today a tool for the administration of the configurations of my clients I will try on the one hand to administer also the Exclusions with it. On the other hand, I cannot manage all exclusions with all tools (equally well) and this can be the reason for a (perhaps already overdue) change of strategy.</p><ul><li>In the <strong>MDE portal</strong>, only custom indicators, i.e. hashes, can be excluded — and only there. Since the Custom Indicators are the (almost always) preferred whitelisting variant, this portal is set in any case.</li><li><strong>Intune </strong>can set all exclusions except hashes / custom indicators. Unfortunately, <a href="https://microsoftintune.uservoice.com/forums/291681-ideas/suggestions/40594768-merge-windows-defender-antivirus-exclusions-from-m">Intune does not seem to be able to combine lists of exclusions</a>, which can be a challenge in large heterogeneous environments.</li><li><strong>GPOs </strong>can also be used to configure all exclusions except hashes / custom indicators — GPOs can even combine multiple lists here. For clients, however, it should be kept in mind that the distribution of computer policies via VPN is not ideal — but most of those who do this today probably already know that ;-)</li><li>With <strong>SCCM</strong>, the AV exclusions can be managed well. With ASR Exclusions, however, there is currently still the restriction that no wildcards are supported — which severely limits usability.</li><li>Last but not least, all <strong>tools and scripts</strong> that are able to manipulate registry values can also be used to potentially manage everything except custom indicators.</li></ul><h3>What is the best way to deal with exclusions?</h3><p>As you can see, there are several ways to whitelist and block files and this creates some challenges, especially in larger environments. One strategy for dealing with file exclusions might look like this:</p><h4>#1: Avoid exclusions</h4><p>That means we don’t want exclusions. We do not want to migrate new exclusions and we do not want to migrate existing ones. Every exclusion must be well justified.</p><h4>#2: Use Custom Indicators (hashes) whenever possible!</h4><p>As described above, CIs have several advantages:</p><ul><li>They are much safer, as collisions are very unlikely.</li><li>The creation can be easily integrated into processes via runbooks.</li><li>The administration is done in the Security Center, not in Config Management.</li></ul><h4>#3: Use the right (classic) exclusion type and avoid common mistakes</h4><p>If hashes are not possible, proceed in the following order for Classic Exclusions:</p><ul><li>Processes</li><li>(complete) Pathes</li><li>Extensions</li></ul><blockquote>Using this exclusions is something you want to avoid because they can be abused. It is not that hard to guess wich folders are excluded and it is eays to check.</blockquote><p><strong>Before you create an exclusion</strong> you should look at these two sources:</p><ul><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-exclusions-microsoft-defender-antivirus?view=o365-worldwide#recommendations-for-defining-exclusions">Recommendations for defining exclusions</a></li><li><a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/common-exclusion-mistakes-microsoft-defender-antivirus?view=o365-worldwide">Common mistakes to avoid when defining exclusions</a></li></ul><p>In addition to lists of locations that must not be excluded, other typical errors such as the use of filenames without folders in the exclusions or the correct use of environment variables are also covered there.</p><h4>#4: Make yourself familiar with the scoping of exclusions</h4><p>I think Custom Indicators don’t need to be scoped, as the risk is very manageable and the effort is disproportionate. (The way to do this would be Device Groups in MDE).</p><p>With Classic Exclusions it is advisable to differentiate a little and find a good compromise. This looks for servers usually clearly different than for clients, since clients are clearly more homogeneous. While servers often have a handling per server type in the GPO anyway, clients will usually try to have a very uniform policy.</p><p>Depending on the structure, however, it can still make sense to maintain multiple lists and combine them as needed to reduce administration efforts. The practical example would be if only a certain user group uses a certain software and you then use a combination of two lists for these clients (GPOs and SCCM can do this). It is worth to plan a little bit to find a good compromise.</p><h4>#5: Monitor and Review your Exlusions</h4><p>In any environment exclusions accumulate over time and it very important to deal with these two issues:</p><ol><li>How can I prevent and check if there have been (illegitimate) changes to the Exclusions?</li><li>How and when do I check my inventory and how can I reduce it?</li></ol><p>For question number 1 have a look in the Monitoring section below. For Question 2 you will need a process.</p><h3>How do the different mechanisms interact?</h3><h4>What happens if I use more than one configuration method?</h4><p>By default, local changes will be merged with the lists by Group Policy, Configuration Manager, or Intune. The Group Policy lists take precedence when there are conflicts. You can <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-local-policy-overrides-microsoft-defender-antivirus?view=o365-worldwide#merge-lists">configure how locally and globally defined exclusions lists are merged</a> to allow local changes to override managed deployment settings. (<a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-extension-file-exclusions-microsoft-defender-antivirus?view=o365-worldwide">Source</a>)</p><p>I think disabling merging in general is a very useful thing. The corresponding setting can be enabled via <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-local-policy-overrides-microsoft-defender-antivirus?view=o365-worldwide#configure-how-locally-and-globally-defined-threat-remediation-and-exclusions-lists-are-merged">GPO </a>or via the <a href="https://docs.microsoft.com/en-us/windows/client-management/mdm/defender-csp">Defender CSP</a> with a <a href="https://www.jeffgilb.com/custom-microsoft-intune-oma-uri-policy-ins-and-outs/">custom policy</a> in Intune. The <a href="https://admx.help/?Category=Windows_10_2016&amp;Policy=Microsoft.Policies.WindowsDefender::DisableLocalAdminMerge">RegKey </a>that is set in this way now ensures that locally added exclusions are overwritten.</p><h4>What happens at a conflict?</h4><p>The <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/indicator-file?view=o365-worldwide#policy-conflict-handling">MS documentation</a> answers this question so:</p><p><em>Cert and File IoC policy handling conflict will follow the below order:</em></p><p><em>If the file is not allowed by Windows Defender Application Control and AppLocker enforce mode policy/policies, then </em><strong><em>Block<br></em></strong><em>Else if the file is allowed by the Microsoft Defender Antivirus exclusion, then </em><strong><em>Allow<br></em></strong><em>Else if the file is blocked or warned by a block or warn file IoC, then </em><strong><em>Block/Warn<br></em></strong><em>Else if the file is allowed by an allow file IoC policy, then </em><strong><em>Allow<br></em></strong><em>Else if the file is blocked by ASR rules, CFA, AV, SmartScreen, then </em><strong><em>Block<br></em></strong><em>Else </em><strong><em>Allow</em></strong><em> (passes Windows Defender Application Control &amp; AppLocker policy, no IoC rules apply to it)</em></p><p>To simplify this, my friend <a href="https://twitter.com/fabian_bader?s=20">Fabian</a> has created this wonderful meme! 😍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*tyYqT0hgiilZJ7ZjKoWE7Q.png" /></figure><h3>How can I prevent and check if there have been (illegitimate) changes to the Exclusions?</h3><h4>General Manipulation Prevention</h4><p>Before we look at the AV exclusion use case, I recommend everyone check out <a href="https://m365internals.com/2021/07/05/why-are-windows-defender-av-logs-so-important-and-how-to-monitor-them-with-azure-sentinel/">this blog</a> to learn what can be manipulated in general in Defender AV and how to best deal with it. It is reasonable to try to prevent manipulation of the configuration and although Tamper Protection has no influence on AV Exclusions, its use is very useful as it can prevent many basic manipulations of the Defender.</p><p>Finally, <a href="https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/configure-local-policy-overrides-microsoft-defender-antivirus?view=o365-worldwide#configure-how-locally-and-globally-defined-threat-remediation-and-exclusions-lists-are-merged">Configure Local overrides for Microsoft Defender AV settings</a> can be used to prevent local exclusions from being generated by simply disabling the merging of the lists. This means that only the exclusions from the GPOs apply.</p><h4>Detect and prevent local exclusions</h4><p>The behavior described above for combining exclusion lists is very useful for scoping. However, this behavior can also be used by an attacker. By default it is possible to create own local exclusions with local administration rights and in my experience there are also some accounts in many companies that have e.g. the rights to edit a GPO that affects the clients. Reason enough to have a look how we can be informed about changes.</p><p>The first approach is to look at the MDE client via a custom detection. Alex <a href="https://gist.github.com/alexverboon/f2f52279a8a38583bca0589fdf88f9d9">Verboon has already published something good </a>about this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABBcb_WLsMkJNh0ow7EPpw.png" /></figure><p>Thus, according to my tests, the following scenarios can be identified:</p><ul><li>Creation of a local policy</li><li>Using the Windows Security GUI</li><li>Powershell with the CMDlet Add-MpPreference</li></ul><p>However, besides the methods provided for this purpose, I can also try to put my exclusions <strong>directly into the registry as keys</strong>:</p><p>Theoretically this can be done in several ways with different permissions (Administrator or SYSTEM) in the hives <em>HKLM\Software\Microsoft\Windows Defender\…</em> and <em>HKLM\Software\Policies\Microsoft\Windows Defender\…</em></p><p>In my tests I was not able to change keys in the non-policy path either as admin or as SYSTEM although SYSTEM is owner of the hive. The reason for this I suspect is that Defender AV prevents changes to this part of the registry by a kernel-mode driver.</p><p>In the hive under Policies it is possible to create further exclusions as a local admin which (after some time or a gpupdate) will be applied. Unfortunately, no logs are generated for any changes made this way or by GPO.</p><blockquote>This works (after a reboot) even on a non domain-joined Windows 10 device if you create the hive under policy and add the keys. This is a really serious problem from my point of view and should be fixed by MS. If you are interested in how exactly this vulnerability can be used check out <a href="https://cloudbrothers.info//en/create-persistent-defender-av-exclusions-circumvent-defender-endpoint-detection/">this (awesome) blog by Fabian Bader</a>!</blockquote><h4>Detect and prevent exclusions from configuration systems</h4><p>Since there are many ways to configure as described above, this is not a complete list but I limit myself to the tools that are accessible to me.</p><p><strong><em>Add Custom Indicators in MDE</em></strong></p><p>As described above you need the <em>Active Remediation Actions permission </em>to manipulate the CIs. Each CI is directly recognizable when and by whom it was created.</p><p>Unfortunately, there are no events for the creation of CIs in the audit log yet, but since there are already filters for them, I am optimistic that it will soon be possible to specifically search for or alert on them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*ZzvWz6uxyKI6fJYGyTSnJg.png" /></figure><p><strong><em>Add Exclusions in Intune</em></strong></p><p>Of course, it is also possible to add further Exclusions with Intune. These can be created by (at least) the following roles:</p><ul><li><strong>In Intune:</strong> <em>Endpoint Security Manager and Custom Roles</em></li><li><strong>In AAD:</strong> <em>Global Admin, Intune Admin, Security Admin</em></li></ul><p>These changes are included in the Intune Audit Log and can be <a href="https://github.com/crmhh/stuff/blob/main/NewMDAVExclusionbyInune.kql">queried</a> alerted accordingly if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xv6N8yPH4rQtGRymloNlHg.png" /></figure><p><strong><em>Add Exclusions via GPO</em></strong></p><p>Finally, there is the possibility to add exclusions via GPO. By the above described behavior for merging the lists it is possible to add additional exclusions with each existing or new GPO that acts on the system.</p><p>Unfortunately, neither the modification of the GPOs nor the configured systems have an event that indicates that an exclusion has been added. You will only see that a GPO has been modified or applied. To determine this change, only a regular export and comparison would help at the moment.</p><p>To go into a little more detail, a look at Advanced Hunting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCDTbq6R10aNMb7caxausQ.png" /></figure><p>There are some entries in the DeviceRegistry events table from the <em>HKLM\Software\Policies\Microsoft\</em> policy hive that even contain changes to the <em>Windows Defender</em> keys, but nothing from the exclusions hive.</p><h3>Conclusion</h3><p>In this blog I have tried to summarize my learnings around the topic of Exclusions in Defender for Endpoint. We first looked at what types of exclusions there are and how they can be managed, including a strategy of which ones to use. Then we dived a bit deeper into the mechanics of exclusions and what happens when conflicts occur and what scoping options are available. The last part then dealt with the risks, hardening and monitoring.</p><p>I am afraid that this topic will continue to be relevant and hope that I have overlooked something, especially in the areas of hardening and monitoring. It is quite obvious that an attacker with admin rights can only be stopped with difficulty, but the fact that he can create exclusions unseen and thus create a space in which he can reload all the necessary tools makes the situation even more difficult.</p><p>For me, the critical part was formulating a realistic strategy for dealing with exclusions:</p><blockquote>#1: Avoid exclusions</blockquote><blockquote>#2: Use Custom Indicators (hashes) whenever possible!</blockquote><blockquote>#3: Use the right (classic) exclusion type and avoid common mistakes</blockquote><blockquote>#4: Make yourself familiar with the scoping of exclusions</blockquote><blockquote>#5: Monitor and Review your Exlusions</blockquote><p>What’s your strategy for dealing with exlusions? Contact me: <a href="https://twitter.com/cbrhh">https://twitter.com/cbrhh</a></p><h3>Acknowledgements</h3><p>Thanks to <a href="https://twitter.com/fabian_bader?s=20">Fabian Bader</a> and <a href="https://twitter.com/nadineausRT?s=20">Nadine Kern</a> for reviewing and checking all that stuff. 💖 And don’t forget to read <a href="https://cloudbrothers.info/">Fabians Blog</a> !</p><h4>More Sources:</h4><ul><li><a href="https://yongrhee.wordpress.com/2020/07/29/how-to-take-care-of-false-positives-fps-with-mdatp-microsoft-defender-antivirus-system-center-endpoint-protection/">How to take care of false positives (FP&amp;rsquo;s) with MDATP, Microsoft Defender Antivirus, System Center Endpoint Protection&amp;hellip;</a></li><li><a href="https://www.linkedin.com/pulse/microsoft-defender-atp-indicators-compromise-ioc-ahmed/">Microsoft Defender ATP Indicators of Compromise IoC explained</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddacf2fdd047" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/my-learnings-on-microsoft-defender-for-endpoint-and-exclusions-ddacf2fdd047">My learnings on Microsoft Defender for Endpoint and Exclusions</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Outbound AAD B2B Discovery]]></title>
            <link>https://chris-brumm.medium.com/outbound-aad-b2b-discovery-788b471ba677?source=rss-a236d29b3f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/788b471ba677</guid>
            <category><![CDATA[b2b]]></category>
            <category><![CDATA[azure-active-directory]]></category>
            <dc:creator><![CDATA[Christopher Brumm]]></dc:creator>
            <pubDate>Fri, 18 Jun 2021 12:28:28 GMT</pubDate>
            <atom:updated>2021-06-18T12:28:28.883Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last few months I was asked again and again in which other tenants users from a customer environment are active and unfortunately I had very few suggestions to find out. This time, however, it was about a tenant move and I had to deal with the topic a bit more intensively. In advance: My solution is not perfect but you can work with it ;-)</p><h3>What is AAD B2B and why should I use it?</h3><p>Before we get into the specific problem and its solution, I would like to give a short intro to B2B — imho one of the most powerful features of AAD. It enables collaboration across company boundaries and allows external access to apps connected in my tenant. Guests are usually invited by users or administrators and have their own lifecycle to manage.</p><p>A guest account can be thought of as a kind of shortcut to the real account in your home tenant. It can be interacted with (e.g. in Teams Channels), it can be assigned permissions and licenses in my tenant. However, the primary authentication of the account is always done in its home tenant.</p><p>From the perspective of an Azure AD administrator, there are two scenarios: Inbound and Outbound B2B!</p><blockquote>Inbound B2B means that there are guests / externals in my tenant working on my resources.</blockquote><p>For guests in my tenant, I have good options for control:</p><p>With the <strong>External Collaboration</strong> Settings I can control which rights a guest has in my directory and who can invite a guest. In special scenarios, I can also control from which DNS domains guests can be invited.</p><blockquote><strong>My recommendation</strong> for this is to keep the rights of a guest as low as possible on the one hand (Why? <a href="https://o365blog.com/post/quest_for_guest/">see here</a>) and on the other hand to make the process of inviting a guest as low-threshold as possible.</blockquote><p>In <strong>Conditional Access</strong> <em>all guests</em> can be selected as user type. So it is possible to exclude <em>all guests</em> from certain policies and to create policies for guests only. In combination with dynamic groups it is even possible to create policies for guests from certain domains or with static groups to create policies for especially privileged guests.</p><blockquote><strong>My recommendation</strong> is to create a separate set of rules in Conditional Access for guests in which at least MFA and, depending on the requirement, Terms of Use and Conditional Access App Control — and thus the use of the browser — are enforced.</blockquote><p>Finally, with <strong>Access Reviews</strong> it is possible to manage the inventory of guests and get rid of orphaned guests. While it is possible to create an <a href="https://techcommunity.microsoft.com/t5/azure-active-directory-identity/access-reviews-for-guests-in-all-teams-and-microsoft-365-groups/ba-p/1994697">Access Review for all guests in teams</a>, the feature is primarily designed with a focus on controlling access to resources (such as teams, groups, sites). Following this approach, <strong>Access Packages</strong> can be used directly to control not only a review but the complete control of permissions to these resources.</p><blockquote><strong>My recommendation</strong> is to engage with this topic early on, because experience shows that otherwise the number of guests and permissions will continue to grow and at some point it will be almost impossible to keep track of / control. There are for teams, for example, <a href="https://blog.thinformatics.com/2020/09/another-microsoft-teams-governance-approach-using-aad-identity-governance/">super concepts including automation from my friend Jakob</a>.</blockquote><blockquote>Outbound B2B means that users from my tenant work on resources in other tenants and are guests there.</blockquote><p>Unfortunately, it is not yet possible to detect in which remote tenant a user is a guest and it is not possible to control whether and in which tenants a user can be a guest. Additionally, all the control options described above are not applicable in this scenario.</p><blockquote>The only — but somewhat outdated — approach to control is currently the AAD feature <a href="https://identitypro.blog/master-the-azure-ad-tenant-restrictions-feature/">Tenant Restrictions</a>, which requires a proxy server to set a header listing the allowed tenants.</blockquote><blockquote>Why do you want to know / control outbound B2B anyway?</blockquote><p>Personally, I don’t think it’s a good idea to restrict outbound B2B, as that will only lead to more accounts and more shadow IT (but I’m sure there are other opinions 😉 )</p><p>However, there is a scenario in which one would like to know quite urgently in which other tenants the users are on the move: When moving the domains / users in another tenant.</p><blockquote>After a cross-tenant migration, a guest must be re-invited because the relationship has become broken.</blockquote><p>To prepare such a migration, my goal is to find the top scorers to inform the users and contact the ITs of the other tenants so that the guests can be re-invited on the day of the migration.</p><p>It is important at this point not to simply delete the guests and re-invite them, but to reset the guest so that the data and permissions attached to the guest are retained. For resetting the guest’s invitation, the remote tenant administrator has the options GUI or API (e.g. <a href="https://docs.microsoft.com/en-us/azure/active-directory/external-identities/reset-redemption-status">via Powershell</a>).</p><p>To find an reset all guests from a specific domain you can extend <a href="https://github.com/crmhh/stuff/blob/main/reset-guests.ps1">my simple script</a> for this.</p><h3>Evaluation of the sign-in logs</h3><p>To find out where my users are I started to look at the sign-in logs and was very happy about the new fields <strong><em>HomeTenantID </em></strong>and <strong><em>RessourceTenantId</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GotqPNY7xEt_hAav47RPzA.png" /></figure><p>In order to be able to evaluate the logs in your own tenant well (and for various other reasons), the AAD logs should be <a href="https://docs.microsoft.com/en-us/azure/active-directory/reports-monitoring/concept-activity-logs-azure-monitor">sent to a log analytics workspace</a> / Azure Monitor.</p><p>There, the sign-in logs (<a href="https://docs.microsoft.com/en-us/azure/active-directory/reports-monitoring/reference-azure-monitor-sign-ins-log-schema">schema</a>) can then be evaluated quite easily with KQL (<a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/concepts/">Getting started</a> → <a href="https://t.co/esDVonbFkG?amp=1">Getting Master</a>):</p><pre>SigninLogs<br>| where ResourceTenantId != HomeTenantId<br>| distinct UserPrincipalName, ResourceTenantId</pre><h4>Tenant Names and IDs</h4><p>The result of my query is then a lot of Tenant IDs. Each tenant / each Azure Active Directory has a tenant ID and it is globally unique. For the own tenant there are several possibilities to determine this easily — for example on the start page of the AAD or via <a href="https://docs.microsoft.com/en-us/powershell/module/servicemanagement/azurerm.profile/get-azurermtenant?view=azuresmps-4.0.0#example-1--getting-all-tenants">Powershell</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CDFITx5YYUojRqAYkX81g.png" /></figure><p>For foreign tenants a little more effort is required, but for a given domain at least these methods can be used to determine the appropriate tenant ID:</p><ul><li>via the <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc">OpenId config Endpoint</a> e.g. with Postman</li><li>via the <a href="https://o365blog.com/aadinternals/">AAD Internals</a></li><li>via the blade <a href="https://docs.microsoft.com/en-us/azure/active-directory/governance/entitlement-management-organization#add-a-connected-organization">Connected Organisations</a> in Azure AD</li></ul><p>Unfortunately, however, there is no way (for privacy reasons, it seems) to perform this resolution backwards.</p><h4>How can I do this for third-party tenants?</h4><p>As I wrote in the introduction, my trigger was a review of a tenant that was to be replaced. This was a so-called unmanaged tenant not created by IT but by the users themselves. This can happen in the following situations:</p><ul><li>Test licenses</li><li>Invitation to another tenant (or sharing)</li></ul><p>In such a tenant, it is often not a given that AAD is integrated with a log analytics workspace and, depending on the planned approach, it may not be done anymore.</p><p>In this scenario, it is possible and useful to fall back on another more manual procedure.</p><ol><li>Export of data via GUI as JSON</li><li>Import into Azure Data Explorer</li><li>Evaluation via KQL</li></ol><p>This was my first time working with Azure Data Explorer and I was very pleased with how easy an initial deployment was. Here is a guide on how to create it:</p><p><a href="https://docs.microsoft.com/en-us/azure/data-explorer/create-cluster-database-portal">Quickstart: Create an Azure Data Explorer cluster &amp; DB</a></p><p>In the portal, the data can then be easily imported as JSON and start directly with the queries. I found it a bit hard to get used to the fact that the first letter of all field names after the import is always Lower Case.</p><blockquote>I learned that it is really a good idea to start the ADX cluster only on demand 😂</blockquote><h3>Deeplinks and Tenant Branding</h3><p>With a long list of tenant IDs I started asking around if anyone had any ideas how to find out which tenants are behind them. Fortunately, <a href="https://twitter.com/joslieben?s=20">Jos Lieben</a> got in touch relatively quickly on Twitter and recommended a Powershell snippet by <a href="https://twitter.com/jseerden?s=20">John Seerden</a>. He showed me that it is possible to call the deep link to the login page of a tenant with the tenant id. It looks like this:</p><pre>https://login.microsoftonline.com/<strong><em>resourceTenantId</em></strong>/oauth2/authorize?client_id=12345</pre><p>My query (Azure Data Explorer variant with lower case) now returns a descending list of tenant IDs sorted by number of users, including deep links to the tenants:</p><pre>XXSignIns<br>| where resourceTenantId != homeTenantId<br>| distinct userPrincipalName, resourceTenantId<br>| summarize count() by resourceTenantId<br>| extend link = strcat(&quot;https://login.microsoftonline.com/&quot;, resourceTenantId, &quot;/oauth2/authorize?client_id=12345&quot;)<br>| order by count_ desc<br>| project-reorder count_, resourceTenantId, link</pre><p>This creates a table from which you can easily copy the link into an incognito session of the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*3gzxrbIJySXnDCS4yInxlQ.png" /></figure><p>The branding of the tenants can then be very revealing and has solved the problem for me 😎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*YK-iswKWGTm0dZK8y9z2hg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=788b471ba677" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>