﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel><title>Steve on Security</title>
<description>Theoretical Headbanging</description>
<generator>blog</generator>
<link>https://syfuhs.net/</link>
<item>
  <title>Deprecating NTLM is Easy and Other Lies We Tell Ourselves</title>
  <link>https://syfuhs.net/deprecating-ntlm-is-easy-and-other-lies-we-tell-ourselves</link>
  <description>&lt;p&gt;Edit 3: We have a video!&lt;/p&gt;
&lt;p&gt;&lt;div class="video"&gt;&lt;iframe width="560" height="315" title="YouTube embed" src="about:blank" data-src="https://www.youtube-nocookie.com/embed/zlhoAYsSd4c?modestbranding=1&amp;amp;hd=1&amp;amp;rel=0&amp;amp;theme=light" allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;
&lt;p&gt;Edit: Oh hey, &lt;a title="Goodbye NTLM" href="https://aka.ms/ntlm"&gt;we announced our strategy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We've been hinting at the deprecation and removal of NTLM from Windows for a while now. We're finally talking about how we're doing it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bluehat Podcast (not the presentation):&amp;nbsp;&lt;/strong&gt;&lt;a href="https://podcasts.apple.com/us/podcast/deprecating-ntlm-is-easy-and-other-lies-we-tell/id1688087915?i=1000633321530"&gt;The BlueHat Podcast: Deprecating NTLM is Easy and Other Lies We Tell Ourselves with Steve Syfuhs on Apple Podcasts&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Webinar Recording (not Bluehat):&amp;nbsp;&lt;/strong&gt;&lt;a href="https://www.youtube.com/watch?v=SEtARCtGP0Y"&gt;The Evolution of Windows Authentication - YouTube&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What:&lt;/strong&gt; I'm giving a presentation&lt;br /&gt;&lt;strong&gt;When:&lt;/strong&gt; October 12th&lt;br /&gt;&lt;strong&gt;Where:&lt;/strong&gt; Microsoft Bluehat Conference&lt;br /&gt;&lt;strong&gt;Streamed:&lt;/strong&gt; Good question&lt;br /&gt;&lt;strong&gt;Recorded:&lt;/strong&gt; Yes [links TBD]&lt;/p&gt;
&lt;p&gt;More details to follow. &lt;a href="https://www.microsoft.com/bluehat/"&gt;BlueHat | Microsoft&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net/images/2023/10/bh.jpg" alt="Bluehat Presentation" width="889" height="500" /&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Featured</category>
  <category>Windows</category>
  <category>Authentication</category>
  <category>NTLM</category>
  <guid isPermaLink="false">https://syfuhs.net/deprecating-ntlm-is-easy-and-other-lies-we-tell-ourselves</guid>
  <pubDate>Wed, 04 Oct 2023 18:46:00 GMT</pubDate>
</item>
<item>
  <title>Finding and Killing the Process that Opened Your Port</title>
  <link>https://syfuhs.net/finding-and-killing-the-process-that-opened-a-port</link>
  <description>&lt;p&gt;Saved for when Future Steve goes searching for examples on how to do this again.&lt;/p&gt;
&lt;p&gt;I had a project that required acting as a server by opening a socket on a particular port and then listen for incoming connections. Not that particularly interesting. However, the process of building it was kind of a pain because the program would periodically linger in the background holding the socket open and launching a new instance would fail because hey look someone already has that socket open.&lt;/p&gt;
&lt;p&gt;In order to optimize my laziness and reduce my overall frustration I opted to have the new instance find and kill the old instance. It's a dev server, what do I care? Anyway.&lt;/p&gt;
&lt;p&gt;There are tools that show you which processes own which ports. There are tools that kill processes. There aren't really tools that show you port owners and then let you kill them. Certainly not in any easy to use way. On top of that, all the examples online just show you how to marry the two, usually by grepping your way through a whole bunch of string dumps, and well, nah.&lt;/p&gt;
&lt;p&gt;Just query the damn socket table:&lt;/p&gt;
&lt;p&gt;&lt;script src="https://gist.github.com/SteveSyfuhs/60d132f3e030c000f2ebdaef61965c35.js"&gt;&lt;/script&gt;&lt;/p&gt;
&lt;p&gt;
&lt;script src="https://gist.github.com/SteveSyfuhs/60d132f3e030c000f2ebdaef61965c35.js"&gt;&lt;/script&gt;
&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>.NET</category>
  <category>Development</category>
  <guid isPermaLink="false">https://syfuhs.net/finding-and-killing-the-process-that-opened-a-port</guid>
  <pubDate>Fri, 04 Aug 2023 02:57:00 GMT</pubDate>
</item>
<item>
  <title>Improvements in Windows Kerberos Architecture</title>
  <link>https://syfuhs.net/improvements-in-windows-kerberos-architecture</link>
  <description>&lt;p&gt;It's Friday afternoon, it's sunny out, and I have no desire to start on any new projects this late in the week.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let's discuss architectural changes to Kerberos cryptography in Windows!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Why do you care? You don't.&lt;br /&gt;Will this practically affect you? No, it won't.&lt;br /&gt;Is it interesting? Well, I think it is.&lt;/p&gt;
&lt;p&gt;Anyway...&lt;/p&gt;
&lt;p&gt;Many many moons ago Kerberos in Windows supported only RC4 and DES algorithms for the various encryption and signing requirements.&lt;/p&gt;
&lt;p&gt;Because of this there was a useful dichotomy of things. Code was easy enough. Was it doing RC4? Yes, carry on. No? do DES.&lt;/p&gt;
&lt;p&gt;This meant you could reason about all the different facilities of Kerberos fairly easily because whatever you were doing only needed to know two states.&lt;/p&gt;
&lt;p&gt;This actually worked relatively well for a while because technically you could bolt on 3rd party encryption algorithms, and they'd more or less just work as long as they followed either the DES way or the RC4 way.&lt;/p&gt;
&lt;p&gt;This was manifested through the CDLocateCSystem and family of cryptdll.dll library functions.&lt;/p&gt;
&lt;p&gt;These are undocumented functions, and they certainly were never intended for 3rd parties to use.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Nevertheless.&lt;/p&gt;
&lt;p&gt;This all came about in the late 90's for the release of Windows 2000 and went along without issue until Vista/Server 2008 because: AES.&lt;/p&gt;
&lt;p&gt;AES was an important milestone because it was and still is a solid crypto suite.&lt;/p&gt;
&lt;p&gt;Bringing AES into the picture wasn't that difficult at a low level. There's that cryptdll.dll thing and it exports all the usual functions you'd expect like "please gimme all the crypto suites you support" and "I've chosen AES, please give me the encryptor for that".&lt;/p&gt;
&lt;p&gt;On top of that, AES also met the standard that it more or less behaved like RC4 or DES, so it fell into the do-as-DES-does flow of logic.&lt;/p&gt;
&lt;p&gt;Beautiful. Life is good.&lt;/p&gt;
&lt;p&gt;Ah, but DES is shit. We also need to kill DES quickly and quietly.&lt;/p&gt;
&lt;p&gt;Okay, find and replace "DES" with "AES" and life is good, right?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Nah, we also need to continue supporting DES for those ERP systems that only support DES, but never willingly choose DES normally.&lt;/p&gt;
&lt;p&gt;Okay, so do AES or RC4, or DES if DESONLY, and if AES follow the DES logic for etype-info and salts and such.&lt;/p&gt;
&lt;p&gt;Oh, also AES can only be used on Server 2008 DFL because reasons.&lt;/p&gt;
&lt;p&gt;Uhhhhhhhhhhh. K.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And so, this monstruous pattern was born (paraphrased, not real source code).&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2023%2F4%2Faaa.png" alt="" width="962" height="140" /&gt;&lt;/p&gt;
&lt;p&gt;That's ehh not great. Doubly so when it's duplicated in subtly different ways a few dozen times throughout the code.&lt;/p&gt;
&lt;p&gt;It's ugly, but manageable enough so long as you don't have to futz with the logic, and it has worked just fine for 20 years.&lt;/p&gt;
&lt;p&gt;Okay, but what happens if you need to kill off another cipher suite because, say, a researcher finds a flaw in how checksumming is handled. 😶😬&lt;/p&gt;
&lt;p&gt;Welp.&lt;/p&gt;
&lt;p&gt;We *could* just add in checks everywhere for DES... and RC4. It's clunky, but it's not the end of the world.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We could just remove RC4 from the cryptdll implementation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yeah nah, that is the end of the world.&lt;/p&gt;
&lt;p&gt;Let's look at the cards dealt to us.&lt;/p&gt;
&lt;p&gt;DES -- dead, removed in future version.&lt;br /&gt;RC4 -- dying, removed in future version.&lt;br /&gt;AES-SHA1 -- alive, bit ornery, not going anywhere.&lt;/p&gt;
&lt;p&gt;That's actually not a great hand. We need to get better cards at some point. We have options, which in the simplest terms is RFC 8009 -- AES-SHA2.&lt;/p&gt;
&lt;p&gt;But how do we add that? More important how do we add that AND also remove RC4?&lt;/p&gt;
&lt;p&gt;That's right kids! We rewrite the entire crypto stack in Kerberos!&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2023%2F4%2Fbbbb.jpg" alt="" width="494" height="372" /&gt;&lt;/p&gt;
&lt;p&gt;Hey look at that.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2023%2F4%2Fcccc.png" alt="" width="405" height="509" /&gt;&lt;/p&gt;
&lt;p&gt;The value here is significant because we can (and did) rewrite all the monstrous logic spread throughout the codebase into logic that never has to be touched ever again.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2023%2F4%2Fddd.png" alt="" width="943" height="188" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2023%2F4%2Feee.png" alt="" width="959" height="131" /&gt;&lt;/p&gt;
&lt;p&gt;This means all the logic to disable a cipher outright like DES, or disable certain usages of the cipher, like RC4 session keys, is hidden from the rest of the stack.&lt;/p&gt;
&lt;p&gt;On top of that, adding a *new* cipher suite is relatively trivial because only one spot in the code needs to know.&lt;/p&gt;
&lt;p&gt;And most importantly I get to delete functions like this.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2023%2F4%2Fffff.png" alt="" width="388" height="102" /&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Kerberos</category>
  <category>Windows</category>
  <category>Authentication</category>
  <guid isPermaLink="false">https://syfuhs.net/improvements-in-windows-kerberos-architecture</guid>
  <pubDate>Fri, 14 Apr 2023 21:39:00 GMT</pubDate>
</item>
<item>
  <title>Kerberos Event ID 27</title>
  <link>https://syfuhs.net/kerberos-event-id-27</link>
  <description>&lt;div class="css-1dbjc4n"&gt;
&lt;div class="css-1dbjc4n r-1s2bzr4"&gt;
&lt;p class="css-901oao r-vlxjld r-37j5jr r-1blvdjr r-16dba41 r-vrz42v r-bcqeeo r-bnwqim r-qvutc0" dir="auto" lang="en" data-testid="tweetText"&gt;&lt;span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"&gt;&lt;strong&gt;Update Dec 2: &lt;/strong&gt;If you're finding this post as a result of the November 2022 Windows patch, I recommend you review &lt;a href="https://support.microsoft.com/en-us/topic/kb5021131-how-to-manage-the-kerberos-protocol-changes-related-to-cve-2022-37966-fd837ac3-cdec-4e76-a6ec-86e67501407d"&gt;KB5021131: How to manage the Kerberos protocol changes related to CVE-2022-37966 - Microsoft Support&lt;/a&gt; if you haven't already. Pay special attention to this registry key:&lt;/span&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class="ocpExpandoHeadTitleContainer"&gt;&lt;strong class="ocpLegacyBold"&gt;DefaultDomainSupportedEncTypes&lt;/strong&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div class="ocpebw"&gt;
&lt;blockquote&gt;
&lt;div class="ocpExpandoBody"&gt;
&lt;p&gt;Configurable value to state what the default Supported Encryption Type for an Active Directory user or computer if their&amp;nbsp;&lt;strong class="ocpLegacyBold"&gt;ms-DS-SupportedEncryptionType&lt;/strong&gt;&amp;nbsp;attributes is not set.&lt;/p&gt;
&lt;table class="banded"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;&lt;strong class="ocpLegacyBold"&gt;Registry key&lt;/strong&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;HKEY_LOCAL_MACHINE\System\CurrentControlSet\services\KDC&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;&lt;strong class="ocpLegacyBold"&gt;Value&lt;/strong&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;DefaultDomainSupportedEncTypes&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;&lt;strong class="ocpLegacyBold"&gt;Data type&lt;/strong&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;REG_DWORD&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;&lt;strong class="ocpLegacyBold"&gt;Default value&lt;/strong&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;0x27&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;&lt;strong class="ocpLegacyBold"&gt;Restart&amp;nbsp;required?&lt;/strong&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p&gt;No&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;p class="css-901oao r-vlxjld r-37j5jr r-1blvdjr r-16dba41 r-vrz42v r-bcqeeo r-bnwqim r-qvutc0" dir="auto" lang="en" data-testid="tweetText"&gt;&lt;span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"&gt;You can try setting this to &lt;code&gt;0x1C&lt;/code&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p class="css-901oao r-vlxjld r-37j5jr r-1blvdjr r-16dba41 r-vrz42v r-bcqeeo r-bnwqim r-qvutc0" dir="auto" lang="en" data-testid="tweetText"&gt;&lt;span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"&gt;--&lt;/span&gt;&lt;/p&gt;
&lt;p id="id__xv5a8yt6n8h" class="css-901oao r-vlxjld r-37j5jr r-1blvdjr r-16dba41 r-vrz42v r-bcqeeo r-bnwqim r-qvutc0" dir="auto" lang="en" data-testid="tweetText"&gt;&lt;span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"&gt;There's been a bunch of questions from folks about Event 27 after the 11B changes. The presence of this event is not an indicator of another bug. It is the result of a fix to one of the vulnerabilities in 11B. Let's decode what this is saying.&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The event log text:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;While processing a TGS request for the target server class/service.domain.com, the account abc@DOMAIN.COM did not have a suitable key for generating a Kerberos ticket (the missing key has an ID of 9).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The requested etypes were 23 &amp;nbsp;3 &amp;nbsp;1.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The accounts available etypes were 23 &amp;nbsp;18 &amp;nbsp;17.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;TGS-REQ: hopefully obvious by now -- you've authenticated already. You've exchanged your password or whatever for a TGT. TGT is good.&lt;/p&gt;
&lt;p&gt;You're requesting a ticket to an SPN class/service.domain.com.&lt;/p&gt;
&lt;p&gt;Key ID = 9: poorly labelled -- means the action the key is needed for. It's an internal mapping for us for debugging because from a customer diagnostics perspective it's all the same.&lt;/p&gt;
&lt;p&gt;9 is service ticket encryption. That means the KDC could not find a key to encrypt the ticket.&lt;/p&gt;
&lt;p&gt;Okay, why can't it find a key? How does it decide which key to pick?&lt;/p&gt;
&lt;p&gt;It finds the intersection of 3 sets:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Requested ETypes&lt;br /&gt;Account keys&lt;br /&gt;KDC supported ETypes&lt;/p&gt;
&lt;p&gt;Two of those sets are listed in the event.&lt;/p&gt;
&lt;p&gt;Requested ETypes is literally the requested ETypes in the Kerberos TGS request body. "As a client, I only support XYZ ETypes".&lt;/p&gt;
&lt;p&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net/images/2022%2F11%2FFiRd_DLagAE99P_.png" alt="TGS-REQ Requested ETypes" width="512" height="328" /&gt;&lt;/p&gt;
&lt;p&gt;Account keys are the actual keys stored in the database.&lt;/p&gt;
&lt;p&gt;KDC supported ETypes is what's recorded in the registry as... supported.&lt;/p&gt;
&lt;p&gt;Let's do some math.&lt;/p&gt;
&lt;p&gt;1=DES1&lt;br /&gt;3=DES2&lt;br /&gt;17=AES128&lt;br /&gt;18=AES256&lt;br /&gt;23=RC4&lt;/p&gt;
&lt;p&gt;23, 3, 1 &amp;cap; 23, 18, 17 = 23&lt;/p&gt;
&lt;p&gt;Okay, only one common key, and that is...RC4. Yeeeugh.&lt;/p&gt;
&lt;p&gt;But that should work, shouldn't it? RC4 is terrible, but selected EType is selected EType.&lt;/p&gt;
&lt;p&gt;Except we're missing an intersection against KDC supported etypes. That's this policy applied to the DC. Default is 0, which means pick whatever Windows thinks is best. Most people pick AES and/or Future encryption types.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net/images/2022%2F11%2FFiRbwLbagAAM402.png" alt="Allowed Encryption Types" width="417" height="507" /&gt;&lt;/p&gt;
&lt;p&gt;The policy most folks choose is AES/Future. It's good and safe. That means we're working with a written value of 0x7FFFFFF8. Let's decode that. Remember start at the right.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;0x7FFFFFF8 =&amp;gt; 0111 1111 1111 1111 1111 1111 1111 1000&lt;/code&gt;&lt;br /&gt;&lt;code&gt;DES1 -----------------------------------------------^&lt;/code&gt;&lt;br /&gt;&lt;code&gt;DES2 ----------------------------------------------^&lt;/code&gt;&lt;br /&gt;&lt;code&gt;RC4 ----------------------------------------------^&lt;/code&gt;&lt;br /&gt;&lt;code&gt;AES128 ------------------------------------------^&lt;/code&gt;&lt;br /&gt;&lt;code&gt;AES256 ----------------------------------------^&lt;/code&gt;&lt;br /&gt;&lt;code&gt;AES-SK ---------------------------------------^&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Okay, back to math.&lt;/p&gt;
&lt;p&gt;23, 3, 1 &amp;cap; 23, 18, 17 = 23&lt;br /&gt;23 &amp;cap; 18, 17 = null&lt;/p&gt;
&lt;p&gt;Bang. Oops.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Time to write the event.&lt;/p&gt;
&lt;p&gt;Okay, well there's clearly a fault here. Why is the request only asking for RC4 and worse DES?&lt;/p&gt;
&lt;p&gt;Well, because that's what the client was configured to send.&lt;/p&gt;
&lt;p&gt;Why was it configured to send that? Because machine policy said so.&lt;/p&gt;
&lt;p&gt;Addendum&lt;/p&gt;
&lt;p&gt;Because of course it's always a little more complicated. After reports of clients also being configured for AES-only I reviewed the code again.&lt;/p&gt;
&lt;p&gt;The "Requested ETypes" values in the log may also refer to the service account msDS-SupportedEncryptionTypes attribute.&lt;/p&gt;
&lt;p&gt;The logger will choose which one to record based on a couple of conditions, so of course it's not actually guaranteed to be what's in the request, just sometimes. &lt;code&gt;exasperated.gif&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And for completeness if that attribute is zero, it pulls the value from the default enctype registry value.&lt;/p&gt;
&lt;p&gt;So the above logic is still correct for why it fails. You asked for X, system said it only supports X, but the service in question is configured for Y.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Authentication</category>
  <category>Kerberos</category>
  <guid isPermaLink="false">https://syfuhs.net/kerberos-event-id-27</guid>
  <pubDate>Thu, 24 Nov 2022 01:20:00 GMT</pubDate>
</item>
<item>
  <title>Understanding Windows Authentication</title>
  <link>https://syfuhs.net/understanding-windows-auth</link>
  <description>&lt;p&gt;This is just a list of all the things I've written on Windows authentication. I've sorted it by rabbit hole.&lt;/p&gt;
&lt;h2&gt;Architectural Things&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/what-happens-when-you-type-your-password-into-windows"&gt;What Happens When you Type Your Password into Windows?&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-azure-ad-windows-sign-in-works"&gt;How Azure AD Windows Sign-in Works&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-authentication-works-when-you-use-remote-desktop"&gt;How Authentication Works when you use Remote Desktop&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/understanding-identity-delegation"&gt;Identity Delegation in Active Directory&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-managed-service-accounts-in-active-directory-work"&gt;How Managed Service Accounts in Active Directory Work&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/a-bit-about-the-local-security-authority"&gt;A Bit About the Local Security Authority&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/on-computer-passwords"&gt;On Computer Passwords&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/why-we-built-azure-ad-kerberos"&gt;Why We Built Azure AD Kerberos&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/windows-hello-cloud-trust"&gt;Windows Hello Cloud Trust&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;The Protocols&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/a-bit-about-kerberos"&gt;Kerberos Explained in a Little Too Much Detail&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/windows-and-domain-trusts"&gt;Windows and Domain Trusts&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/kerberos-fast-armoring"&gt;Kerberos FAST Armoring&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/hybrid-authentication-with-fido"&gt;Hybrid Authentication with FIDO&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-azure-ad-kerberos-works"&gt;How Azure AD Kerberos Works&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Credential Protection&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/protecting-against-credential-theft-in-windows"&gt;Protecting Against Credential Theft in Windows&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/privileged-access"&gt;A Strategy for Protecting Privileged Access&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-windows-defender-credential-guard-works"&gt;How Windows Defender Credential Guard Works&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/how-does-remote-credential-guard-work"&gt;How does Remote Credential Guard Work?&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Service Hardening&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/lessons-in-disabling-rc4-in-active-directory"&gt;Lessons in Disabling RC4 in Active Directory&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/killing-ntlm-is-hard"&gt;Killing NTLM is Hard&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://syfuhs.net/mfa-is-hard-to-do-right"&gt;MFA is Hard to do Right&lt;/a&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Authentication</category>
  <category>Windows</category>
  <category>Security</category>
  <category>Featured</category>
  <guid isPermaLink="false">https://syfuhs.net/understanding-windows-auth</guid>
  <pubDate>Mon, 13 Jun 2022 22:14:00 GMT</pubDate>
</item>
<item>
  <title>How does Remote Credential Guard Work?</title>
  <link>https://syfuhs.net/how-does-remote-credential-guard-work</link>
  <description>&lt;p&gt;In the spirit of distracting myself from Doom Scrolling, let's talk about a feature that is super useful that many folks don't really know a lot about: Remote Credential Guard.&lt;/p&gt;
&lt;p&gt;I've gone into relatively great detail about all the different stages of Windows auth and I encourage everyone to read through the posts because there's literally centuries of dev hours put into building all of this and it's complex.&lt;/p&gt;
&lt;p&gt;The first thing is how does basic sign on work? &lt;a href="https://syfuhs.net/what-happens-when-you-type-your-password-into-windows"&gt;What Happens When you Type Your Password into Windows? (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The second is how does basic RDP authentication work? &lt;a href="https://syfuhs.net/how-authentication-works-when-you-use-remote-desktop"&gt;How Authentication Works when you use Remote Desktop (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;div class="css-1dbjc4n"&gt;
&lt;div class="css-1dbjc4n r-1s2bzr4"&gt;
&lt;div id="id__8xrc52kv2mr" class="css-901oao r-jwli3a r-37j5jr r-1blvdjr r-16dba41 r-vrz42v r-bcqeeo r-bnwqim r-qvutc0" dir="auto" lang="en"&gt;&lt;span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"&gt;The third one is how does Credential Guard work? &lt;a href="https://syfuhs.net/how-windows-defender-credential-guard-works"&gt;How Windows Defender Credential Guard Works (syfuhs.net)&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p class="css-901oao r-jwli3a r-37j5jr r-1blvdjr r-16dba41 r-vrz42v r-bcqeeo r-bnwqim r-qvutc0" dir="auto" lang="en"&gt;&lt;span class="css-901oao css-16my406 r-poiln3 r-bcqeeo r-qvutc0"&gt;The fourth one is What is the LSA? &lt;a href="https://syfuhs.net/a-bit-about-the-local-security-authority"&gt;A Bit About the Local Security Authority (syfuhs.net)&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Now, since I don't expect everyone to go off and read those let's summarize a bit.&lt;/p&gt;
&lt;p&gt;In a normal world you type your password into Windows and that kicks off a bunch of machinery that verifies the credential, sets up your logon session, creates your desktop, etc.&lt;/p&gt;
&lt;p&gt;RDP does the exact same thing, except it has a precursor step that makes sure you're sending the password to the right computer called NLA. After, the RDP client literally sends the password you typed in across the network to the remote machine.&lt;/p&gt;
&lt;p&gt;The remote machine effectively does the equivalent of typing that password into a credential provider for you, kicking off all the logon machinery. This is super important because the password unlocks all sorts of important systems within your logon session.&lt;/p&gt;
&lt;p&gt;There are things like DPAPI that are bound to your credential. SSO using Kerberos or NTLM require the password to get a TGT or challenge. It's a fairly important prerequisite. &lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It turns out this is really rather dangerous if you don't trust that remote machine, because it has your password now whether you like it or not. Incidentally this is why keeping NLA on all the time is important.&lt;/p&gt;
&lt;p&gt;So, what do we do about it? Well, if we go back to how Credential Guard works, we have this concept of a tiny locked down VM running beside your regular session where you can periodically ask it certain specific questions.&lt;/p&gt;
&lt;p&gt;1. Can you encrypt/decrypt this for me? (Yes)&lt;br /&gt;2. Can you give me my password to send to this other machine (NO!)&lt;br /&gt;3. Can you store this session key so attackers can't steal it? (Yes)&lt;/p&gt;
&lt;p&gt;Yadda yadda yadda.&lt;/p&gt;
&lt;p&gt;Coding-wise it was implemented [more or less] as an interface of questions you can ask. We have two implementations: the first is the one LSA uses when CG is off. Things just stay in LSA memory. The second lives in LsaIso, where LSA interacts with it over Hyper-V-provided RPC.&lt;/p&gt;
&lt;p&gt;When CG is on, LSA knows to call the RPC version, otherwise it calls the normal-world version. Most important secret-y things travel through this interface.&lt;/p&gt;
&lt;p&gt;Only LSA can call the interface implementations, so at worst you're still protected from normal attacks because you must first breach LSA before doing anything interesting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which, by the way go turn on LSA PPL please.&lt;/p&gt;
&lt;p&gt;The engineering value behind this design is also super high because it makes it clear who is responsible for what security decisions. I'm very proud of the devs that designed and built this because it was a monumental engineering task.&lt;/p&gt;
&lt;p&gt;Anyway.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So, you have:&lt;br /&gt;Password =&amp;gt; LSA =&amp;gt; Cred Guard&lt;/p&gt;
&lt;p&gt;Cred Guard &amp;lt;=interface=&amp;gt; LSA &amp;lt;=&amp;gt; Apps&lt;/p&gt;
&lt;p&gt;Now we introduce RDP. On the target machine it works exactly the same way, except that password came from a remote machine.&lt;/p&gt;
&lt;p&gt;What if we did this?&lt;/p&gt;
&lt;p&gt;Client:&lt;/p&gt;
&lt;p&gt;Password =&amp;gt; LSA =&amp;gt; Cred Guard [client machine]&lt;/p&gt;
&lt;p&gt;RDP Server:&lt;/p&gt;
&lt;p&gt;Cred Guard [client machine] &amp;lt;=RDP interface=&amp;gt; LSA &amp;lt;=&amp;gt; Apps&lt;/p&gt;
&lt;p&gt;[thinking.gif]&lt;/p&gt;
&lt;p&gt;Remember that interface thingy that LSA calls? What if we built a 3rd interface that instead of doing things in memory, or RPC over Hyper-V, it does it with RPC over the RDP transport whatsits (I can't remember what they're called).&lt;/p&gt;
&lt;p&gt;Now your creds stay on the client, and whenever the RDP target needs to use those secrets for whatever reason it asks LSA as usual, LSA asks the interface, and it just happens that the interface implementation lives on the other side of the world in your client machine.&lt;/p&gt;
&lt;p&gt;[mindblown.gif]&lt;/p&gt;
&lt;p&gt;And so we have Remote Credential Guard.&lt;/p&gt;
&lt;p&gt;Now, obviously this is not a fool-proof solution to all security problems. You have full SSO to all things on the remote machine just as if you typed in your password. That means something on that machine can do something malicious as you via SSO.&lt;/p&gt;
&lt;p&gt;But they can only do it for as long as your session is active. Once you disconnect, the connection to the client LSA is dead. Requesting new tickets fails. The target machine's ticket cache is also useless because it requires Cred Guard to function. NTLM has no ntowf.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Authentication</category>
  <category>Featured</category>
  <category>Security</category>
  <guid isPermaLink="false">https://syfuhs.net/how-does-remote-credential-guard-work</guid>
  <pubDate>Sat, 26 Feb 2022 20:51:00 GMT</pubDate>
</item>
<item>
  <title>Windows Hello Cloud Trust</title>
  <link>https://syfuhs.net/windows-hello-cloud-trust</link>
  <description>&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/windows/security/identity-protection/hello-for-business/hello-hybrid-cloud-trust"&gt;Windows Hello Cloud Trust&lt;/a&gt;: What is it? Why do you care?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A thread.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs)&amp;nbsp; &lt;a href="https://twitter.com/SteveSyfuhs/status/1496231396469358602?ref_src=twsrc%5Etfw"&gt;February 22, 2022&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In the early days, Windows Hello for Business came in two deployment flavors: Certificate Trust or Key Trust.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Certificate Trust is basically the answer to the question "what if we made smart cards unlockable with your face?"&lt;/p&gt;
&lt;p&gt;This is a surprisingly accurate depiction because under the covers Windows Hello uses certificate logon to get you to the desktop, which in the CT case means spinning up PKI, deploying templates, protecting private keys through hardware binding, etc.&lt;/p&gt;
&lt;p&gt;Smart cards require the exact same infrastructure, and the only difference is where the private key is stored. In the Hello case it's stored on disk and protected by your TPM. Smart cards store them in silicon embedded on a plastic card.&lt;/p&gt;
&lt;p&gt;This model works about as well as you can expect for a system that is not dependent on the cloud and must coexist with existing PKI within large organizations, and actually: it works well. We cut out teeth on getting the infrastructure right with smart cards over 20 years.&lt;/p&gt;
&lt;p&gt;All of this came about in Windows 10, and didn't require changes to Active Directory, which means no Domain Controller deployments. Okay, that actually makes for some reasonable tradeoffs.&lt;/p&gt;
&lt;p&gt;But then we had this other mode: Key Trust. This mode doesn't require PKI and gives you some flexibility in deployment, but for all intents and purposes requires The Cloud to do all sorts of orchestration plus enough Server 2016 DCs to handle authentication load. Tradeoffs.&lt;/p&gt;
&lt;p&gt;Between the two, for the vast majority of customers Key Trust is a lot easier to deploy as they're already hybrid, or are planning it, don't already have PKI in place, and have no problem standing up a handful of 2016 servers.&lt;/p&gt;
&lt;p&gt;But there are some downsides. See, when you log into Windows with Windows Hello the authority with which you authenticate against is determined by your join state. Domain join =&amp;gt; Domain Controller. Azure AD Join =&amp;gt; Azure AD.&lt;/p&gt;
&lt;p&gt;Doing the face thing or the fingerprint thing or the PIN thing unlocks a private key, and that private key is used to authenticate to the machine authority. In DJ land that's a certificate, doing Kerberos PKINIT. In AADJ land that's an OAuth signed assertion.&lt;/p&gt;
&lt;p&gt;Certificate trust doesn't need to do anything special, since the PKI is all local to AD and AD fundamentally understands the cert presented to it. The cloud requires something like ADFS to translate the certificate to something AAD understands.&lt;/p&gt;
&lt;p&gt;Key trust is the reverse: the cloud natively understands the key and AD needs it translated. Most folks deploy AAD Connect and rely on a backsync where AAD pushes down the Windows Hello certificates to AD.&lt;/p&gt;
&lt;p&gt;This backsynced key gets stored in a special location different from where certificate trust or smart cards go For Reasons (good reasons) which necessitates 2016+, but still fundamentally works as a smart card does by authenticating using Kerberos PKINIT.&lt;/p&gt;
&lt;p&gt;In principle this is fine since most folks have AAD Connect, but there are problems because this sync can take anywhere from 1 minute to 30 minutes on average, plus however long it takes to replicate from the sync target DC and whichever DC you're authenticating against.&lt;/p&gt;
&lt;p&gt;In short: it takes a long time to provision a key trust key on-prem, and you can't use Windows Hello to log into your hybrid machine for... a while. And you can't access on-prem resources on AADJ machines for... a while.&lt;/p&gt;
&lt;p&gt;It's not ideal.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Remember FIDO? Remember all that work we did to build Kerberos into the cloud? Remember how when you log into a machine, we immediately give you a TGT from AAD and use it to log you into your machine and get you access to on-prem resources?&lt;/p&gt;
&lt;p&gt;So: Cloud Trust.&lt;/p&gt;
&lt;p&gt;[Ta-da]&lt;/p&gt;
&lt;p&gt;Cloud Trust gives us the best of both worlds. We get instant provisioning and instant hybrid auth, all without having to deploy any additional infrastructure. Neat.&lt;/p&gt;
&lt;p&gt;So, how does this thing work? Well, you start with Key Trust. You do all the same onboarding into AAD, where you generate a key, register it with AAD and voila instant Hello. This part is a little more complicated, but honestly, not by much. Make key, have key, give key, use key.&lt;/p&gt;
&lt;p&gt;The heavy lifting is now the backend. In the before-times AAD had to push the key back down to AD, which took fooooreeeevvveerrrr. Now when you log in with the key you registered 5 seconds ago, we generate a partial TGT and return it to your machine.&lt;/p&gt;
&lt;p&gt;Sometime before we generated the TGT you also ran a one-line PowerShell command that:&lt;/p&gt;
&lt;p&gt;1. Created an Azure AD RODC object on-prem&lt;br /&gt;2. Synced that RODC secret to AAD&lt;/p&gt;
&lt;p&gt;The presence of that RODC secret in AAD is what triggers this magic. It tells us you trust AAD to log you in to your on-prem environment.&lt;/p&gt;
&lt;p&gt;So, you log in, we generate a partial TGT encrypted to the RODC secret and return it to you. Your Windows client sees this, sends the partial TGT to a nearby domain controller and asks for a real on-prem TGT.&lt;/p&gt;
&lt;p&gt;The domain controller understands that this is a partial (RODC) TGT, meaning it contains exactly one piece of information in it: your username. The reason this is interesting is because it *doesn't* contain your group membership information.&lt;/p&gt;
&lt;p&gt;This is actually a pretty useful mechanism because folks don't like synchronizing ALL of their group memberships to AAD, and if we returned a TGT with a subset of your memberships you'd be hosed. So, your DC looks you up by name, does some sanity checks, and generates a full TGT.&lt;/p&gt;
&lt;p&gt;Cloud trust takes your hybrid Windows Hello deployment from a very complicated and slow process down to a PowerShell command and some Group Policy or Intune futzing to turn the feature on.&lt;/p&gt;
&lt;p&gt;Not bad.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Authentication</category>
  <category>Featured</category>
  <category>Azure AD</category>
  <guid isPermaLink="false">https://syfuhs.net/windows-hello-cloud-trust</guid>
  <pubDate>Tue, 22 Feb 2022 21:16:00 GMT</pubDate>
</item>
<item>
  <title>Why We Built Azure AD Kerberos</title>
  <link>https://syfuhs.net/why-we-built-azure-ad-kerberos</link>
  <description>&lt;p&gt;Yesterday we announced the public preview of, amongst other things, Azure AD Kerberos. I &lt;a title="How Azure AD Kerberos works" href="https://syfuhs.net/how-azure-ad-kerberos-works" target="_blank" rel="noopener"&gt;discussed a bit about how we did it&lt;/a&gt;, and why the features depend on it. But I didn't really explain why we chose the solution we did.&lt;/p&gt;
&lt;p&gt;Here's why.&lt;/p&gt;
&lt;p&gt;There are... mmmmmm ...a bajillion... Windows devices out in the world today (give or take). Some running the latest and greatest Windows 11, others running various versions of Windows 10, others running Windows 8, Windows 7, XP (seriously folks?), and all the various servers.&lt;/p&gt;
&lt;p&gt;There are... mmmmmmm ...half... a bajillion line of business apps that rely on Active Directory-backed authentication. Some Windows-based, some not-Windows-based. The vast majority of them use Kerberos to authenticate in some way or another.&lt;/p&gt;
&lt;p&gt;Over the next few years folks are going to want to migrate lots of these things to the cloud, either lift-and-shift, rewrite, replace-with-SaaS, etc. and they'll inevitably want to shift away from this on-prem dependency.&lt;/p&gt;
&lt;p&gt;There are *very* good reasons for that. AD has networking constraints, doesn't support certain authentication methods like FIDO, doesn't have easy to use policy controls, is showing its age with the likes of NTLM, etc. I could go on.&lt;/p&gt;
&lt;p&gt;Conversely the cloud -- Azure AD -- has moved mountains with its capabilities: Conditional Access policies, Multifactor Auth, FIDO, world-class auditing and security and reliability.&lt;/p&gt;
&lt;p&gt;Clearly there's a gap here so it makes sense for apps to want to take advantage of what Azure AD can offer. If you're lucky you can replace functionality with OAuth or SAML, but many apps will still require protocols like Kerberos.&lt;/p&gt;
&lt;p&gt;These are the laws of big numbers. If you have a billion things using Kerberos and replace half of them with something else, congrats! You've seriously done the unthinkable. However, you still have half a billion things to do something about.&lt;/p&gt;
&lt;p&gt;Okay crazy idea: What if we made Kerberos a first-class modern protocol for Azure AD?&lt;/p&gt;
&lt;p&gt;Voila: Azure AD Kerberos.&lt;/p&gt;
&lt;p&gt;But Kerberos has its issues. It's insecure, it's hard to use, it's ugly, it's it's it's it's.&lt;/p&gt;
&lt;p&gt;It's none of those things. You're holding it wrong. Yes, I just said that. Hear me out.&lt;/p&gt;
&lt;p&gt;You're holding it wrong because of us.&lt;/p&gt;
&lt;p&gt;Making sweeping changes to improve the security of these things is *hard*. Compatibility is one issue, time to market is another, time to mass adoption is yet another. These all add up to great features like gMSAs and Windows Hello, but it take's time. How do we move faster?&lt;/p&gt;
&lt;p&gt;Kerberos is insecure because it relies on passwords and humans are bad at keeping passwords secure. The weaknesses are because the security of the protocol relies on the strength of the password and weak passwords can be easy to crack.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F12%2Fmfa.png" alt="Conditional Access MFA" width="295" height="634" /&gt;&lt;/p&gt;
&lt;p&gt;We solved that through some pretty simple rules:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You just can't do password auth.&lt;/li&gt;
&lt;li&gt;Service Principal secrets are not passwords. They're randomly generated noise.&lt;/li&gt;
&lt;li&gt;There's no fallback to NTLM.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Kerberos is hard to use.&lt;/p&gt;
&lt;p&gt;I mean, is it?&lt;/p&gt;
&lt;p&gt;Nevertheless, we now do all the heavy lifting for you. You had to make sure you typed the password in right and had to give it the right SPN, but now we do that for you in the majority of the cases.&lt;/p&gt;
&lt;p&gt;Kerberos is ugly. I guess? But have you looked at how TLS client certificate auth *really* works?&lt;/p&gt;
&lt;p&gt;I'm getting off topic.&lt;/p&gt;
&lt;p&gt;Anyway, let's talk about it in action. With on-prem AD how would you lock down a file share to require MFA like Windows Hello? Well, I guess you'd have to look up the Windows Hello SIDs and stick deny ACLs on there when they...aren't...present? How the frig do you do that sanely?&lt;/p&gt;
&lt;p&gt;Azure AD just requires a Conditional Access policy.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It's a checkbox.&lt;/p&gt;
&lt;p&gt;Maybe you only want devices that comply to a certain company policy. With on-prem AD you...deploy PKI for device certs marked with EKUs that indicate compliance, force machine certificate auth, roll out claims policies issued on presence of EKUs and&lt;/p&gt;
&lt;p&gt;&lt;img style="float: left;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F12%2Fmfa2.jpg" alt="Device Compliance" width="295" height="166" /&gt;&lt;/p&gt;
&lt;p&gt;I can't remember what else.&lt;/p&gt;
&lt;p&gt;Just a checkbox in Azure AD.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F12%2FFFomJ3DUcAEDURJ-637740850451092579.png" alt="Location Policy" width="729" height="486" /&gt;&lt;/p&gt;
&lt;p&gt;Maybe you only want users accessing the file share from certain regions or jurisdictions or countries. With on-prem AD you... if you just... ah well... or I guess ...NAP? Is that a thing still?&lt;/p&gt;
&lt;p&gt;Still just a checkbox in Azure AD.&lt;/p&gt;
&lt;p&gt;Well, okay. They're radio buttons.&lt;/p&gt;
&lt;p&gt;Conditional access for Kerberos is a billion-dollar security control if you ask me, and it's just built in to Azure AD for you for free.&lt;/p&gt;
&lt;p&gt;Auditing is another critical aspect. You have 300 Domain Controllers in your environment, and you want to find out if a user that lives in North Carolina just logged in at 3:30am from... Angola?&lt;/p&gt;
&lt;p&gt;Yeah, I don't even know where to start.&lt;/p&gt;
&lt;p&gt;It's a search field in Azure AD.&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F12%2FFFotaBOVcAQxAWu.png" alt="Audit Search" width="817" height="288" /&gt;&lt;/p&gt;
&lt;p&gt;So, put all of this together and you can see why you might want to modernize your Kerberos usage.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Authentication</category>
  <category>Kerberos</category>
  <category>Azure AD</category>
  <category>Windows</category>
  <category>Active Directory</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/why-we-built-azure-ad-kerberos</guid>
  <pubDate>Thu, 02 Dec 2021 23:29:00 GMT</pubDate>
</item>
<item>
  <title>Why Thread Readers are Blocked</title>
  <link>https://syfuhs.net/why-thread-readers-are-blocked</link>
  <description>&lt;p&gt;Every time I write out a &lt;a href="https://syfuhs.net/how-azure-ad-kerberos-works"&gt;long&lt;/a&gt; &lt;a href="https://syfuhs.net/on-computer-passwords"&gt;thread&lt;/a&gt; &lt;a href="https://syfuhs.net/a-bit-about-the-local-security-authority"&gt;on&lt;/a&gt; &lt;a href="https://syfuhs.net/mfa-is-hard-to-do-right"&gt;some&lt;/a&gt; &lt;a href="https://syfuhs.net/killing-ntlm-is-hard"&gt;technical&lt;/a&gt; &lt;a href="https://syfuhs.net/lessons-in-disabling-rc4-in-active-directory"&gt;topic&lt;/a&gt; I inevitably see someone replying to my first post tagging a bot and telling it to unroll the thread.&lt;/p&gt;
&lt;p&gt;I block every single one of those bots. They won't work. I will go out of my way to make sure they don't work.&lt;/p&gt;
&lt;p&gt;Why?&lt;/p&gt;
&lt;p&gt;Because they make money off my content without lifting a finger. I actually don't care if someone reuses my work. Go to town, have at it, make a buttload of money. But, if it's a wholesale copy of my stuff wrapped in advertisements for god knows what and all you've done is copied and pasted? Well, that's a no from me. Also, maybe, you know, ask? I'll say yes; just tell folks where you got it.&lt;/p&gt;
&lt;p&gt;To that end I always dutifully put all these threads into posts on this site under the &lt;a href="https://syfuhs.net/category/twitter%20thread"&gt;Twitter Thread&lt;/a&gt; category and every thread has a link to that post at the end. I even have &lt;a href="https://syfuhs.net/feed/rss"&gt;RSS&lt;/a&gt;/&lt;a href="https://syfuhs.net/feed/atom"&gt;ATOM&lt;/a&gt; feeds so if you want all these threads in a single place go use an RSS reader.&lt;/p&gt;
&lt;p&gt;Not only are the posts formatted better, they also doesn't have advertisements on them. I make no money off this site. It costs me money to host.&lt;/p&gt;
&lt;p&gt;Do everyone a favor and stop using these godforsaken bots. It takes time and energy putting stuff into written form and they're taking advantage of people just wanting to create.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/why-thread-readers-are-blocked</guid>
  <pubDate>Thu, 02 Dec 2021 17:09:00 GMT</pubDate>
</item>
<item>
  <title>How Azure AD Kerberos Works</title>
  <link>https://syfuhs.net/how-azure-ad-kerberos-works</link>
  <description>&lt;p&gt;I spent the better part of the last two years building the authentication stack used by &lt;a href="https://techcommunity.microsoft.com/t5/azure-virtual-desktop-blog/announcing-public-preview-of-fslogix-profiles-for-azure-ad/ba-p/3019855"&gt;FSLogix in Azure Virtual Desktop for AADJ machines&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1466188763072110595"&gt;December 1, 2021&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It turns out building an entirely new form of hybrid authentication is complicated. How did we make a platform protocol like SMB work for Windows machines without requiring Active Directory?&lt;/p&gt;
&lt;p&gt;Easy (welllll): we turned Azure AD into a KDC for Kerberos.&lt;/p&gt;
&lt;p&gt;What do I mean by that? You turned AAD into a KDC? Huh? You did what?!&lt;/p&gt;
&lt;p&gt;Let's break this down a bit. You have Azure Virtual Desktop, and you want to stash user profiles into a centralized place. Voila: FSLogix. Not new. But you don't want to host your own file share.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Ah. Well.&lt;/p&gt;
&lt;p&gt;Okay, we have this thing called Azure Files which is SMB over Azure Storage, so stuff the profiles there. That's...actually really cool.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How do you authenticate to it? Easy! NTLM. Wait. No, crap. Bad. Bad. Bad.&lt;/p&gt;
&lt;p&gt;So AzFiles introduced Active Directory support.&lt;/p&gt;
&lt;p&gt;In principle this is somewhat simple. You create a service principal in your own AD and give it an SPN of cifs/your.file.core.windows.net, and whenever you type &lt;code&gt;\\your.file.core.windows.net&lt;/code&gt; your Windows client will dutifully ask AD for a ticket and away you go.&lt;/p&gt;
&lt;p&gt;"All" Azure Files needs to know is the service principal password and it can decrypt the ticket, get your identity, get your SIDs, and everyone is happy.&lt;/p&gt;
&lt;p&gt;Except how does the AVD host contact AD? It needs to be domain joined or AADJ'ed. And it needs line of sight to a DC.&lt;/p&gt;
&lt;p&gt;Okay, well your AVD hosts are in the cloud, and your DCs are in your on-prem network and that means VPN or moving DCs into the cloud AND still needing a VPN for replication yadda yadda yadda. Why can't Azure Files just use AAD to authenticate users?&lt;/p&gt;
&lt;p&gt;Let's call it impedance mismatch. Windows understands SMB. SMB understands NTLM or Kerberos. AAD understands OAuth.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Ah.&lt;/p&gt;
&lt;p&gt;Well, what if we make AAD understand Kerberos? How do you make the world's largest [web-based] identity provider natively understand the world's most-used [not-web-based] authentication protocol?&lt;/p&gt;
&lt;p&gt;And so begins a two-year journey.&lt;/p&gt;
&lt;p&gt;First of all, let's set some ground rules. Kerberos is great for many reasons, but it's also janky for others. It has two legs: AS and TGS.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;AS exchanges primary creds for tickets.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;TGS exchanges tickets for tickets.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The AS leg can be a bit janky.&lt;/p&gt;
&lt;p&gt;AS requires both parties have knowledge of the client's password (or asymmetric keys) and AAD doesn't necessarily know either of those, at least not in the forms necessary to make the protocol work. Also, what about support for new authenticators like FIDO? Hmm.&lt;/p&gt;
&lt;p&gt;Wait a minute. We've solved this problem already. What if AAD gives us a TGT during logon? That's how we made FIDO work. &lt;a href="https://syfuhs.net/hybrid-authentication-with-fido"&gt;Hybrid Authentication with FIDO (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As it turns out that wasn't quite good enough. The TGT we issue for FIDO targets your on-prem servers, and doesn't contain things like a PAC, and is intended to be exchanged for an on-prem TGT the minute it's received so it's just...weird.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F12%2FFFju0YAVEAETyPt.png" alt="Kerberos Ticket Cache" width="608" height="182" /&gt;&lt;/p&gt;
&lt;p&gt;Alright, what if we give you a separate TGT? A Cloud TGT, if you will. I've logged into Windows. It's fired off a request to AAD to get my PRT, and with my PRT comes back this FIDO TGT (optionally) as well as a Cloud TGT.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And so it gets interesting.&lt;/p&gt;
&lt;p&gt;We have some curious problems to contend with now. A user belongs to a single realm. When you log in you get a single primary TGT, and that more or less dictates who you contact to get tickets. Well, my realm is on-prem. The cloud TGT can't trample that lest we break the world.&lt;/p&gt;
&lt;p&gt;So I now belong to two realms: on-prem and the meta-realm &lt;code&gt;KERBEROS.MICROSOFTONLINE.COM&lt;/code&gt;. Everyone belongs to it. To clarify up front: this is not an isolation thing, it's just a global name. There's still tenant isolation.&lt;/p&gt;
&lt;p&gt;This meta-realm is conceptually simple: when you want to get a Kerberos ticket to a cloud resource you ask the &lt;code&gt;KERBEROS.MICROSOFTONLINE.COM&lt;/code&gt; realm. Easy.&lt;/p&gt;
&lt;p&gt;Okay, I've logged in, gotten my PRT, gotten my cloud TGT, and now AVD asks FSLogix to load my profile from &lt;code&gt;\\mystuff.file.core.windows.net&lt;/code&gt;. FSLogix doesn't know any better so it asks Windows, Windows asks SMB, SMB says "heeeeeey I need a ticket?" Good old SSO. &lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now the Kerberos stack has a request for &lt;code&gt;cifs/mystuff.file.core.windows.net&lt;/code&gt;, how does is it know what realm to use, what TGT to use? It's so confusing. It turns out to be quite simple: during that PRT thing at logon we return a mapping of name suffixes to realms.&lt;/p&gt;
&lt;p&gt;What does that mean? An example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;*.windows.net =&amp;gt; KERBEROS.MICROSOFTONLINE.COM&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If the SPN ends with the value on the left, then that means you should use the TGT from the realm on the right.&lt;/p&gt;
&lt;p&gt;Okay, so the Kerberos stack now knows cifs/myfiles.core.windows.net belongs to the cloud &lt;code&gt;KERBEROS.MICROSOFTONLINE.COM&lt;/code&gt; realm. How do you get a ticket from this nebulously named thing?&lt;/p&gt;
&lt;p&gt;Back during logon we contacted AAD and did the PRT thing. In response we got&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The PRT&lt;/li&gt;
&lt;li&gt;Cloud TGT&lt;/li&gt;
&lt;li&gt;FIDO TGT (optionally)&lt;/li&gt;
&lt;li&gt;Realm mapping&lt;/li&gt;
&lt;li&gt;AAD tenant details&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Aha, here we go. Tenant details.&lt;/p&gt;
&lt;p&gt;The bit of Windows that did the AAD authentication knows enough about Kerberos to say "It's dangerous to go alone! Take this!", bundles up the TGT, mapping, and tenant info and hands it off to the Kerberos stack.&lt;/p&gt;
&lt;p&gt;The Kerberos stack is enlightened enough to see that if it gets this bundle of stuff that it should do something special with it. What does it do?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Stuff the TGT into the cache&lt;/li&gt;
&lt;li&gt;Cache the realm mapping&lt;/li&gt;
&lt;li&gt;Add a KDC Proxy map between (2) and the endpoint in the tenant details&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Oh hey, that's how we magically transit Kerberos over the internet! KDC Proxy. Or more specifically the &lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-kkdcp/5bcebb8d-b747-4ee5-9453-428aec1c5c38"&gt;[MS-KKDCP]&lt;/a&gt; protocol. Neeeeeeat.&lt;/p&gt;
&lt;p&gt;Okay, back to the ticket request. Kerberos sees &lt;code&gt;cifs/mystuff.file.core.windows.net&lt;/code&gt;, sees &lt;code&gt;*.windows.net&lt;/code&gt; maps to &lt;code&gt;KERBEROS.MICROSOFTONLINE.COM&lt;/code&gt; realm and sees a KDC proxy mapping of that realm to &lt;code&gt;https://login.microsoftonline.com/tenantid/kerberos&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Hmm.&lt;/p&gt;
&lt;p&gt;Incidentally you can find that endpoint in the .well-known endpoints list: &lt;code&gt;https://login.microsoftonline.com/common/.well-known/openid-configuration&lt;/code&gt; (replace common with your tenant ID).&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F12%2FFFj2BzwUYAQ1l29.png" alt="Kerberos endpoint" width="669" height="106" /&gt;So we fire off a TGS request over the KDC Proxy protocol to AAD and now it's real good old-fashioned Kerberos and we're cooking with fire.&lt;/p&gt;
&lt;p&gt;It turns out this is the easy part. AAD receives the TGS-REQ, verifies the cloud TGT matches the tenant in the endpoint, looks up the user, looks up the requested SPN, generates a ticket, encrypts it to the service principal key, bundles it all up in a TGS-REP and returns it.&lt;/p&gt;
&lt;p&gt;Oh right, the service principal. It's just an AD service principal. It has keys. You configured it when you set it up. Azure Files has its' storage keys, those keys are synced with AAD, and when you generate a ticket, it gets encrypted to those keys.&lt;/p&gt;
&lt;p&gt;Anyway, the Kerberos stack receives the TGS-REP, strips out the ticket, generates an AP-REQ, hands it back to SMB, SMB stuffs it into a header, sends the SMB hello, Azure Files receives the hello, decrypts the ticket, and hey look at that, an identity.&lt;/p&gt;
&lt;p&gt;SMB didn't know any better. Azure Files mostly didn't know any better. FSLogix definitely didn't know any better, and now here you are, logged into AVD with a centralized and roaming profile secured without Active Directory.&lt;/p&gt;
&lt;p&gt;Whoa.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Authentication</category>
  <category>Azure AD</category>
  <category>Kerberos</category>
  <category>Kerberos.NET</category>
  <category>Featured</category>
  <guid isPermaLink="false">https://syfuhs.net/how-azure-ad-kerberos-works</guid>
  <pubDate>Wed, 01 Dec 2021 23:57:00 GMT</pubDate>
</item>
<item>
  <title>On Computer Passwords</title>
  <link>https://syfuhs.net/on-computer-passwords</link>
  <description>&lt;p&gt;In the spirit of people being wrong on the internet, I wanted to briefly discuss something people rarely get right: the computer account password.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Your computer has an account in Active Directory and that account has a password. This account is what makes Kerberos work. When you want to communicate with this computer you encrypt tickets to the account password.&lt;/p&gt;
&lt;p&gt;When your computer wants to act as itself on the network (instead of, say, you) it uses it's password to authenticate to the domain controller. Things running as SYSTEM or NETWORK SERVICE operate as the computer account on the network.&lt;/p&gt;
&lt;p&gt;That's why you see COMPUTERNAME$ in DC event logs. Because it's literally the computer account authenticating to-and-fro.&lt;/p&gt;
&lt;p&gt;But the thing people get wrong repeatedly is how this account password is managed.&lt;/p&gt;
&lt;p&gt;Well, it turns out it's deceptively simple. You have this service on your computer called netlogon. Within this netlogon service is a timer. Every few days it polls a domain controller to find out when the password expires, and if it's nearing expiration it changes it.&lt;/p&gt;
&lt;p&gt;See, netlogon is the service that makes function calls to Active Directory on behalf of your computer. There are a handful of ways you communicate with a DC: Kerberos, NTLM, LDAP, and RPC. Netlogon is the RPC bit, and this has historically been called the Secure Channel.&lt;/p&gt;
&lt;p&gt;Incidentally not to be confused with SChannel which is the Windows TLS/SSL provider. They are not related.&lt;/p&gt;
&lt;p&gt;So Windows uses netlogon to rotate it's computer account password.&lt;/p&gt;
&lt;p&gt;The process is fairly simple.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Timer wakes up, connects to a DC, see's its been 30 days&lt;/li&gt;
&lt;li&gt;Netlogon generates a password locally, stashes it, authenticates to the DC with the old password&lt;/li&gt;
&lt;li&gt;Calls ChangePassword(newPassword)&lt;/li&gt;
&lt;li&gt;DC acks&lt;/li&gt;
&lt;li&gt;NL Replaces old pwd with stashed pwd&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;But what happens if that fails? The DC isn't available or the change call doesn't succeed?&lt;/p&gt;
&lt;p&gt;Nothing. Notta. Zilch. Not a thing. A big whopping zero.&lt;/p&gt;
&lt;p&gt;See, *computer* password changes are optimistic. Until you get a confirmation you must assume it's the old password.&lt;/p&gt;
&lt;p&gt;The reason you must assume it's the old one is because of continuity of service. If the computer can't change it's password because it's been WFH for 6 months what happens when you're back in the office? Well, you've now got 10k very annoyed computers to fix manually.&lt;/p&gt;
&lt;p&gt;This is incidentally the source of many fantastically incorrect takes on how Active Directory works.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Take: expired computer passwords cause the trust to be broken.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Fact: nope. Computer passwords have an exception to the lockout policy. They just keep on truckin with the old password.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Take: expired passwords cause computer accounts to expire.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Fact: nope. Just, nope.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Take: computer accounts that haven't logged on in so many months are expired.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Fact: nope.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Take: computer accounts that haven't logged on in so many months are deleted from the directory.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Fact: nope. This isn't a feature in AD. Domain admins like to run scripts that periodically purge such computers and *that* is the source of many problems.&lt;/p&gt;
&lt;p&gt;For all intents and purposes computer accounts don't break on their own nor do they break because of any built-in timers in Windows. That said...&lt;/p&gt;
&lt;p&gt;Computer accounts do break. This is very clearly seen when you find you can't log into your machine anymore with some obscure workstation trust error.&lt;/p&gt;
&lt;p&gt;There's fundamentally only a handful of reasons this happens.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The computer lost the password&lt;/li&gt;
&lt;li&gt;The computer account was deleted&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;(2) is pretty obvious. An admin or some third party process removed it. Happens all the time. DELETE * WHERE LASTLOGGEDON &amp;lt; 3mo&lt;/p&gt;
&lt;p&gt;But (1) is more problematic because it's insidious -- Windows as a rule doesn't just lose things.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This can occur when system secrets get corrupted. Machines are not infallible. Drives fail, processes aren't transactional, bugs go boo, etc.&lt;/p&gt;
&lt;p&gt;Thankfully the fix is usually super easy: Test-ComputerSecureChannel -Repair&lt;/p&gt;
&lt;p&gt;But that generally shouldn't be required. Windows doesn't especially care that the password hasn't changed in forever. It'll happily rotate it the next time it has line of sight, but until then it'll just keep on truckin like nothing is wrong. Because nothing is wrong.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Authentication</category>
  <category>Security</category>
  <category>Windows</category>
  <category>Twitter Thread</category>
  <category>Featured</category>
  <guid isPermaLink="false">https://syfuhs.net/on-computer-passwords</guid>
  <pubDate>Thu, 23 Sep 2021 21:59:00 GMT</pubDate>
</item>
<item>
  <title>A Bit About the Local Security Authority</title>
  <link>https://syfuhs.net/a-bit-about-the-local-security-authority</link>
  <description>&lt;p&gt;It's been a while since our last thread and I need to kill time while a ginormous time travel trace file finishes copying, so let's talk a bit about LSA, the Windows Local Security Authority.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F8%2FE8DGwZ6UUAIyOSP.png" alt="LSASS" width="433" height="586" /&gt;&lt;/p&gt;
&lt;p&gt;The LSA is a system component that oversees all the security decisions on your machine. Whenever Windows needs to authenticate a user or verify permissions or what not, the system asks the LSA. It primarily lives in a user mode service: LSASS.&lt;/p&gt;
&lt;p&gt;The LSA is a bit of an interesting beast in that it's not one singular thing. It's made up of a handful of components, mostly living in user mode, with one teeny-tiny* component living in the kernel.&lt;/p&gt;
&lt;p&gt;*not so tiny&lt;/p&gt;
&lt;p&gt;Before we dig too much into the LSA itself, we need to take a brief look at how Windows security works. There are two fundamental security boundaries in Windows we need to look at: the kernel/usermode boundary, and the user/user boundary.&lt;/p&gt;
&lt;p&gt;The user/user boundary is fairly straightforward. Two separate standard users can't interfere with one another on the same machine. This is enforced through authorization rules bound to identifying information about each user: namely their SIDs.&lt;/p&gt;
&lt;p&gt;A SID is just a unique identifier. No two things will have the same SID. So user A and user B have separate SIDs, and everything belonging to each user is stamped somehow with that SID. The authorization rules in Windows say if you don't have this SID then you can't touch.&lt;/p&gt;
&lt;p&gt;This is fundamentally how all security decisions in Windows are made. Does the user have a SID that matches the list of SIDs that are required to do the thing? Yes, then carry on. No, screw off. Of course, there are two extensions to this, the first being groups.&lt;/p&gt;
&lt;p&gt;The groups you're a member of are an extension of your identity, so as a result you have your SID plus all the SIDs of the groups you're a member of. The second is Windows privileges.&lt;/p&gt;
&lt;p&gt;A Windows privilege is a right to interact with Windows itself. This includes benign things like turning the computer off or critical things like running system services. Privileges are bound to SIDs (ish). Each privilege has a list of SIDs that are allowed to hold the privilege.&lt;/p&gt;
&lt;p&gt;So when I want to turn the computer off Windows checks for the SeShutdownPrivilege, which is granted to the user by virtue of having specific SIDs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Eh, sort of. These privileges are actually stamped on a user token.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F8%2FE8DRv4AVkAE8-A3.png" alt="Privileges" width="480" height="626" /&gt;&lt;/p&gt;
&lt;p&gt;These user tokens are managed by the LSA and are created when a user logs on. Every single user has a token, and every operation in Windows is bound to a token because all processes have a token mapped to them: &lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;These user tokens, often called NT Tokens, are the way Windows represents user identities when logged in. The token is a kernel data structure. What this means is only things in the kernel can touch this data. Which brings us to the kernel mode/usermode boundary.&lt;/p&gt;
&lt;p&gt;The kernel/user boundary is a hardware-enforced boundary. Your CPU dictates whether your code runs in kernel or in user mode. To call things in kernel mode you have to ask the CPU nicely and it may or may not acquiesce because it has a known list of functions that can be called.&lt;/p&gt;
&lt;p&gt;This list is highly specific and dictates whether your API can ask the CPU to execute a function in the context of the kernel. This is how for instance your program can read files off disk. The program asks the CPU if it can execute a kernel call to read IO.&lt;/p&gt;
&lt;p&gt;Anyway, in practice what this means is all the stuff in the kernel like your NT Token can't be touched by stuff in user mode without going through these special functions, and it turns out there isn't a specific function for managing tokens. How's this all work?&lt;/p&gt;
&lt;p&gt;Well, let's start at the beginning. Remember how I said all processes have tokens, and all tokens are managed by LSA, and LSA is a user mode process? Well that sounds a bit...impossible? It turns out the system cheats a bit.&lt;/p&gt;
&lt;p&gt;When the computer turns on the first (ish) thing that executes is the kernel executive. It is "the" kernel process. It's the thing that holds all the system goodies. It's the "in the beginning" in the biblical sense. And it's a no good cheater.&lt;/p&gt;
&lt;p&gt;The executive kicks off user mode, which starts with a single process: wininit.exe. It needs to be running as an identity so the executive cheats and makes the very first SYSTEM token. Wininit knows this and that there's no security system yet, so it starts lsass.exe.&lt;/p&gt;
&lt;p&gt;Incidentally the kernel also knows there's no security system in place, so it halts all further security decisions until LSA starts up. If LSA fails to start the system fails to start.&lt;/p&gt;
&lt;p&gt;So LSASS. That was a long fricken preamble. LSASS is kind of dumb. It only has one job, which is to act as a service host. That service that gets hosted is The LSA. The LSA is *also* a service host, whose job is to host additional services. Oy.&lt;/p&gt;
&lt;p&gt;So, that LSA service. It's called the LSA server and is backed by lsasrv.dll. If you go look at the files you'll see this is an absolutely massive DLL compared to lsass.exe. That's where all the meat is.&lt;/p&gt;
&lt;p&gt;The server has two jobs, one of which is to host an RPC server (shocked face), and to manage additional child services. These child services are critical, but less interesting. They are things like netlogon, the key isolation service, or LDAP or KDC on your domain controller. &lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F8%2FE8DhgO5VEAIpx7C.png" alt="Services" width="480" height="626" /&gt;&lt;/p&gt;
&lt;p&gt;But the RPC server on the other hand is super interesting. Whenever your application makes a security call, like LogonUser, or something like SSPI's InitializeSecurityContext, your process must call this RPC server.&lt;/p&gt;
&lt;p&gt;Your application doesn't get to touch LSA directly. It goes through some stub calls like LogonUser, which are RPC clients, which communicate to LSA, and then LSA does all the magic.&lt;/p&gt;
&lt;p&gt;That magic is also kinda interesting, because LSA (server) doesn't strictly know what the magic is. LSA (server) knows how to communicate with clients, but it has to hand the actual work off to plugins called authentication providers. Extensibility is fun.&lt;/p&gt;
&lt;p&gt;So to recap you have LSASS, which hosts services, specifically the LSA Server service. The LSA Server service hosts the RPC server, and other complementary services, and the RPC server (kinda sorta) hosts authentication providers. Wheeeee.&lt;/p&gt;
&lt;p&gt;These APs are where the magic happens. There are a handful of builtin APs like Kerberos and NTLM and a very special one called Negotiate, which knows how to...negotiate...between Kerb and NTLM and whatever else is registered.&lt;/p&gt;
&lt;p&gt;I won't go into the logon process, but here it is: &lt;a href="https://syfuhs.net/what-happens-when-you-type-your-password-into-windows"&gt;What Happens When you Type Your Password into Windows? (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Somewhere along the way the logon process needs to create an NT token for the user, so everything running as that user has an identity in the system.&lt;/p&gt;
&lt;p&gt;APs now start to cross the streams with LSA. One other thing LSA knows how to do is communicate with the kernel. Aha! Remember the kernel waiting on the security system to start up? This is why. LSA needs to be able to call into the kernel to ask the kernel to create tokens.&lt;/p&gt;
&lt;p&gt;So the AP asks LSA to create a token. LSA calls into the kernel via RPC (ALPC specifically) and the kernel says "okie-doke here you go".&lt;/p&gt;
&lt;p&gt;But this is RPC. Can't anyone call RPC? Actually yes. But it turns out the kernel-side RPC server checks the caller's token to make sure it's SYSTEM. Funny how that works. /fin&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Authentication</category>
  <category>Security</category>
  <category>Featured</category>
  <guid isPermaLink="false">https://syfuhs.net/a-bit-about-the-local-security-authority</guid>
  <pubDate>Thu, 05 Aug 2021 22:08:00 GMT</pubDate>
</item>
<item>
  <title>MFA is Hard to do Right</title>
  <link>https://syfuhs.net/mfa-is-hard-to-do-right</link>
  <description>&lt;p&gt;There was an internal discussion going on about folks getting too many MFA prompts when they're using RDP. I've danced around this topic quite a bit in past threads, but maybe let's take a look at it: how MFA works in Windows.&lt;/p&gt;
&lt;p&gt;In Windows-land MFA comes in all sorts of flavors. Often what folks see is just a second field on the Windows logon screen to enter a one time password or send a request to their phone to approve before being taken to your desktop.&lt;/p&gt;
&lt;p&gt;This is not MFA. I mean, it is MFA in the sense that you're providing two factors, but in fact it's not MFA because the authority you're communicating with only ever sees a password. This is a critical distinction.&lt;/p&gt;
&lt;p&gt;See, in this scenario you're unlocking your device using the second factor. That's all well and good, but the majority of the things you're doing on your machine actually require communication with other services...not on your machine.&lt;/p&gt;
&lt;p&gt;How were you authenticated to those services? If it's an internal service then that means Kerberos or NTLM. The only way you can authenticate to AD for either of those protocols is through password or certificate.&lt;/p&gt;
&lt;p&gt;If it's an external service protected by AAD then you're using OAuth. AAD OAuth understands many credential types. Which one did we use?&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021/EtaQ-N1UcAEaF88_637480712571624983.jpg" alt="That's bad." width="497" height="372" /&gt;&lt;/p&gt;
&lt;p&gt;Well, the logon screen asked for your password and you hit a button on your phone to approve the logon so chances are quite good that you're authenticating to AD or AAD with...just a password.&lt;/p&gt;
&lt;p&gt;But, the thing is, Windows doesn't really care how you authenticated. I mean, it does, but the internal mechanics aren't doing authorization checks, yet.&lt;/p&gt;
&lt;p&gt;What it boils down to is the authority that Windows trusts just blessed your logon, so you're now at the desktop doing stuff. Windows *then* limits access to things on your machine through authz rules that are driven by the contents of the ticket returned by the authority.&lt;/p&gt;
&lt;p&gt;Put in more technical terms the ticket from AD contains a list of SIDs. Things in Windows are ACL'ed against SIDs, so when checking if you have access to stuff, Windows checks your SID list and gives a yay/nay. Other machines do the exact same thing when you connect to them.&lt;/p&gt;
&lt;p&gt;These SIDs that are put into the ticket are derived from your group membership as well as derived from the credential you used to authenticate yourself. Password is the baseline and gives you nothing special, and there's no way to tell AD that you did password + superduperMFA.&lt;/p&gt;
&lt;p&gt;Therefore in order to do MFA in Windows *and* have it represented to other services, you need to use a method that your authority understands.&lt;/p&gt;
&lt;p&gt;Active Directory understands exactly one(-ish) other factor: certificates.&lt;/p&gt;
&lt;p&gt;This means you can authenticate using smart cards or using Windows Hello.&lt;/p&gt;
&lt;p&gt;AAD understands more. It understands certificates, FIDO, and the mobile authenticator. This means you can [sorta] use smart cards (sorta), Windows Hello, FIDO key, or push authentication to get the MFA blessing. Windows and AAD together understand just a subset of that though.&lt;/p&gt;
&lt;p&gt;So back to the internal thread. Folks are working from home and need to RDP to their work machine from their home machine. The problem is that they're getting a bunch of MFA prompts on the remote machine whenever they do anything. What gives? They're using MFA, right?&lt;/p&gt;
&lt;p&gt;The problem was that MFA was being enforced outside of Windows, before RDP kicked off so the machine they were remoting in to only ever saw a password.&lt;/p&gt;
&lt;p&gt;But Steve, why weren't they using Windows Hello?? Well, because it was their home machine. You can't get an organization-stamped Windows Hello credential put onto your home machine. It just ain't working that way.&lt;/p&gt;
&lt;p&gt;So they connect to a service that prompts for MFA and gives you an RD Gateway that can forward your request to the internal machine. To be clear: this is a secure process. To get to the gateway you need to MFA, there's no two ways about it.&lt;/p&gt;
&lt;p&gt;But now that you've passed the MFA check you can securely use a password to RDP. Windows only ever sees the password, so AD never stamps your ticket with the certificate or Windows Hello SID (technically there is no SID for either, I'm glossing over part of this machinery).&lt;/p&gt;
&lt;p&gt;It's a hybrid joined device so it reaches out to AAD to get a PRT. This process also sees its just a password so it doesn't stamp the PRT with the MFA claim. Then you try and access a resource that enforces MFA, so AAD checks the PRT for the MFA claim and whoops no claim. Prompt.&lt;/p&gt;
&lt;p&gt;Ten minutes later you access another resource that enforces MFA, so AAD checks the PRT for the claim and whoops still no claim. Prompt.&lt;/p&gt;
&lt;p&gt;Repeat ad infinitum.&lt;/p&gt;
&lt;p&gt;This is why remote access is super difficult to get right, where you're balancing usability with security. Everything in the chain needs evidence the previous thing was authenticated to with MFA, otherwise everything further in the chain will prompt for it.&lt;/p&gt;
&lt;p&gt;Obviously the answer then is to make Windows understand all the things. Well, which things? Which protocols? Which standards? Which vendor extensions to protocols?&lt;/p&gt;
&lt;p&gt;Well, and then I guess make RDP understand them too. And all the RDP clients on Mac and Linux, and oh we have this HTML-based version too.&lt;/p&gt;
&lt;p&gt;It's hard work.&lt;/p&gt;
&lt;p&gt;So the goal then is to converge on only a couple standards and well known implementations and just try and get everyone to play nicely together. It's the only rational approach.&lt;/p&gt;
&lt;p&gt;All of this adds up to the question: how do you do remote desktop securely then?&lt;/p&gt;
&lt;p&gt;You need MFA, full stop. Protecting the gateway with MFA is a must. You need to also enforce MFA (or some derivative policy) on all the services you use.&lt;/p&gt;
&lt;p&gt;At that point you need to ask if being inundated with MFA prompts is a great user experience or if its leads to prompt blindness?&lt;/p&gt;
&lt;p&gt;You can solve that by transferring the MFA state from the client to the target machine by using a strong credential like smart card or Windows Hello.&lt;/p&gt;
&lt;p&gt;Windows Hello is amazing technology that folks love to use and works beautifully on work machines connecting to work machines. But it's not suitable when you're on your home machine. Smart cards work great though.&lt;/p&gt;
&lt;p&gt;FIDO is an amazing technology and it solves so many problems, but its not quite ready for RDP yet. We'll get there.&lt;/p&gt;
&lt;p&gt;Anyway, remote access is hard. I have no other closing thought. Good luck.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Authentication</category>
  <category>Security</category>
  <category>Windows</category>
  <category>Featured</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/mfa-is-hard-to-do-right</guid>
  <pubDate>Fri, 07 May 2021 21:38:00 GMT</pubDate>
</item>
<item>
  <title>Killing NTLM is Hard</title>
  <link>https://syfuhs.net/killing-ntlm-is-hard</link>
  <description>&lt;p&gt;&lt;strong&gt;EDIT 2: &lt;/strong&gt;Oh hey, &lt;a title="Goodbye NTLM" href="https://aka.ms/ntlm"&gt;we announced our strategy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT: &lt;/strong&gt;Good news. &lt;a href="https://syfuhs.net/deprecating-ntlm-is-easy-and-other-lies-we-tell-ourselves"&gt;Deprecating NTLM is Easy and Other Lies We Tell Ourselves (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So I joked earlier today that the reason we can't kill NTLM is because folks turn off telemetry. That's false.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Mostly.&lt;/p&gt;
&lt;p&gt;Here's why.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1390007473260535812?ref_src=twsrc%5Etfw"&gt;May 5, 2021&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There's one sure-fire way to kill NTLM: switch to Kerberos or similar modern authentication protocol. Alright, done and done -- what more is there? Well, like all things its never that easy. If it were that easy we'd have solved this 15 years ago.&lt;/p&gt;
&lt;p&gt;That's because NTLM is both a blessing and a burden. It has some properties that modern protocols don't. Namely that it doesn't require line of sight to a domain controller and that it doesn't enforce server authentication. Can you guess which bit is great and which is terrible?&lt;/p&gt;
&lt;p&gt;Line of sight is maybe relatively straightforward to understand. In Kerberos world the client (you) need to speak to a domain controller to get a ticket before you're allowed to access a resource. This sucks majorly when you're outside the boundaries of your network.&lt;/p&gt;
&lt;p&gt;Therefore that means you need to set up a VPN or KDC Proxy or some such thing. But that's a chicken and egg problem: to connect to VPN you need to authenticate, to authenticate you need to connect to the DC, to connect to the DC you need...line of sight. Doh!&lt;/p&gt;
&lt;p&gt;NTLM doesn't have that problem. You authenticate to the service in question and that service fires the request to the DC. The service is usually in a fixed location so enforcing line of sight there is usually quite easy.&lt;/p&gt;
&lt;p&gt;This is why RDP with NLA works from outside the network. You're not doing Kerberos anymore, instead you're doing NTLM, where the client is firing the NTLM request to the target directly, and the target is forwarding it off to the DC.&lt;/p&gt;
&lt;p&gt;Fundamentally NTLM gets the same information as if you're doing Kerberos. Kerberos just bundles everything up ahead of time, where NTLM needs to go off and get it every time.&lt;/p&gt;
&lt;p&gt;So what's the big deal?&lt;/p&gt;
&lt;p&gt;Property 2: NTLM doesn't do server auth.&lt;/p&gt;
&lt;p&gt;Server auth is fundamentally just the idea that you can [somehow] guarantee the server you're communicating with is in fact the server you want to communicate with.&lt;/p&gt;
&lt;p&gt;As authentication protocols go, not supporting server auth sucks majorly.&lt;/p&gt;
&lt;p&gt;The reason for that is because you just fired a credential-thingy to a server that says its the server you want to talk to, but you can't really verify that at all. What's to stop that server from forwarding it off to the real server and pretending to do evil things as you?&lt;/p&gt;
&lt;p&gt;This has made the news recently as a new form of attack. It's not particularly new: NTLM has never supported server auth. The flaw here is really just that things are using NTLM when they shouldn't.&lt;/p&gt;
&lt;p&gt;And why are things using NTLM when they shouldn't? Well, for the two properties I just described.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. If a client doesn't have line of sight to a DC it can't do Kerberos, so it falls back to NTLM.&lt;/p&gt;
&lt;p&gt;2. Server auth is forcing a downgrade to NTLM.&lt;/p&gt;
&lt;p&gt;Wait, isn't that bad? Why would a server downgrade?&lt;/p&gt;
&lt;p&gt;Well, it's not the server doing it. It's the client or DC doing it, because they can't guarantee server auth.&lt;/p&gt;
&lt;p&gt;See, the guarantee of server auth is by virtue of a trusted third party saying 'yeeeeep, I vouch that server has the same name as the one you requested'. Kerberos does this with SPNs.&lt;/p&gt;
&lt;p&gt;When you ask for a ticket to a service you use the SPN to identify it. The DC looks up the SPN and gives you a ticket to it. If that ticket can be decrypted by the server, then the DC has proven the server is who they say they are. &lt;a href="https://syfuhs.net/a-bit-about-kerberos"&gt;Kerberos Explained in a Little Too Much Detail (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;TLS does this through certificates. The server presents a certificate containing domain names. If the domain name you're contacting the server by is in the list, then you can reasonably say the CA that issued to certificate guarantees that server is who they say they are.&lt;/p&gt;
&lt;p&gt;So what happens if the SPN isn't found, or the domain name isn't in the certificate? Well, server authentication CANNOT succeed.&lt;/p&gt;
&lt;p&gt;In the TLS case this is catastrophic. It's like always clicking the "yes I know this is dangerous and stupid" button in your browser when you get a cert warning. It means you have no root of trust, so there are zero guarantees of privacy of information passed in the TLS channel.&lt;/p&gt;
&lt;p&gt;NTLM can be similarly catastrophic, but in different ways. NTLM, much like Kerberos, can be used to authenticate clients, or to optionally provide a secure channel for communications similar to TLS.&lt;/p&gt;
&lt;p&gt;The way this works is basically that either protocol will produce a session key that both the client and server know, that can be used for encrypting traffic between the two. This is how protocols like RPC or SMB work.&lt;/p&gt;
&lt;p&gt;Other protocols like HTTP don't need NTLM or Kerberos to provide a secure channel because HTTP can rely on TLS to do that. So NTLM is only used for authenticating the user.&lt;/p&gt;
&lt;p&gt;So therefore in the NTLM via HTTP over TLS case, you have some measure of server authentication through TLS. Not quite the end of the world.&lt;/p&gt;
&lt;p&gt;So if Kerberos can't happen for whatever reason, then the client will fall back to NTLM.&lt;/p&gt;
&lt;p&gt;This is the crux of the problem. If server auth fails then you must fall back to a protocol that doesn't do server auth. You can replace the protocol with something that does do server auth, but suddenly you're back to the original problem: server auth *already* failed.&lt;/p&gt;
&lt;p&gt;This is why killing NTLM is so hard. We can replace the protocol with something better, but that something is starting it's life right out the gate fighting with basic fundamentals.&lt;/p&gt;
&lt;p&gt;This is also why the approach to date has been more about remediating scenarios that are falling back to NTLM vs replacing NTLM outright: replacing it outright doesn't necessarily buy us anything.&lt;/p&gt;
&lt;p&gt;Alternatively we can just turn it off. That actually just makes things worse.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Obviously security is important, but continuity of business is important-er. Turning off business critical services is a dangerous game.&lt;/p&gt;
&lt;p&gt;So the path forward is through information gathering. You need to know what's doing NTLM, and you need to know why it's doing it. There's an audit policy for that: &lt;a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/network-security-restrict-ntlm-audit-incoming-ntlm-traffic"&gt;Network security Restrict NTLM Audit incoming NTLM traffic (Windows 10) - Windows security | Microsoft Docs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Which brings us to the original joke: we can't deprecate NTLM because folks don't turn on telemetry.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That's false. We have ways of doing it, but it doesn't necessarily buy us much.&lt;/p&gt;
&lt;p&gt;What telemetry does tell us though is *when* we can turn it off.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Authentication</category>
  <category>Twitter Thread</category>
  <category>Security</category>
  <category>Featured</category>
  <guid isPermaLink="false">https://syfuhs.net/killing-ntlm-is-hard</guid>
  <pubDate>Wed, 05 May 2021 18:49:00 GMT</pubDate>
</item>
<item>
  <title>Lessons in Disabling RC4 in Active Directory</title>
  <link>https://syfuhs.net/lessons-in-disabling-rc4-in-active-directory</link>
  <description>&lt;p&gt;Was pulled in to a fun customer issue last Friday around disabling RC4 in Active Directory. What happened was, as you can imagine, not good: RC4 was disabled and half their environment promptly started having a Very Bad Day.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1366526316397301761?ref_src=twsrc%5Etfw"&gt;March 1, 2021&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&amp;nbsp;&lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;RC4 is a stream cipher. A stream cipher is kinda sorta like a one time pad (note: kinda, and sorta). A one-time pad is a cryptographic operation that takes one value and XORs it against a random value. A^B = C. A is your data, B is random noise. C is your encrypted cipher.&lt;/p&gt;
&lt;p&gt;They're incredibly useful because the XOR operation is only reversible when you know A or B, and if B is suitably random that means you have to guess for all combinations of B. In other words you have to brute force it. As far as cryptography goes that's nearly perfection.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F3%2FEvbcZfVVkAMDSrh.jpg" alt="RC4 is broken" width="691" height="1203" /&gt;&lt;/p&gt;
&lt;p&gt;However, the trick with one-time pads is that you need as many random bits as you have data. If you have 10 data you need 10 random. If you 10k data you need 10k random. You cannot repeat the random, lest you introduce a pattern and code breakers just love patterns.&lt;/p&gt;
&lt;p&gt;So a stream cipher could take a one-time pad and cut the key down to a fixed length, manipulating the key every operation. Let's say you have 100 data and 10 random. The first 10 data get XOR'ed to the 10 random, then the 10 random get XOR'ed to something else. Repeat 10 times.&lt;/p&gt;
&lt;p&gt;This turns out to be incredibly simple to code and is incredibly fast relative to other crypto algorithms. However, the cost is that you're now doing key scheduling which means if you can predict the schedule you've broken the cipher.&lt;/p&gt;
&lt;p&gt;RC4 fits the bill here. It's painfully simple to implement. Here it is in entirety. But it's also irreparably broken.&lt;/p&gt;
&lt;p&gt;The thing with RC4 is that if you have enough data transformed by a single key you can eventually predict what the original plaintext is. This became a semi-practical attack in 2013 when some smart folks figured out how to apply this to TLS. &lt;a href="https://isg.rhul.ac.uk/tls/"&gt;https://isg.rhul.ac.uk/tls/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For this attack to happen it requires observing billions of bytes of data. This is done easily enough with TLS, hence why folks jumped at disabling RC4 cipher suites. TLS isn't the only place RC4 is used, and RC4 is still broken, so it's just good form to disable it everywhere.&lt;/p&gt;
&lt;p&gt;So now we have Active Directory and RC4 is enabled by default. In 2021?! How dare. Weeeeeelllll, RC4 isn't quite that bad in this case. Like, it's bad, but not super bad because each key will only ever be used for encrypting small amounts of data.&lt;/p&gt;
&lt;p&gt;The current attacks require observing *lots* of data encrypted with a single RC4 key. For Kerberos we're talking maybe 8-16kb at most, not the gigabytes required for the attack. So it's bad, but not end of the world bad.&lt;/p&gt;
&lt;p&gt;But that's no excuse. Why is it still there? Well, it turns out the RC4 cipher suite has a unique property: it doesn't require a salt when doing key agreement.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Huh?&lt;/p&gt;
&lt;p&gt;So Kerberos has two legs between a client and KDC. AS and TGS.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;AS is how you authenticate yourself: here's password gimme krbtgt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;TGS is: here's krbtgt gimme service ticket.&lt;/p&gt;
&lt;p&gt;Now we don't ever just send the password to the server. What we do is we encrypt a thing using the password as a key and fire that thing over to the server. The server also has your password and can decrypt. If it decrypts then we agree we both know the password.&lt;/p&gt;
&lt;p&gt;But Active Directory doesn't store the password itself. It stores a key derived from the password. That is, take the password and hash it, and store that hashed value. You encrypt against this hashed value.&lt;/p&gt;
&lt;p&gt;So lets go back in time, circa mid 90's when Active Directory was being built. Back then, in the real world, Windows authentication was NTLM. NTLM kinda sorta worked similarly where you derived a key from a password and used that key to sign some stuff.&lt;/p&gt;
&lt;p&gt;That derivation was and is admittedly very lame. It's &lt;code&gt;md4(password)&lt;/code&gt;. So in NT Server in the directory database was username + md4(password), and that's it.&lt;/p&gt;
&lt;p&gt;And taking the cryptographic properties of NTLM out the picture for a moment, it still kinda sucked as an authentication protocol. It didn't offer server authentication and it wasn't easily extendable for future changes. So Active Directory switched to Kerberos.&lt;/p&gt;
&lt;p&gt;But we wanted upgrades to be seamless. When you left work Friday afternoon logging in to NT and came back Monday morning we wanted you to be able to log in to AD without any fuss, despite the fact that we changed literally everything out from under you.&lt;/p&gt;
&lt;p&gt;And Kerberos at the time was using DES (eww). This posed a problem. You can't transform an MD4 key into a DES key. The protocol certainly didn't let you do weird things like DES(MD4(password)), so Windows created the MD4+RC4 crypto system.&lt;/p&gt;
&lt;p&gt;The magic of this is that the NTLM key and Kerberos key are interchangeable so no password changes were required. Over time as users changed their passwords Active Directory would derive these newer, stronger, keys and would inform clients to prioritize these stronger keys.&lt;/p&gt;
&lt;p&gt;This turns out to be phenomenally powerful because it transparently migrates users to stronger keys without breaking anyone, at a small cost of delaying weeks or months as password changes occur. Is it perfect? No. Does it keep the masses happy? Yes.&lt;/p&gt;
&lt;p&gt;But there's another small problem: salts. Salts add randomness to passwords, making their hashed form incomparable to other hashes. hash('password', salt1) &amp;lt;&amp;gt; hash('password', salt2). We do this for all sorts of reasons, but the primary is so it's harder to guess the password.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This lack of salt and the use of MD4 for password to key derivation is what makes the RC4 cipher suite in Kerberos dangerous. The RC4 portion itself is kinda meh in the overall scheme of things.&lt;/p&gt;
&lt;p&gt;This is because MD4 itself is a pretty lousy hash algorithm, and it's easier to guess the original password when compared to the AES ciphers. Passwords that are longer than 12 characters are generally safe from these kinds of attacks. I go into detail in &lt;a href="https://syfuhs.net/protecting-against-credential-theft-in-windows"&gt;Protecting Against Credential Theft in Windows&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;But salts complicate the protocol. Both client and KDC need to take the password and salt and derive the same key, so both need to know them. Seems simple enough? Just use a well known value...?&lt;/p&gt;
&lt;p&gt;Ah no, they need to be unique, otherwise two identical passwords with the same salt will form the same hash. Oops. Okay, compute a salt from the username. Aha, here we go, this works. It's unique and both parties know it. And it doesn't change! Oh wait, it can.&lt;/p&gt;
&lt;p&gt;Users change their usernames all the time because names change all the time. If the salt were just the username that means we'd have to recompute the hash in AD every time the username changed, which means we'd need to know the password and only admins change usernames so 🤔.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F3%2FEvbpCjIVcAEjMED.jpg" alt="AS-REP Ping response" width="457" height="387" /&gt;&lt;/p&gt;
&lt;p&gt;Okay, so what if the KDC only changes the salt on password change and just tells us what it is whenever we authenticate? And so this is how Kerberos works. The client "pings" (no not ICMP) the KDC and the KDC says here ya go.&lt;/p&gt;
&lt;p&gt;And so long story short (hahahaha, oh.) we come to the customer issue. RC4 doesn't require a salt. AES requires a salt. You can see in the previous screenshot the ARCFOUR instance doesn't provide a salt because there just isn't one.&lt;/p&gt;
&lt;p&gt;If you use RC4 you don't need to ping the KDC. You can just derive the key from the password and go. Therefore if you disable RC4 conversely you must always know the salt.&lt;/p&gt;
&lt;p&gt;This poses a small challenge. Sometimes you don't want the system to know the password itself, so you provide these things called keytabs. They're files with some structured data that map users to derived keys. You derive the keys upfront once so you only need the password once.&lt;/p&gt;
&lt;p&gt;Sometimes these files are generated without having line of sight to a KDC too so the tool generating the file has to guess which salt to use. Sometimes the tool guesses the wrong salt. Oops.&lt;/p&gt;
&lt;p&gt;So you generate these files and deploy the thing and the system chugs along just fine until you disable RC4 and the whole things comes crashing down. The system was using RC4, and RC4 worked because there wasn't a salt. When it switched to AES it required the salt and...oops.&lt;/p&gt;
&lt;p&gt;Well that's a pretty lame experience for anyone, let me tell you. Why did the tool guess the wrong salt? I've already told you: because the name changed.&lt;/p&gt;
&lt;p&gt;&lt;img style="text-align: center; float: left;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F3%2FEvbtgCeVEAgLAHT.jpg" alt="UPNs can change" width="416" height="563" /&gt;&lt;/p&gt;
&lt;p&gt;Active Directory lets you change your username. You actually have two different usernames. Your sAMAccountName and your UPN. You can use either to log in with Kerberos, but Active Directory will only derive your salt from a single value: the sAMAccountName + Realm.&lt;/p&gt;
&lt;p&gt;Well it happens that their UPN is in the form samaaccountname@customrealm.com, but their realm is anotherrealmentirely[.]com. As such their salt was ANOTHERREALMENTIRELY.COMsamaccountname. This happens when you add custom UPN suffixes.&lt;/p&gt;
&lt;p&gt;The password never changed so the salt never had a chance to change (not that it would). And the tool to generate the keytab just derived the salt from the user principal name, which in most cases is fine, but in this case wasn't.&lt;/p&gt;
&lt;p&gt;And so you might think to yourself that this isn't that big a deal you haven't ever changed the usernames or the suffixes or anything like that. It turns out there's exactly one scenario that every environment hits: when you promote the first DC in a forest.&lt;/p&gt;
&lt;p&gt;When you create a forest the domain admin is the machine's local administrator account. I'm not talking implicitly, I'm talking the local admin is copied into the AD database including it's password. The password that was set when you built the machine, before it had a realm.&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration: line-through;"&gt;And the domain admin is part of the protected users group so RC4 is already disabled for them.&lt;/span&gt; If the admin is a member of the Protected Users group, that means RC4 is disabled for them, and that then means they MUST use AES, which means they MUST use a salt, which means the salt had to exist when the machine was first built. Oy.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So the realm is the computer name.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F3%2FEvcBd4FVoAQ6NhK.jpg" alt="The realm is the computer" width="945" height="414" /&gt;&lt;/p&gt;
&lt;p&gt;Anyway. Here's some useful links as you consider getting rid of RC4.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://techcommunity.microsoft.com/t5/itops-talk-blog/tough-questions-answered-can-i-disable-rc4-etype-for-kerberos-on/ba-p/382718"&gt;Tough Questions Answered: Can I disable RC4 Etype for Kerberos on Windows 10 ? (microsoft.com)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/decrypting-the-selection-of-supported-kerberos-encryption-types/ba-p/1628797"&gt;Decrypting the Selection of Supported Kerberos Encryption Types - Microsoft Tech Community&lt;/a&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Active Directory</category>
  <category>Kerberos</category>
  <category>Security</category>
  <category>Featured</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/lessons-in-disabling-rc4-in-active-directory</guid>
  <pubDate>Tue, 02 Mar 2021 00:33:00 GMT</pubDate>
</item>
<item>
  <title>Protecting Against Credential Theft in Windows</title>
  <link>https://syfuhs.net/protecting-against-credential-theft-in-windows</link>
  <description>&lt;p dir="ltr" lang="en"&gt;Have you ever thought to yourself "boy, I sure wish I had to use passwords more often"? No, of course not. Passwords suck. Good passwords are long and hard to remember and easy to remember passwords aren't good. They're inherently portable and easy to steal.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1360335417740906498?ref_src=twsrc%5Etfw"&gt;February 12, 2021&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning: &lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We've known this a great many years and platforms like Active Directory and Windows have supported better options like smart cards for 20 years because of this. So what is it about passwords that make them so hard to protect?&lt;/p&gt;
&lt;p&gt;First of all, we need them to be random. Random means people can't guess them. Suppose I pick a simple 5 letter password from the lowercase alphabet. That's 26 letters and 5 positions, or 26^5, or ~11.8 million combinations.&lt;/p&gt;
&lt;p&gt;As a human it'll take you forever to guess it, but it'll take a computer less than a second to generate all 11.8 million combinations. But I'm also human so I'm going to pick something easy for me to remember: "riley". That's super easy to guess if you've looked me up.&lt;/p&gt;
&lt;p&gt;So we start to enforce strength requirements: must be 8 characters with uppercase, lowercase, numbers, symbols, one reoccurring character from season 6 of your favorite TV show. This gives you (say) 92 characters and 8 positions or 92^8 or 5132 trillion combinations.&lt;/p&gt;
&lt;p&gt;So my password is now aSdX3$CC;^k@. I can barely remember what I had for lunch yesterday, am I expected to remember this? Oh, and I have to change it every 90 days? Ugggggh.&lt;/p&gt;
&lt;p&gt;But it turns out this is equally easy for a computer to guess anyway, so. 🤔&lt;/p&gt;
&lt;blockquote class="twitter-tweet"&gt;
&lt;p dir="ltr" lang="en"&gt;Ever wondered what a &lt;a href="https://twitter.com/hashtag/hashstack?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#hashstack&lt;/a&gt; &lt;a href="https://twitter.com/hashcat?ref_src=twsrc%5Etfw"&gt;@hashcat&lt;/a&gt; cluster of 448x RTX 2080s could do for &lt;a href="https://twitter.com/hashtag/password?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#password&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/cracking?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#cracking&lt;/a&gt;? How about 31.8 TH/s on NTLM, 17.7 TH/s on MD5 &lt;a href="https://t.co/k9DmxSULBz"&gt;pic.twitter.com/k9DmxSULBz&lt;/a&gt;&lt;/p&gt;
&lt;p dir="ltr" lang="en"&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEAfIvuXXoAE64PM.jpg" alt="Password Cracking Can be Quick" width="1166" height="729" /&gt;&lt;/p&gt;
&amp;mdash; Terahash (@TerahashCorp) &lt;a href="https://twitter.com/TerahashCorp/status/1155112559206383616?ref_src=twsrc%5Etfw"&gt;July 27, 2019&lt;/a&gt;&lt;/blockquote&gt;
&lt;p&gt;Of course, suppose you don't have $30k to drop on a password cracking rig and you don't have benefactors that will donate to the cause, brute-forcing your way through is out of the question. So you attack the next best thing: Windows.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDbkVYVkAIf6Tm.jpg" alt="Swiss Cheese Model" width="680" height="383" /&gt;&lt;/p&gt;
&lt;p&gt;To attack Windows you have to understand how authentication works in Windows. In simple terms you have a high value credential (password) which you exchange for a medium value credential (TGT/PRT), that is exchanged for low value credentials (service tickets/access tokens).&lt;/p&gt;
&lt;p&gt;You can think of them as first order, which derives a second order, which then derives a third order credential, all with decreasing capabilities as you go further out. This is sort of the mantra for solutions like Credential Guard: protect the first and second order credentials.&lt;/p&gt;
&lt;p&gt;That's all well and good however technologies like Credential Guard serve very specific and well defined purposes and aren't holistic catch-all solutions.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is important: there's never a one-size-fits-all solution to security.&lt;/p&gt;
&lt;p&gt;Securing complex systems like Windows, or your enterprise network, requires many layers. It's like the swiss cheese analogy for stopping the spread of COVID-19. Layer one stops something very specific. Layer two stops another thing, layer three... etc.&lt;/p&gt;
&lt;p&gt;So Credential Guard protects your 1st and second order credentials at rest *once* they've entered the system. To understand why this matters it's important to go back to how credentials are processed by Windows.&lt;/p&gt;
&lt;p&gt;Passwords enter your computer through credential providers, into LSA, and processed by AD or AAD. I've explained this in great detail in both text and video form. &lt;a href="https://syfuhs.net/what-happens-when-you-type-your-password-into-windows"&gt;What Happens When you Type Your Password into Windows? (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cred provs do their thing and pass it off to LSA.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDcu-rVoAIB5y8.jpg" alt="Logon UI Process" width="883" height="263" /&gt;&lt;/p&gt;
&lt;p&gt;LSA does a cached logon.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDdAepUcAUacbQ.jpg" alt="LSA Cached Logon" width="884" height="374" /&gt;&lt;/p&gt;
&lt;p&gt;You're taken to your desktop.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDdGPQVIAAv0S7.jpg" alt="Your Desktop" width="884" height="334" /&gt;&lt;/p&gt;
&lt;p&gt;And THEN off you go to Active Directory or AAD.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDdLnRVoAIweMA.jpg" alt="Off to AD or AAD" width="884" height="301" /&gt;&lt;/p&gt;
&lt;p&gt;But this is all very hand-wavy. Along the way there are built-in extensibility points where third parties can add in their own code to make the login work however they need it to, because sometimes that's just how things be.&lt;/p&gt;
&lt;p&gt;You can drop in your own credential provider that looks just like the password credprov. You can install a custom LSA authentication package that listens for passwords. Or you can install a subauth module and log the password.&lt;/p&gt;
&lt;p&gt;But we have solutions for that. LSA Protected Process mode is one. It prevents anyone from loading third party code into LSA so they can't touch those extensibility points. But you can bypass LSAPPL -- so we have HVCI to enforce it. Lots of solutions here.&lt;/p&gt;
&lt;p&gt;But there's more to this. Your password doesn't magically go from your keyboard to the credprov. It gets converted to electrical signals and sent along a wire into your computer to be processed by the CPU in a driver in the kernel and then converted back to text.&lt;/p&gt;
&lt;p&gt;[page-break]&lt;/p&gt;
&lt;p&gt;So now you have to worry about hardware keyloggers snooping the wire. Or kernel-mode keyloggers listening to the drivers. The latter is easier to handle: limit what kinds of drivers can be installed through something like Windows Defender Application Control. The former though?&lt;/p&gt;
&lt;p&gt;Not a lot you can do to protect from hardware keyloggers. To truly protect this whole stack you need dedicated hardware that guarantees nothing is listening to the electrical signals. That's hard even with specialized hardware. It's impossible for general purpose systems.&lt;/p&gt;
&lt;p&gt;All of this adds up to a particularly complicated mess that is hard to fit into your head and harder to defend. Surely there are better options here?&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDnqXaUcAE2XZf.jpg" alt="Smart card form factors" width="516" height="688" /&gt;&lt;/p&gt;
&lt;p&gt;This is why we've been pushing passwordless. Sure, it's partly a marketing thing, but it's also a line in the sand. Passwords just genuinely suck. We can do better and we want to do better.&lt;/p&gt;
&lt;p&gt;So we have smart cards. These were our first go at passwordless 20 years ago. They are more secure than passwords for a few good reasons...&lt;/p&gt;
&lt;p&gt;First, they rely on asymmetric crypto (passwords = symmetric), which means you split the key into two separate pieces: a secret (private) key and a public key. You can share the public key with anyone, but you keep the private key to yourself.&lt;/p&gt;
&lt;p&gt;To authenticate the user you ask them to perform an operation that only the holder of the private key can perform, which is then verified against the public portion.&lt;/p&gt;
&lt;p&gt;This turns out to be an incredibly useful property. With smart cards you can store the private key in a tiny integrated circuit embedded into a piece of plastic. When you need to authenticate you plug it in to a reader which lets the computer ask the IC to perform operations.&lt;/p&gt;
&lt;p&gt;This makes the key portable and also prevents you from copying the key off the IC, since the IC is hardened to protect against that sort of thing (in theory).&lt;/p&gt;
&lt;p&gt;There's an obvious problem here: anyone can steal the card and use it. So we introduce PINs that unlock the card. You type a PIN into your computer, which is sent to the card and if it's correct that tells the card that it's safe to perform the requested operation.&lt;/p&gt;
&lt;p&gt;So smart cards for everyone!! Except, they didn't really take off. Why? Well, a few reasons.&lt;/p&gt;
&lt;p&gt;They require dedicated readers.&lt;br /&gt;They're expensive to manufacture.&lt;br /&gt;They're easy to lose.&lt;br /&gt;They're easy to break.&lt;br /&gt;The standards bodies were...insane.&lt;/p&gt;
&lt;p&gt;Over time these issues were overcome. We got better form factors, the manufacturing costs went down, the standards bodies mostly came to their senses.&lt;/p&gt;
&lt;p&gt;Alas, the standards still kind of aren't great and making changes to them is hard to do.&lt;/p&gt;
&lt;p&gt;But there's also another more insidious problem with them in that we're back to typing secrets (your PIN) into a keyboard that translates into electrical signals across a wire into the kernel and&lt;/p&gt;
&lt;p&gt;Always evolving we built Windows Hello. The simplest way to describe Windows Hello is you take a smart card and embed it into your computer. We store you private key on your hard drive, encrypted to a key derived from your TPM and something else.&lt;/p&gt;
&lt;p&gt;When you want to use this private key to perform an operation, say to log in, you take that "something else", combine it with the TPM and out comes your private key. That "something else" could be a PIN you type in, or a biometric template from your face or fingerprint.&lt;/p&gt;
&lt;p&gt;This solves so many fundamental problems with smart cards.&lt;/p&gt;
&lt;p&gt;Nothing to physically lose.&lt;br /&gt;Nothing to break.&lt;br /&gt;Doesn't require a dedicated reader (ish).&lt;br /&gt;Manufacturing costs are low(er).&lt;br /&gt;Infinitely easier to use.&lt;/p&gt;
&lt;p&gt;But there are tradeoffs. The credential isn't portable anymore. This is a positive and a negative. On the one hand you can't steal the private key and use it elsewhere. On the other hand you have to register yourself on every machine you use.&lt;/p&gt;
&lt;p&gt;The cryptographic operations occur in the OS. Therefore you can snoop on the "something else" path and collect the PIN or parts of the biometric template. In a theoretical sense that's potentially very bad. Way way way waaaaay harder to attack than passwords, but still.&lt;/p&gt;
&lt;p&gt;This was solved through some serious collaboration between hardware vendors and Windows folks and culminated in something called Windows Hello Enhanced Sign-in Security. &lt;a href="https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/windows-hello-enhanced-sign-in-security"&gt;Windows Hello Enhanced Sign-in Security | Microsoft Docs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The gist of this is relatively simple: move all the important security (crypto) operations that occur in the normal world OS into VSM. Easy, right? Well no. This was a hard problem to solve. 😂&lt;/p&gt;
&lt;p&gt;But now it's incredibly difficult to snoop any data between the hardware sensors through the kernel to VSM and back into LSA. There are no extensibility points that let you touch the raw creds. Now that first order high value cred is seriously protected.&lt;/p&gt;
&lt;p&gt;Combine it with Credential Guard and now all you're left with is low value credentials. Not bad.&lt;/p&gt;
&lt;p&gt;But we're back to the problem of portability. You need to register the credentials on each machine you use. To register credentials you need another high value credential AND you need MFA.&lt;/p&gt;
&lt;p&gt;Did I mention that smart cards and Windows Hello are MFA? They are. They're something you have (card or PC) and something you know or are (PIN or face/fingerprint). You're not going to get a super-high value credential out of just a password, so you need to go the extra step.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2F2%2FEuDxETkUUAQsM1i.jpg" alt="FIDO keys" width="539" height="718" /&gt;&lt;/p&gt;
&lt;p&gt;Some folks don't like to recognize Windows Hello as MFA. They're wrong, it is MFA. However, it may not fit their requirements *for* MFA creds because you require separation of the credentials from the machine. Sure, that's fine.&lt;/p&gt;
&lt;p&gt;So portability is critical here. Which is why we have this thing called FIDO. It's an industry consortium and set of standards that allow different parties to agree on the form of credentials used as well as their relative security worthiness or credibility.&lt;/p&gt;
&lt;p&gt;The net product is this security key, which is kinda sorta like a smart card in that is stores a private key, and you have to unlock it before you can ask it to perform operations against that key.&lt;/p&gt;
&lt;p&gt;What makes it special and better than smart cards is the implementation. The protocol is simpler, the metadata is structured for specific scenarios (SCs are generic and require things called middleware to interpret functions), and you can store many identities on a single key.&lt;/p&gt;
&lt;p&gt;But most importantly the ability to unlock the key has multiple predefined mechanisms. You can use a PIN typed into your computer, or you can use a key-specific mechanism like using a fingerprint reader built into the key. Getting that to work with smart cards is...non-standard.&lt;/p&gt;
&lt;p&gt;Actually, another important thing is that these keys are rated for security levels and those levels are imprinted on the authentication. With a smart card all the party knows is a certificate was used. With FIDO you know a hardware key certified to a certain level was used.&lt;/p&gt;
&lt;p&gt;AND ANOTHER THING... smart cards expose certificates, which can be used for any number things (a good thing for sure), whereas FIDO exposes specific authentication protocols. When I log into a website with a smart card I'm using TLS client cert auth. FIDO is higher in the stack.&lt;/p&gt;
&lt;p&gt;Plugging into the TLS transport stack is expensive and complicated and potentially leads to uuuuugly vulnerabilities. Moving the authentication to the application layer is architecturally more sound. It's safer and easier to implement.&lt;/p&gt;
&lt;p&gt;Dangit, and another thing! FIDO isn't just about external keys. It's about abstracting away authentication methods. With FIDO and webauthn you can log into a website with your security key or with Windows Hello. Windows Hello IS a FIDO and webauthn key.&lt;/p&gt;
&lt;p&gt;I guess I went off on a tangent there. Anyway...&lt;/p&gt;
&lt;p&gt;So you see why passwords are pretty lousy, and why we don't think they should be the predominant method of authenticating people. /fin&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Authentication</category>
  <category>Credential Guard</category>
  <category>Featured</category>
  <category>Windows</category>
  <category>Credential Theft</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/protecting-against-credential-theft-in-windows</guid>
  <pubDate>Fri, 12 Feb 2021 22:43:00 GMT</pubDate>
</item>
<item>
  <title>How Managed Service Accounts in Active Directory Work</title>
  <link>https://syfuhs.net/how-managed-service-accounts-in-active-directory-work</link>
  <description>&lt;p dir="ltr" lang="en"&gt;Have you ever heard of these things called Managed Service Accounts? They allow you to run programs as an account that doesn't require a password while still having the security of a strong password. They're pretty neat. &lt;a href="https://t.co/p7nfDnyUqp"&gt;pic.twitter.com/p7nfDnyUqp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1357419082413264902?ref_src=twsrc%5Etfw"&gt;February 4, 2021&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&lt;/strong&gt; Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEtaAiQuVEAALiNd_637480705207055399.png" alt="A gMSA in Active Directory" width="254" height="358" /&gt;&lt;/p&gt;
&lt;p&gt;To be more precise, it's not that they don't have passwords, it's that they don't require you the administrator to know the password. The password is managed by Active Directory for you. That means not worrying about weak passwords or having to manually rotate them. Neat, right?&lt;/p&gt;
&lt;p&gt;These are also just regular accounts in AD. They're special in that they're managed, but under the covers they're computer accounts, which inherit from user accounts. They walk and talk like principals in AD, so they have usernames, credentials, and service principal names.&lt;/p&gt;
&lt;p&gt;This therefore means they can log in to Active Directory through Kerberos and NTLM. That makes them perfect for hosting services and tasks that require authenticating users or operating in authenticated sessions.&lt;/p&gt;
&lt;p&gt;Which is great, but how do they work? How does Windows know how to use them and how can this be done securely since no one knows the password?&lt;/p&gt;
&lt;p&gt;Well, it turns out it's partly super simple, and partly super complicated. The super simple part is that when you create a managed account you specify what other accounts are allowed to see the password. &lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEtaGE7MVEAAkSo8_637480705833363861.png" alt="Creating a gMSA in PowerShell" width="1239" height="558" /&gt;&lt;/p&gt;
&lt;p&gt;The things in PrincipalsAllowedToRetrieveManagedPassword can be computers, users, or groups. These things are put into an ACL on an AD LDAP attribute of the (g)MSA that say if you present a SID in this list you can query this attribute.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Add-KdsRootKey -EffectiveTime ((get-date).addhours(-10))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;New-ADServiceAccount gmsa1 -DNSHostName gmsa1.corp.identityintervention.com `&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp;-PrincipalsAllowedToRetrieveManagedPassword djpp$ `&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp;-KerberosEncryptionType RC4, AES128, AES256&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$gmsa = Get-ADServiceAccount -Identity 'gmsa1'-Properties 'msDS-ManagedPassword'&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;($gmsa.'msDS-ManagedPassword'|ForEach-Object ToString X2) -join ' '&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So when something needs to log in as that user it can query the LDAP attribute and get the password. Easy! ...ish. Well, not so easy. The value in this attribute is...&lt;a title="MSDS-MANAGEDPASSWORD_BLOB -- oy" href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/a9019740-3d73-46ef-a9ae-3ea8eb86ac2e" target="_blank" rel="noopener"&gt;complicated&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEtaHmVCUcAAchi-_637480735819097341.png" alt="The password data structure" width="555" height="391" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEtaIoyeUYAAXtNo_637480706395434849.png" alt="Configuring a service to run as a gMSA" width="414" height="483" /&gt;&lt;/p&gt;
&lt;p&gt;"But Steve" you say "the whole point of a managed service account is that you don't need to know the password. How does Windows know to get this password?"&lt;/p&gt;
&lt;p&gt;That's a great question, wish I thought of it myself. The answer is actually a little silly.&lt;/p&gt;
&lt;p&gt;Windows doesn't actually know it's dealing with a managed account. The administrator configured [whatever thing] to log on as an account, and left the password blank.&lt;/p&gt;
&lt;p&gt;There's no rule that says ALL USERS MUST HAVE A PASSWORD. Windows allows users to not have passwords. Active Directory even lets you not have passwords (PSA: FOR THE LOVE OF ALL THINGS HOLY DON'T ALLOW THIS PLEASE).&lt;/p&gt;
&lt;p&gt;So back to the question: how? Well, it turns out Windows just accepts that this might be a (g)MSA so during a logon call it opens a connection to AD and asks for the the password in the msDS-ManagedPassword attribute.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;PS C:\Windows\system32&amp;gt; $gmsa = Get-ADServiceAccount -Identity 'gmsa1'-Properties 'msDS-ManagedPassword'&lt;/code&gt;&lt;br /&gt;&lt;code&gt;PS C:\Windows\system32&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;PS C:\Windows\system32&amp;gt; ($gmsa.'msDS-ManagedPassword'|ForEach-Object ToString X2) -join ' '&lt;/code&gt;&lt;br /&gt;&lt;code&gt;01 00 00 00 22 01 00 00 10 00 00 00 12 01 1A 01 34 47 EB 28 EE C4 F4 2E 0D E9 83 3E F3 5C 05 58 EA E5 3E 7D C7 BB 3F F1 28 AA 49 84 51 46 DF 8A CF 33 34 83 10 7A 94 BC FB A2 11 27 8E 31 B7 70 C1 D7 7D CA 8D 33 6F 7D 07 33 7E 69 64 05 24 8F 57 2B A5 AA 74 4E 86 03 30 E1 A7 19 69 1B 76 F7 63 60 43 DA 7C 8D 56 46 99 8A F1 1F A7 F1 ED 2B E9 8B 8F 51 FD 17 16 42 19 5C 10 DA D8 53 4B D1 76 9E 88 0F 1F C4 8F 54 E8 DE 8F E0 A5 F0 82 13 CA 89 33 D9 0A 5E 19 6E FA BE CD 50 33 82 A1 CE 9E FF 09 92 06 96 75 7E A5 B2 E6 FB 8B 7A 9A 75 61 DC 06 C4 80 49 33 9C CA B7 C5 A9 BF 36 72 FF A6 7F 31 C8 E4 74 3D C6 B6 2A BE 8A DD A7 41 42 DB 9E EE C1 BB 0A 9F 0F A0 F3 C2 6A 0E B8 FD 23 A7 7D C5 10 F6 4E 59 B4 CE 35 49 47 17 C0 C9 FD 6F E2 F1 77 DF 0A E6 93 1D 84 F3 3F 45 6A AB 42 54 49 3B DD 9F 9B E8 0D 4E CC 57 80 3E 56 BE C4 00 00 EB 66 BA 80 28 14 00 00 EB 08 EA CD 27 14 00 00&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now you're looking at this kinda funny thinking waaaaaait a minute how does this bullsh*t work? Well remember, computers have machine accounts in AD. The computer logs in to AD, gets a Kerberos ticket to the DC asking for this attribute and does an ACL check.&lt;/p&gt;
&lt;p&gt;Does principal djpp$ have a SID in their PAC that matches the ACL on the attribute? Yes? Here you go. It's plain old SSO. &lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So now the computer has the password (and a bunch of metadata from that attribute? Odd... 🤔). Windows takes that password and the username and...logs it on. Whoa. &lt;a href="https://syfuhs.net/what-happens-when-you-type-your-password-into-windows"&gt;What Happens When you Type Your Password into Windows? (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;P.S. another shameless plug: I did a video on how this works too. &lt;a href="https://syfuhs.net/ops108-windows-authentication-internals-in-a-hybrid-world"&gt;OPS108: Windows authentication internals in a hybrid world (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;At this point the account has logged on and has all the usual accoutrement of a logon session. Nothing special. Any application running as that user has the usual SSO. Incoming requests can be authenticated using Kerberos (assuming someone registered an SPN on the attribute).&lt;/p&gt;
&lt;p&gt;This is all well and good until the password expires. Wait what? Expires? Who expires it? When? What? Huh?&lt;/p&gt;
&lt;p&gt;So the funny thing about managed account passwords is that they aren't real. They aren't&amp;nbsp;&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;code&gt;pwd = unicode(rand(254))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;as many people might expect. They're derived secrets from a special root key.&lt;/p&gt;
&lt;p&gt;In Active Directory you have this thing called a Root Key. It's the base (root) of all derived secrets in a forest. You take this root, append a bunch of localized metadata, and out pops a derived key.&lt;/p&gt;
&lt;p&gt;This is incidentally how we can do things like group encryption with PFX files. Take the root key and append the group SID. Stand up a service in AD that accepts tickets, and if the requisite SID is in the PAC it'll provide the metadata to generate the same key and decrypt. Ish.&lt;/p&gt;
&lt;p&gt;That isn't exactly how that works. How it actually works is complicated and makes anyone that isn't a cryptographer cry.&lt;/p&gt;
&lt;p&gt;But back to managed accounts. The passwords are derived secrets computed from the root key and metadata. That metadata is basically accountKeyId + createdTime + interval. The interval and start time are critical. This allows the password to rotate regularly. Here's how it works.&lt;/p&gt;
&lt;p&gt;Your root is "abc" with an interval of 30 days.&lt;/p&gt;
&lt;p&gt;"abc" at 12:42 Feb 4 2021 = "aaa"&lt;br /&gt;"abc" at 12:42 Mar 6 2021 = "bbb"&lt;br /&gt;"abc" at 12:42 Apr 5 2021 = "ccc"&lt;/p&gt;
&lt;p&gt;Following? This means at any given time AD knows what the password should be, will be, and was. Since the metadata is included in the blob, Windows also knows the interval. It doesn't have the root key so it can't derive it, but it can refresh it on that interval.&lt;/p&gt;
&lt;p&gt;"But Steve" you say again "isn't that a bit overkill? It's just a password."&lt;/p&gt;
&lt;p&gt;It is. But stuff breaks when the password is wrong.&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEtaQ-N1UcAEaF88_637480712571624983.jpg" alt="This is bad" width="497" height="372" /&gt;&lt;/p&gt;
&lt;p&gt;There are some constants in life. One of them is that Active Directory is a multi-master replicated database, and that means life finds a way when replication fails.&lt;/p&gt;
&lt;p&gt;So if we took out this derived key business, we could maybe make the PDC act as the password changer. It runs a scheduled task that goes through every managed account and rotates it regularly. Sure. Works well enough. Except then the PDC needs to replicate that out to everyone.&lt;/p&gt;
&lt;p&gt;Another fact of life is that customers have thooooousands of DCs in their environments. Some are on cargo ships in the middle of the ocean and only check in every few hours. Some are in submarines that check in weekly.&lt;/p&gt;
&lt;p&gt;If the PDC has to push out passwords and these DCs can't communicate, then these DCs are using an expired password. Breaks policy. Bad.&lt;/p&gt;
&lt;p&gt;So option two is just give each DC the control to change the password. That's all great until you have two DCs that aren't talking to each other change the password. Eventually they'll sync up and latest wins, but until then you've got mismatched passwords and, well, screw that.&lt;/p&gt;
&lt;p&gt;So when you add this all up you get a requirement that everyone must know the real password at all times.&lt;/p&gt;
&lt;p&gt;Of course I left out one big huge thing about managed accounts! There's two kinds! Managed Service Accounts (MSA) and Group Managed Service Accounts (gMSA). What's the diff?&lt;/p&gt;
&lt;p&gt;Originally MSAs were designed to be installed only on one computer at a time. What you'd do is register the MSA. This stamped the AD object such that only that one computer could get the password. If you tried it from another it would fail even if it had permission.&lt;/p&gt;
&lt;p&gt;In theory this was great because you could very easily lock down who could see the password, and rotate it whenever the MSA was deployed to another machine. Until you decided to deploy a cluster. Oops.&lt;/p&gt;
&lt;p&gt;A service gets deployed to 2 machines with a load balancer splitting traffic between them. The service requires Kerberos, so an SPN is registered on... the computer? No, there's two of them. Okay spin up a service account. Ooooh, managed don't need to know the password, great.&lt;/p&gt;
&lt;p&gt;So you spin up an MSA and install it on box one and register the SPN and then go to install it on box two and... womp womp. Can't. Okay, spin up a SECOND account and add...the...SPN.........dammit! And now we're back to regular accounts and passwords.&lt;/p&gt;
&lt;p&gt;So here we have *Group* Managed Service Accounts. The difference with gMSAs (I have no idea why we lowercase the G) is that they don't get installed on machines. You grant the machine(s) the right to read the password, and that's it.&lt;/p&gt;
&lt;p&gt;Why don't you install it? Because installing it was intended to lock the MSA to the machine. Since it's group-based there's just no need to lock it.&lt;/p&gt;
&lt;p&gt;These days you can use managed accounts for all sorts of things: running services, scheduled tasks, IIS app pools, etc. You generally have to be running as SYSTEM since you're granting rights to the computer account, but they're easy once you get the hang of them.&lt;/p&gt;
&lt;p&gt;You can even try it out with PsExec:&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;code&gt;psexec.exe -i -u corp\gmsa1$ -p ~ cmd.exe&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So what are you waiting for? Go forth and deploy gMSAs.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Active Directory</category>
  <category>Windows</category>
  <category>Security</category>
  <category>Single Sign-On</category>
  <category>Authentication</category>
  <category>Featured</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/how-managed-service-accounts-in-active-directory-work</guid>
  <pubDate>Thu, 04 Feb 2021 21:20:00 GMT</pubDate>
</item>
<item>
  <title>OPS108: Windows authentication internals in a hybrid world</title>
  <link>https://syfuhs.net/ops108-windows-authentication-internals-in-a-hybrid-world</link>
  <description>&lt;p&gt;Have you ever wondered what happens when you type your password into Windows? With the cloud becoming a major part of our world, we find ourselves having to talk to both on-premises and cloud-native resources, which dramatically affects what happens when you do type your password into Windows.&lt;/p&gt;
&lt;p&gt;Follow along as Steve Syfuhs gives a guided tour of how Windows handles logons internally and secures your authentication in a hybrid world.&lt;/p&gt;
&lt;p&gt;&lt;div class="video"&gt;&lt;iframe width="560" height="315" title="YouTube embed" src="about:blank" data-src="https://www.youtube-nocookie.com/embed/IlIP13iqJOg?modestbranding=1&amp;amp;hd=1&amp;amp;rel=0&amp;amp;theme=light" allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This session includes:&lt;/strong&gt;&lt;br /&gt;02:11 Logging on to Windows&lt;br /&gt;03:36 Types of logins&lt;br /&gt;06:33 The Logon UI&lt;br /&gt;09:39 Local Security Authority&lt;br /&gt;21:53 Logon UI Part II&lt;br /&gt;23:42 Local Security Authority Part II&lt;br /&gt;25:14 Kerberos in Windows&lt;br /&gt;35:35 Logon Sessions including Azure Active Directory&lt;br /&gt;38:09 Local Security Authority Part III&lt;br /&gt;43:53 Oauth in Windows - Types of credentials&lt;br /&gt;45:55 Windows Hello Logon&lt;br /&gt;53:34 FIDO Logon&lt;br /&gt;56:32 Local Security Authority Part IV&lt;br /&gt;1:01:08 Azure AD Join&lt;br /&gt;1:05:14 Community Q&amp;amp;A - How long do we need to keep on-premises AD around?&lt;br /&gt;1:09:39 How can we enable MFA/FIDO keys for normal AD Login and not only for Apps that support Modern Auth?&lt;br /&gt;1:12:44 When will we get rid of passwords once and for all?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Community chat&lt;/strong&gt;&lt;br /&gt;Want to chat about this session? Come join us on Discord! &lt;a title="Ask us questions on Discord" href="https://aka.ms/ops108-chat" target="_blank" rel="noopener"&gt;https://aka.ms/ops108-chat&lt;/a&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Security</category>
  <category>Single Sign-On</category>
  <category>Presentation</category>
  <category>Kerberos</category>
  <category>Authentication</category>
  <category>Hybrid</category>
  <guid isPermaLink="false">https://syfuhs.net/ops108-windows-authentication-internals-in-a-hybrid-world</guid>
  <pubDate>Tue, 02 Feb 2021 17:15:00 GMT</pubDate>
</item>
<item>
  <title>Identity Delegation in Active Directory</title>
  <link>https://syfuhs.net/understanding-identity-delegation</link>
  <description>&lt;p&gt;Have you ever had an app that authenticated users, and then thought wouldn't it be great if it could act as that user for the services it has to call later?&lt;/p&gt;
&lt;p dir="ltr" lang="en"&gt;This has historically been called Impersonation, Delegation, Act As, or On Behalf Of depending on protocols in play.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1354156027885699072?ref_src=twsrc%5Etfw"&gt;January 26, 2021&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning: &lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Fundamentally the idea is simple. The user projects their identity to some remote application (i.e. authenticate). The app can't do anything with that projection other than accept it. Delegation is the act of granting that app the right to project the identity further downstream.&lt;/p&gt;
&lt;p&gt;There's a fundamental requirement with this though. The method of projecting (authing) the user has to rely on a trusted third party. In other words using something like federation or protocols like Kerberos. This is in contrast to just passing around creds. You might wonder why.&lt;/p&gt;
&lt;p&gt;It's because if the app in the middle has your password it can just use your password for downstream stuff, ad infinitum. Trusted third party auth protocols by their nature like having 1:1 relationships with all parties. Unfettered projection complicates things.&lt;/p&gt;
&lt;p&gt;I keep saying projecting when I technically mean authenticating. You might wonder why. Authentication is the act of verifying a credential, where that credential could be a password, or a token, or a ticket. Most people associate it with just the first step: the user password.&lt;/p&gt;
&lt;p&gt;With delegation there's usually multiple forms of credentials in play. However, the identity represented by those credentials remains the same. Hence projecting the identity.&lt;/p&gt;
&lt;p&gt;There's another fundamental requirement with delegation. The middle app must be explicitly granted the right to delegate to other things. This is, I hope, somewhat obvious to everyone that it's for enforcing security. Let me explain.&lt;/p&gt;
&lt;p&gt;Authentication is about building a trusted relationship (for some definition of trust) between two parties. When I ask Active Directory for a ticket to a web server I'm relying on the web server to trust AD, and by extension trust me. I project my identity to that server.&lt;/p&gt;
&lt;p&gt;If the web server could take that projection and act as me for other services, that original trust is broken because AD hasn't blessed the relationship between me and that other service.&lt;/p&gt;
&lt;p&gt;This right to delegate can come in many forms and is primarily dictated by the protocol in play. There are two basic types though.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First, there's the right to delegate to anyone. Meaning this middle app can project to any app whatsoever and there's no (or little) limit on it.&lt;/p&gt;
&lt;p&gt;Second, there's the right to delegate to specific apps. Meaning the middle app is only allowed to project your identity to a known list of apps. This particular method is preferred for, again I hope, obvious security reasons. Most delegation services stick to this form nowadays.&lt;/p&gt;
&lt;p&gt;There are other forms, but they all kinda fit the above patterns.&lt;/p&gt;
&lt;p&gt;There are different implementations of delegation. Active Directory calls it delegation. Federation protocols like WS-Fed/Trust call it ActAs. OAuth calls it delegation or impersonation, Azure AD calls it on-behalf-of. Let's look at AD and Azure AD.&lt;/p&gt;
&lt;p&gt;Many folks know about delegation because of this screen in Active Directory. Many people have come to hate this screen. This screen applies to that middle web server.&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEsrzDD_UwAED4iI_637472950657237513.png" alt="The delegation form in Active Directory" width="418" height="564" /&gt;&lt;/p&gt;
&lt;p style="text-align: left;"&gt;User A projects their identity to web server B, and B projects A's identity to web service C. A =&amp;gt; B =&amp;gt; C. The screen from before applies to B. That screen lets you control what form of delegation you want to allow.&lt;/p&gt;
&lt;p&gt;The first option is obvious. B isn't allowed to delegate to anyone, period.&lt;/p&gt;
&lt;p&gt;The second option is mode 1: B can delegate to whoever it wants. Could be C, could be D, could be Y, could be Z.&lt;/p&gt;
&lt;p&gt;The third option is mode 2: B can only delegate to C if it's in the list below it.&lt;/p&gt;
&lt;p&gt;But the third option has a catch: you can only delegate when using Kerberos. So option 3b was added: you can delegate to whoever is in this list without authenticating. Whaaaaaat the eff? We'll come back to this.&lt;/p&gt;
&lt;p&gt;So AD relies on Kerberos for delegation. The first option is called unconstrained delegation. This is the easiest mode to wrap your head around because what you're doing is giving your client TGT to the web server, so the server can do whatever it wants with it.&lt;/p&gt;
&lt;p&gt;That's literally all it's doing. The client is informed that the server uses unconstrained delegation so the client copies the user TGT, stuffs it into the AP-REQ authenticator, and fires it off to the target server.&lt;/p&gt;
&lt;p&gt;Once the server receives the AP-REQ, it decrypts it and creates a logon session and ticket cache. The TGT is stuffed into the cache. When the server needs to make a call as the user it uses the TGT to request a ticket to whatever is next. &lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Incidentally this is why Credential Guard blocks unconstrained delegation on the client. Unconstrained delegation is Stealing-your-TGT-as-a-Service. &lt;a href="https://syfuhs.net/how-windows-defender-credential-guard-works"&gt;How Windows Defender Credential Guard Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Next is what's called constrained delegation. You provide a list of services web server B is allowed to project the identity to. You might think okay, it's just like unconstrained where they copy the TGT over, and the web server has to ask what it can project to, but it's not.&lt;/p&gt;
&lt;p&gt;We don't live in a world where we can blindly trust web server B. If B is even a little untrustworthy and it managed to get a hold of a TGT for the user, it's game over for that user. We in no uncertain terms want that TGT loose on the network. So what do?&lt;/p&gt;
&lt;p&gt;Well, we don't do Kerberos. 😲&lt;/p&gt;
&lt;p&gt;More precisely what we do is use a protocol that is an extension to Kerberos called Service-for-User [MS-SFU] or s4u. &lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/MS-SFU/3bff5864-8135-400e-bdd9-33b552051d94"&gt;[MS-SFU]: Kerberos Protocol Extensions: Service for User and Constrained Delegation Protocol | Microsoft Docs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;S4u is a way for web server B to safely request a ticket to service C on behalf of the user. It does this by using the service ticket user A handed to server B as an evidence ticket. Huh?&lt;/p&gt;
&lt;p&gt;Imagine you're web server B. You have an identity "webserverb$". You have a password, and AD knows who you are. You can receive Kerberos service tickets. AD encrypts them to your password. Nothing particularly fancy about this. It's basic Kerberos. &lt;a href="https://syfuhs.net/a-bit-about-kerberos"&gt;A bit about Kerberos (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now, you receive a ticket from user A and decrypt it. You create the SSO logon session for the user and tell the web app it's user A. Now the web app wants to communicate to service C as that user so it asks for a ticket to service C.&lt;/p&gt;
&lt;p&gt;Web server B has a logon session for user A, so web server B checks for a TGT. No TGT because we're constrained. Okay, let's try S4U. To do this, the web server makes a request to the domain controller for a service ticket to C.&lt;/p&gt;
&lt;p&gt;The server has an identity on the network, therefore it has a TGT, and it's allowed to ask for service tickets. Again, plain old Kerberos. However, the identity in the service ticket would be server B. So server B adds the service ticket it received from A as an evidence ticket.&lt;/p&gt;
&lt;p&gt;Well now this is interesting to the domain controller. It receives a ticket request from B for C and also a service ticket from A FOR B, plus some flags to say do S4U. So the DC checks the delegation list. Is B allowed to delegate to C? Yes, okay give B a ticket to C as A.&lt;/p&gt;
&lt;p&gt;I promise you aren't having a stroke. The way to follow this is that B needs to prove it's allowed to get the ticket to C on behalf of A, otherwise B could be evil and impersonate whoever they want.&lt;/p&gt;
&lt;p&gt;Once web server B receives the ticket, it bubbles it up to the web app, and the web app stuffs the ticket into the request for web service C. C receives it, decrypts it, and sees it's for user A. And we're back to how SSO works. &lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But remember how I said there's that other mode, where it doesn't require authentication? Yeah about that. We call it Protocol Transition. This exists so web server B can authenticate users using a protocol Active Directory doesn't understand, while still impersonating them.&lt;/p&gt;
&lt;p&gt;Consider if web server B supports SAML. AD doesn't understand SAML, but the web app wants to impersonate the identity projected through SAML so when they call web service C they're acting as user A. This can work through protocol transition.&lt;/p&gt;
&lt;p&gt;It uses the same protocol extension -- S4U. The difference is that the evidence ticket isn't real. Or rather, it's an evidence ticket issued to the server itself. Huh?&lt;/p&gt;
&lt;p&gt;There's a sub-protocol in S4U called service-for-user-to-self or s4u-self. This is an incredibly useful protocol, because an application can request a service ticket to *itself* on behalf of any user. It's useless for auth, but still contains the user identity. Give it a try.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p style="text-align: left;"&gt;&lt;code&gt;new-object system.security.principal.windowsidentity "bob@corp.identityintervention.com"&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img style="float: left;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEssAN6EUYAAoqhz_637472952390448096.png" alt="PowerShell view of S4U-to-Self" width="680" height="571" /&gt;&lt;/p&gt;
&lt;p&gt;It's a TGS-REQ to me, with some bits that says please get on behalf of bob.&lt;/p&gt;
&lt;p&gt;So for just a name you get a ticket to yourself. A ticket to yourself can get your constrained delegation. Put the two together and you have s4u-proxy, AKA protocol transition!&lt;/p&gt;
&lt;p&gt;Of course, here's the problem: protocol transition is increeeedibly dangerous. You've just granted web server B the rights to impersonate whoever they want. That's worse than unconstrained delegation. Oops. As such you've effectively granted web server B the right to act as a DC.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2FEssA5lDVoAAaLns_637472952692475341.png" alt="S4U-to-Self Kerberos request" width="539" height="497" /&gt;&lt;/p&gt;
&lt;p&gt;This is, incidentally why selecting that option tends to make things "just work".&lt;/p&gt;
&lt;p&gt;Please, please, pleeeeeease be incredibly careful if you choose to use it. Any server configured for protocol transition should have the same security as a DC. No joke.&lt;/p&gt;
&lt;p&gt;Anyway, there's one more thing with AD delegation that isn't on that screen. It's something called Resource-Based Constrained Delegation. Huh?&lt;/p&gt;
&lt;p&gt;It's basically regular constrained delegation, but the approval list is flipped. The idea is that instead of saying web server B is allowed to delegate to web service C, it says web service C is allowed to be delegated from web server B.&lt;/p&gt;
&lt;p&gt;This actually makes more sense from a security perspective. The thing you're protecting is web service C, so why are the controls on B? The armed money delivery transports don't dictate which vaults they can go in to, the banks dictate which transports are allowed into the vault.&lt;/p&gt;
&lt;p&gt;The other useful thing about RBCD is more of a practical one. Regular constrained delegation doesn't work across forests because of how the protocol happens to work. There isn't enough authz details in it to identify the service because SPNs are only unique within forests.&lt;/p&gt;
&lt;p&gt;RBCD relies on SIDs. Web service C has a list of SIDs that can delegate to it, and when web server B makes a request to the other forest, it includes web server B's SID.&lt;/p&gt;
&lt;p&gt;But enough about that. Let's look at another form of delegation: Azure AD on-behalf-of.&lt;/p&gt;
&lt;p&gt;Azure AD-based apps are an evolution of AD-based apps. They still have similar, or higher, security requirements. As web server B I want to project user A's identity to service C.&lt;/p&gt;
&lt;p&gt;The difference is in the choice of protocols. Azure AD relies on OAuth2 for authentication and authorization. A client authenticates user A and gets a JWT access token signed by AAD to web server B. Web server B validates the ticket and the app now knows it's user A, so says AAD.&lt;/p&gt;
&lt;p&gt;But the web app wants to access another resource, say Microsoft Graph. The web app can use it's own identity, or it can use the identity of the user. You could keep it simple and use the app identity, but then you need to grant that identity access to all users resources.&lt;/p&gt;
&lt;p&gt;That's a fairly broad set of permissions, and attacking that app gets you everything in Graph. That's bad.&lt;/p&gt;
&lt;p&gt;But if you use the user identity, the app doesn't need anything special, and the app can operate as just that single user. That's good.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: left;" src="https://syfuhsblog.blob.core.windows.net/images/2021%2Fthatsgood_637472954036944962.gif" alt="That's good" width="325" height="247" /&gt;&lt;/p&gt;
&lt;p&gt;Protocol-wise this is an extension to OAuth called on-behalf-of. &lt;a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow"&gt;Microsoft identity platform and OAuth2.0 On-Behalf-Of flow - Microsoft identity platform | Microsoft Docs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Not surprisingly it kinda sorta acts a lot like s4u. User A gets a token to server B from AAD. Server B has it's own identity and authenticates to AAD, providing user A's access token to B as an evidence token (assertion).&lt;/p&gt;
&lt;p&gt;AAD checks the list of apps that B is allowed to delegate to, and if C is in the list, it issues a token to B on behalf of A for C.&lt;/p&gt;
&lt;p&gt;This is actually pretty cool. First, it's way easier to follow along because it's all HTTP instead of binary encoded ASN.1 goop. Second, it supports multiple token types. Ergo it supports multiple protocols.&lt;/p&gt;
&lt;p&gt;That means you can transition between OAuth and (say) SAML without turning your app into a major target, because every exchange and token is still authenticated. Awesome.&lt;/p&gt;
&lt;p&gt;Third, you can enforce consent. This shifts authorization a bit so the user is now in control over who can project and forward their identity. That's a nice privacy win.&lt;/p&gt;
&lt;p&gt;So obviously there's been a delegation evolution. From AD unconstrained, all the way to OAuth on-behalf-of. Hopefully it's gotten easier and more secure along the way. /fin&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Security</category>
  <category>Kerberos</category>
  <category>Windows</category>
  <category>Azure AD</category>
  <category>Twitter Thread</category>
  <category>Authentication</category>
  <guid isPermaLink="false">https://syfuhs.net/understanding-identity-delegation</guid>
  <pubDate>Tue, 26 Jan 2021 21:55:00 GMT</pubDate>
</item>
<item>
  <title>Preventing UAC Bypass through Kerberos Loopback</title>
  <link>https://syfuhs.net/preventing-uac-bypass-through-kerberos-loopback</link>
  <description>&lt;p dir="ltr" lang="en"&gt;Have you ever tried to access an admin SMB share on your local machine (\\localname\c$) only to find out you don't have admin perms despite being a local administrator? Why is that? Here's something you maybe didn't know: It's by design -- it's a way of preventing UAC bypass. &lt;a href="https://t.co/1SwNrWn4j8"&gt;pic.twitter.com/1SwNrWn4j8&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1351634657570217984?ref_src=twsrc%5Etfw"&gt;January 19, 2021&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&lt;/strong&gt; Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You might be saying "well duh! That's what UAC does!"&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But we're talking SMB, so it's over the network, therefore it's Kerberos, and Kerberos can't doesn't do UAC over the network because Kerberos doesn't contain local authz information, and UAC is all about local authz.&lt;/p&gt;
&lt;p&gt;Note: SMB loopback actually uses NTLM. But let's not let details get in the way of a good explainer. (NTLM does work similarly though)&lt;/p&gt;
&lt;p&gt;What's the difference between \\localmachine\c$ and \\othermachine\c$ then? Actually, nothing.&lt;/p&gt;
&lt;p&gt;Some background: when a client needs a kerb ticket to something it asks Windows. Windows creates an AP-REQ, which is the requested ticket plus authenticator.&lt;/p&gt;
&lt;p&gt;The ticket is created by the KDC. The client can't see inside it, and can't manipulate it. It's opaque. However, the client can ask the KDC to include extra bits in the ticket. See here for fiddly details:&amp;nbsp;&lt;a href="https://syfuhs.net/a-bit-about-kerberos"&gt;A bit about Kerberos (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;These extra bits are just a way to carry information from the client to the target service during authentication. As it happens one of the things the client always asks to include is a machine nonce.&lt;/p&gt;
&lt;p&gt;See, when the client asks the client Kerberos stack for a ticket, the stack creates a random bit of data and stashes it in LSA and associates it to the currently logged on user. This is the nonce. This nonce is also stuck in the ticket, and then received by the target service.&lt;/p&gt;
&lt;p&gt;The target service, i.e. the same Windows Kerberos stack, knows about this nonce and asks LSA if it happens to have this nonce stashed somewhere. If it doesn't, well, then it's another machine and just carry on as usual.&lt;/p&gt;
&lt;p&gt;However, if it does have this nonce, LSA will inform the Kerberos stack that it originally came from user so and so, and most importantly that the user was *not* elevated at the time.&lt;/p&gt;
&lt;p&gt;What does that mean? Not elevated?&lt;/p&gt;
&lt;p&gt;This is UAC -- User Account Control. UAC is the thing that *tries* to prevent you from doing something stupid with admin privileges.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: left;" src="https://syfuhsblog.blob.core.windows.net:443/images/blobid2_637466880029435301.png" alt="EsH59mLVEAAso1i.png" width="461" height="327" data-filename="EsH59mLVEAAso1i.png" /&gt;&lt;/p&gt;
&lt;p&gt;See, when you log onto Windows you're granted a set of local privileges. Some of these give you lots of control over the system, like local administrator. UAC is a way of preventing you from doing silly things as administrator unless you reeeeeeally want to.&lt;/p&gt;
&lt;p&gt;The way it works is conceptually simple. During login you're given two NT tokens. The first is your high privilege token. It contains all those special privileges. The second is your low privilege token. Everything you do uses your low privilege token by default.&lt;/p&gt;
&lt;p&gt;So when you do need to do something with higher privileges you need to ask Windows "Hey! I need the high privilege token, pleeeeeeeeeeeeease".&lt;/p&gt;
&lt;p&gt;Anyway, LSA knows all about these tokens, so when it receives this Kerberos ticket and contains that nonce and finds the user, voila it has a low privilege token.&lt;/p&gt;
&lt;p&gt;Now the Kerberos stack makes a copy of the ticket contents for it's own SSO session and whenever you do anything in that session, say try write to c$\windows\system32, the authorization system checks the privileges and in this case says nooooope.&amp;nbsp;&lt;a href="https://syfuhs.net/how-windows-single-sign-on-works"&gt;How Windows Single Sign-On Works (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So as a result you don't get to bypass UAC by going through the network. /fin&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Single Sign-On</category>
  <category>Security</category>
  <category>Kerberos</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/preventing-uac-bypass-through-kerberos-loopback</guid>
  <pubDate>Thu, 21 Jan 2021 15:32:00 GMT</pubDate>
</item>
<item>
  <title>Hybrid Authentication with FIDO</title>
  <link>https://syfuhs.net/hybrid-authentication-with-fido</link>
  <description>&lt;p dir="ltr" lang="en"&gt;Speaking of &lt;a href="https://twitter.com/hashtag/passwordless?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#passwordless&lt;/a&gt;... did you ever wonder how we made it work with on-prem Active Directory? It's kind of magic. We built a KDC in the cloud. Here's how it works... &lt;a href="https://t.co/ww7qtg0r3P"&gt;https://t.co/ww7qtg0r3P&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1296893761054576642?ref_src=twsrc%5Etfw"&gt;August 21, 2020&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning:&lt;/strong&gt; Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note this thread was created a while back. Just catching up.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You log into Windows with your FIDO key. Our cloud auth package in Windows (CloudAP) knows how to handle FIDO auth and does the handshake with https://login.microsoftonline.com. That returns an OAuth PRT and a special cloud-minted Kerberos Ticket Granting Ticket.&lt;/p&gt;
&lt;p&gt;The TGT is encrypted using the session key agreed to earlier, so only the client machine can process it. Windows knows this key, and knows that this TGT is special, so it triggers a TGS-REQ to a nearby on-prem KDC using this special TGT as the evidence ticket.&lt;/p&gt;
&lt;p&gt;Prior to all this you had to register your domain with AAD so it could use FIDO, and in doing so what we did was we created a special Read-Only Domain Controller and RODC krbtgt secret. That secret got synced to AAD and is what we use to encrypt the special TGT.&lt;/p&gt;
&lt;p&gt;When your on-prem KDC receives this special TGT it knows that it's special and uses the RODC krbtgt_### secret to decrypt it. The KDC exchanges it for a real TGT and returns it to the client. The client is now in a steady state as far as Kerberos is concerned.&lt;/p&gt;
&lt;p&gt;But what about NTLM? Guh. Well, it turns out we can't kill NTLM yet, so when the client had this special TGT in hand and knew to exchange it for a real TGT, it included a special flag on the TGS-REQ to ask the KDC to include some additional SSO creds in response.&lt;/p&gt;
&lt;p&gt;Those SSO creds are returned to the client and handed off to the various SSO packages in Windows, one being NTLM, and those packages handle them as they would any other credential. Voila, now they know how to handle NTLM and any other supported SSO protocols. Magic!&lt;/p&gt;
&lt;p&gt;Can't forget the pups.&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net/images/blobid1_637464331376962456.jpg" alt="Ef-ZRlwUcAEoAR_.jpg" width="700" height="525" data-src="https://syfuhsblog.blob.core.windows.net/images/blobid1_637464331376962456.jpg" data-filename="Ef-ZRlwUcAEoAR_.jpg" /&gt;&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net/images/blobid0_637464331255857484.jpg" alt="Ef-ZRlwUcAA13sP.jpg" width="700" height="525" data-src="https://syfuhsblog.blob.core.windows.net/images/blobid0_637464331255857484.jpg" data-filename="Ef-ZRlwUcAA13sP.jpg" /&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Single Sign-On</category>
  <category>Security</category>
  <category>Kerberos</category>
  <category>FIDO</category>
  <category>Twitter Thread</category>
  <category>Authentication</category>
  <guid isPermaLink="false">https://syfuhs.net/hybrid-authentication-with-fido</guid>
  <pubDate>Tue, 19 Jan 2021 01:54:00 GMT</pubDate>
</item>
<item>
  <title>Kerberos FAST Armoring</title>
  <link>https://syfuhs.net/kerberos-fast-armoring</link>
  <description>&lt;p dir="ltr" lang="en"&gt;It's Monday evening, the weather is great, and we're in the middle of a pandemic. Lets talk Kerberos! Or rather, it's little known nephew FAST and Armoring.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1287931640929333249?ref_src=twsrc%5Etfw"&gt;July 28, 2020&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning: &lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;p&gt;Note this thread was created a while back. Just catching up.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You might have heard about it from such features as Windows Kerberos Armoring. It's in fact three separate things.&amp;nbsp;&lt;a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/hh831747(v=ws.11)#kerberos-armoring-flexible-authentication-secure-tunneling-fast"&gt;What's New in Kerberos Authentication | Microsoft Docs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;First, it's part of a larger body of work called the pre-authentication framework, a way to provide a generic extensible model of adding authentication methods to Kerberos. It gets more interesting, honest.&lt;/p&gt;
&lt;p&gt;Second, it's a method of creating a generic secure tunnel for information to flow between a client and a KDC within the original Kerberos protocol. I swear, it'll get interesting.&lt;/p&gt;
&lt;p&gt;Third, it's a method where you bind your authentication to the machine account to prevent password attacks like Kerberoasting -- aha, there's the exciting thing!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kill all password attacks. Here's how it works.&lt;/p&gt;
&lt;p&gt;Kerberos is deceptively simple: you, the client, request a ticket from the KDC. The KDC happily responds and encrypts the response to your password. You decrypt it with your password, and voila you have a ticket. This is dangerous because...&lt;/p&gt;
&lt;p&gt;You now have this oracle that'll return encrypted blobs of structured data to any caller, encrypted to a password. This makes cryptographic attacks super easy for weak passwords. A solution was added: the pre-auth timestamp, which is the current time encrypted with your password.&lt;/p&gt;
&lt;p&gt;The KDC receives this timestamp, decrypts it because it knows your password (-ish) and verifies the request was within a short period of time. But still, attackers can intercept the messages and perform those same attacks. They just need to convince you to get a ticket first.&lt;/p&gt;
&lt;p&gt;The protocol itself is bound by this weak thing -- your password. It needs more randomness. Incidentally, most callers happen to be on a domain joined computer when doing Kerberos, and the computer uses a super random password. Innnnnteresting.&lt;/p&gt;
&lt;p&gt;So this framework has this thing called Armoring, which is the idea that you take a key and mix in a whole lotta randomness from another source, and use that instead. So here we take the computer account, and have it request a TGT. The TGT has this thing called a session key.&lt;/p&gt;
&lt;p&gt;That session key is protected within the TGT and only the client and the KDC know it. So why not let the KDC use the randomness of that session key to protect the client?&lt;/p&gt;
&lt;p&gt;The client gets this new mixed key and can now communicate with the KDC. The randomness of the computer password makes any crypto attack infeasible, and the user can still user a password.&lt;/p&gt;
&lt;p&gt;Okay, but what about users that aren't on a domain joined computer? There's a small provision in the spec that lets callers request an anonymous ticket. You lose server authentication, but when you're out alone in the wild, what're you gonna do?&lt;/p&gt;
&lt;p&gt;...assuming the KDC supports that provision of course.&lt;/p&gt;
&lt;p&gt;Now that's all well and good, but what about this tunneling thing? Well back in the dark ages crypto was export controlled (ugh), which left a lot of protocol designers deciding to leave a bunch of crap in cleartext. FAST said nuh uh, attackers can modify that over the wire.&lt;/p&gt;
&lt;p&gt;So you have this super secret shiny key now, and a nice dark hole to shove stuff. So what do we do? We make a copy of the entire request, encrypt it, and shove it in the hole. And leave the outer message in cleartext for appearances sake.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Because why not?&lt;/p&gt;
&lt;p&gt;The cool thing about all this, aside from making password attacks more difficult, is it lets developers easily extend the protocol to include new pre-auth methods like OTPs or PAKEs, and does a reasonably good job of hardening the aging crypto properties of the protocol.&lt;/p&gt;
&lt;p&gt;So, go turn it on. It's super easy.&lt;/p&gt;
&lt;p&gt;Requisite puppies.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net:443/images/blobid0_637464331255857484.jpg" alt="Ed-uy_5VoAAY69y.jpg" width="875" height="656" data-filename="Ed-uy_5VoAAY69y.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net:443/images/blobid1_637464331376962456.jpg" alt="Ed-uy_3U8AAyBHC.jpg" width="875" height="656" data-filename="Ed-uy_3U8AAyBHC.jpg" /&gt;&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Kerberos</category>
  <category>Windows</category>
  <category>Security</category>
  <category>Twitter Thread</category>
  <category>Authentication</category>
  <guid isPermaLink="false">https://syfuhs.net/kerberos-fast-armoring</guid>
  <pubDate>Sat, 16 Jan 2021 22:32:00 GMT</pubDate>
</item>
<item>
  <title>Should I Turn off NLA?</title>
  <link>https://syfuhs.net/should-i-turn-off-nla</link>
  <description>&lt;p style="font-size: 80px; text-align: center;"&gt;No!&lt;/p&gt;
&lt;p&gt;Network Level Authentication is how Windows authenticates remote desktop clients and servers before sending your credentials over to a remote machine.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net/images/EhaXhoYVgAAol8A_637356387540506412.png" alt="A remote desktop connection" width="450" height="335" /&gt;&lt;/p&gt;
&lt;p&gt;If the client can't authenticate the remote server then there's no guarantee it's the server you actually want to log in to, and therefore may be a server trying to steal your credentials.&lt;/p&gt;
&lt;p&gt;This is why you see a credentials prompt when using RDP and never see the Windows logon screen during the initial connection.&lt;/p&gt;
&lt;p&gt;See&amp;nbsp;&lt;a href="https://syfuhs.net/how-authentication-works-when-you-use-remote-desktop"&gt;How Authentication Works when you use Remote Desktop (syfuhs.net)&lt;/a&gt;&amp;nbsp;for the gory details.&lt;/p&gt;
&lt;p&gt;The whole point of NLA is to make sure the name you typed into the RDP application is in fact the server you've connected to. It fails if it isn't the same server. Without NLA the client has no method to prove the remote server is the same as what you've typed in.&lt;/p&gt;
&lt;p&gt;This applies to all forms of credentials, not just passwords. Passwords are ubiquitous so they're the most dangerous to leak, but smart card logons and any number of 3rd party mechanisms can be proxied and snooped &lt;em&gt;if you've turned off NLA&lt;/em&gt;. This means an attacker sitting in between your client and server can impersonate users without you ever knowing.&lt;/p&gt;
&lt;p&gt;So please think twice about turning off NLA. It's there to protect you.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>RDP</category>
  <category>Windows</category>
  <category>Security</category>
  <guid isPermaLink="false">https://syfuhs.net/should-i-turn-off-nla</guid>
  <pubDate>Wed, 30 Dec 2020 19:00:00 GMT</pubDate>
</item>
<item>
  <title>A Strategy for Protecting Privileged Access</title>
  <link>https://syfuhs.net/privileged-access</link>
  <description>&lt;p dir="ltr" lang="en"&gt;So, there was a major attack recently. Apropos of that, I wanted to re-up how we (Microsoft) recommend folks lay out their environments for security-mindedness. In short we call it Privileged Administration. It's the foundation of our (ugh) zero trust model.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1341499772796977153?ref_src=twsrc%5Etfw"&gt;December 22, 2020&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning: &lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Fundamentally the system is simple* because it's just** about isolation -- isolation of business impact. The more damage you can do to the org the fewer things you're allowed to touch.&amp;nbsp;&lt;a href="https://docs.microsoft.com/en-us/security/compass/privileged-access-strategy" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/security/compass/privileged-access-strategy&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;*I'm lying.&lt;/p&gt;
&lt;p&gt;**It's never "just"&lt;/p&gt;
&lt;p&gt;This is somewhat contradictory because by definition highly privileged users have more power. Our model doesn't really reduce these privileges, it just prevents them from being used in certain places.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://docs.microsoft.com/en-us/security/compass/media/overview/end-to-end-approach.png" alt="An end to end approach is required for meaningful security" width="630" height="315" /&gt;&lt;/p&gt;
&lt;p&gt;This is the isolation piece. Domain admins shouldn't be able to do squat in most parts of your network, for instance. They should have an isolated little hole they can live in where *only* domain admins can go.&lt;/p&gt;
&lt;p&gt;It's structured into security levels or more often described as tiers. Think of them as high, medium, and low impact.&lt;/p&gt;
&lt;p&gt;High impact is all your critical infrastructure and accounts required to manage that infrastructure. These are your DCs and domain admins. They can destroy your business with a single command. Maaaaaybe don't let them log in to user workstations to install random programs?&lt;/p&gt;
&lt;p&gt;Medium impact is for specialized roles. They can cause significant damage, but the risk is lower. These are folks like executives, developers touching production, or helpdesk techs.&lt;/p&gt;
&lt;p&gt;And then low impact is for everyone else. They can access some stuff, but usually nothing critical.&lt;/p&gt;
&lt;p&gt;The delineation of all of these is business impact: how badly can I break the company just by doing my job (poorly)?&lt;/p&gt;
&lt;p&gt;That's all well and good, but these are just words and I'm just some person on the internet. Implementation and follow through are critical here.&lt;/p&gt;
&lt;p&gt;How does one implement such privileged administration? We have docs: &lt;a href="https://docs.microsoft.com/en-us/security/compass/security-rapid-modernization-plan" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/security/compass/security-rapid-modernization-plan&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But start simple. On the Venn diagram of regular user and privileged user accounts, there should be two circles that don't overlap.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="https://syfuhsblog.blob.core.windows.net:443/images/blobid1_637442738060100276.jpg" alt="Ep34j5TVoAEGxJR.jpg" width="736" height="359" data-filename="Ep34j5TVoAEGxJR.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;That means your domain admin account isn't your daily driver. You don't check your email with DA. You as the admin have two accounts: a named DA account, and your regular low (or medium) tier account.&lt;/p&gt;
&lt;p&gt;Also follow the concept of clean source. That is -- the thing you're accessing a resource from should have the same level of security. In other words the laptop you check your email from shouldn't be the machine you RDP into a domain controller with. More on this later.&lt;/p&gt;
&lt;p&gt;While you're at it prevent yourself from shooting yourself in the foot: lock down where privileged users can log in. A compromised workstation shouldn't get you keys to the kingdom because a DA logged in three days ago because the user was complaining about something.&lt;/p&gt;
&lt;p&gt;Enforce strong authentication starting from high privilege on down. Domain Admins must always log on with smart cards. Period.&lt;/p&gt;
&lt;p&gt;Why TF is your DA logging on with a weak password of i@mgR00t!?&lt;/p&gt;
&lt;p&gt;This of course gets more complicated the further down the stack you go. Smart cards can be expensive and error prone. Introduce other technologies like Windows Hello or FIDO. Your users will love you and it reduces the number of password resets.&lt;/p&gt;
&lt;p&gt;Audit audit audit audit audit audit audit audit audit audit audit. And for the love of god, review the audit logs. There are tools for this. Some cheap, some not. Some good, some...not. Tune it for critical systems and users first, then work your way out.&lt;/p&gt;
&lt;p&gt;Build up isolated interfaces for those things that require transitioning between privilege levels. HR apps, group management, etc. Make it easy for users to modify non-impacting data so they don't need super privileges just to change their middle name or add themselves to a DL.&lt;/p&gt;
&lt;p&gt;And (or at least) enforce conditional authz policies for such things to require MFA.&lt;/p&gt;
&lt;p&gt;Better yet, build out a just-in-time elevation process for these privileges. Even if you *are* logged on as a domain admin you should still have to indicate what permission you want so you can fiddle with stuff.&lt;/p&gt;
&lt;p&gt;JIT plus auditing and you have a complete record of what happens in your network.&lt;/p&gt;
&lt;p&gt;Once you've done all these things we can revisit this clean source principle. If I'm the IT person managing my domain, how do I access the necessary tools? I'm absolutely not doing it from the machine I check my email from.&lt;/p&gt;
&lt;p&gt;Highly privileged access requires high security. Yes, that sounds dumb, but the point is sound: an attacker that compromises your low privilege account should not be able to leverage that into a high privilege account.&lt;/p&gt;
&lt;p&gt;So again, that machine you check your email on shouldn't have domain admin creds on it, ever. Use a dedicated machine for highly privileged operations, period. To make your life easier you can create a VM on that machine to check your email.&lt;/p&gt;
&lt;p&gt;The difference is you can go from the host into the VM, but not from the VM to the host. These are called Privileged (or Secure) Access Workstations or PAWs/SAWs.&lt;/p&gt;
&lt;p&gt;I use one all the time. My daily driver is my corporate desktop. I can access my email and write code on it. However, if I need access to production systems for troubleshooting or fixing stuff I use my SAW.&lt;/p&gt;
&lt;p&gt;But I don't use my regular account. I use my privileged account, which requires a smart card to log on. And then I JIT to get the permissions I need to access resources. If I need to access the internet I have a scratch VM running my low privilege account too.&lt;/p&gt;
&lt;p&gt;You'll notice I never once mentioned jump servers. That's because they aren't secure as people think. They are by design doing something that breaches isolation. You're transitioning from a low privilege to a high privilege in a low privilege environment.&lt;/p&gt;
&lt;p&gt;And also note that this doesn't give you a pass to ignore endpoint security. Security is a group effort. Lock down your machines, keep them patched, deploy ATP, Cred Guard, HVCI, etc.&lt;/p&gt;
&lt;p&gt;So go &lt;a href="https://docs.microsoft.com/en-us/security/compass/overview" target="_blank" rel="noopener"&gt;do some reading if you're inclined&lt;/a&gt;.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Security</category>
  <category>Windows</category>
  <category>Privileged Access</category>
  <category>Twitter Thread</category>
  <guid isPermaLink="false">https://syfuhs.net/privileged-access</guid>
  <pubDate>Tue, 22 Dec 2020 22:46:00 GMT</pubDate>
</item>
<item>
  <title>How Windows Defender Credential Guard Works</title>
  <link>https://syfuhs.net/how-windows-defender-credential-guard-works</link>
  <description>&lt;p dir="ltr" lang="en"&gt;Okay, lets talk Credential Guard. What is it, why it matters, and how it works.&lt;/p&gt;
&lt;p&gt;&amp;mdash; Steve Syfuhs (@SteveSyfuhs) &lt;a href="https://twitter.com/SteveSyfuhs/status/1333891174738714624?ref_src=twsrc%5Etfw"&gt;December 1, 2020&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Twitter warning: &lt;/strong&gt;Like all good things this is mostly correct, with a few details fuzzier than others for reasons: a) details are hard on twitter; b) details are fudged for greater clarity; c) maybe I'm just dumb.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Credential Guard is a Windows service that protects credentials from being lifted from a machine. Since that means nothing to the vast majority of people let's expand on that.&lt;/p&gt;
&lt;p&gt;Credential Guard protects the secrets used by Windows for single sign-on from being stolen and used on other machines.&lt;/p&gt;
&lt;p&gt;These secrets are numerous. First, there's your password. You type it in to log into Windows. You exchange your password for a TGT. Your TGT has a session key to get access to service tickets. Historically these secrets were ripe for the taking if you could run code as system.&lt;/p&gt;
&lt;p&gt;The attacks fundamentally work something like this. User logs on, downloads something accidentally. Thing finds an EOP, runs as admin, converts admin to system. This thing can now read all memory on the system. Your secrets are in memory. Voila.&lt;/p&gt;
&lt;p&gt;But that's not all. Sometimes it doesn't need to be a complicated attack. We have undocumented APIs that let you get access to these secrets too. They've been around forever and we can't get rid of them for historical reasons. We can only make them harder to access.&lt;/p&gt;
&lt;p&gt;A good example is SSO in Java client applications. If a java application wanted to use the current users logon session to access resources without prompting, the end user had to toggle an undocumented registry key that let java steal the user's TGT session key.&lt;/p&gt;
&lt;p&gt;Or there's this thing called Credential Manager. If you received a prompt, say for RDP or accessing a file share outside your domain, and clicked save credentials then those credentials go into credman. All you have to do is ask credman to give you those creds and it will.&lt;/p&gt;
&lt;p&gt;These were all necessary at one time or another and as our threat models matured we realized there was clearly a security gap here. The problem of course is that our security boundary is system|everything-else. Once you got on as system you could do whatever you wanted.&lt;/p&gt;
&lt;p&gt;We attempted to solve this with LSA Protected Process mode, which is an incredibly clever way of preventing anything from being loaded into the LSA process that wasn't signed by a special CA.&lt;/p&gt;
&lt;p&gt;This was an important step because loading stuff into LSA was a major attack vector and it'd be a huge win if we could nip that. And it was and is reasonably effective for certain types of attacks. Here's where people "but but mimikatz" me.&lt;/p&gt;
&lt;p&gt;LSAPPL isn't perfect. It has weaknesses. If you can make it into the kernel and modify process stuff you can turn it off with the flip of a bit. But you don't build a house with just a hammer. It's one tool of many. Enter Credential Guard.&lt;/p&gt;
&lt;p&gt;For decades there was nothing outside the kernel security boundary. Kernel talked to hardware and had access to everything. Ring 0. Nothing lower than ring 0.&lt;/p&gt;
&lt;p&gt;Until someone invented the hypervisor, which is just a fancy way of saying "hey lets run multiple kernels on a single machine and doll out access to hardware with us controlling it instead of the kernels." Ish.&lt;/p&gt;
&lt;p&gt;It took a generation or two but our hypervisors pretty much let you run all VMs on bare metal now. The hypervisor is this tiny tiny thing that just acts as a resource mediator now and this mediator allows these VMs to stay isolated from one another.&lt;/p&gt;
&lt;p&gt;One VM can't peek into another's memory. Can't look at it's processes, can't communicate with it except through external stacks like ethernet, can't do any of that. Full and complete isolation.&lt;/p&gt;
&lt;p&gt;That therefore means anything running in a VM kernel doesn't have a full view of the world, and malicious code is pretty much stuck there.&lt;/p&gt;
&lt;p&gt;So someone had the brilliant idea: "hey, what if we moved all the critical security-sensitive stuff into a separate VM?"&lt;/p&gt;
&lt;p&gt;Enter VSM: Virtual Secure Mode. Or VBS: Virtualization-based Security.&lt;/p&gt;
&lt;p&gt;This might seem confusing because your Windows client doesn't run in a VM. It runs on bare metal. You inserted a DVD^H^H^H USB stick and installed it on the physical hard drive. And things running in kernel on the bare metal can access all things on the bare metal. What gives?&lt;/p&gt;
&lt;p&gt;As it happens, that's not strictly true anymore. Windows these days runs in a VM on the hypervisor. 😲&lt;/p&gt;
&lt;p&gt;Sort of.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It doesn't exist as a VHDX or anything like that. All the resources are physical, but they're now governed by the hypervisor.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" src="https://syfuhsblog.blob.core.windows.net:443/images/blobid1_637424620931996957.png" alt="uim-architecture.png" width="727" height="367" data-filename="uim-architecture.png" /&gt;&lt;/p&gt;
&lt;p&gt;So what that means then is if you're running VSM/VBS with Credential Guard or any other service relying on it, you're actually running two virtual environments on your machine.&lt;/p&gt;
&lt;p&gt;These are...hybrid VMs if you will. They exist as different modes of the same Windows installation. You have two versions of Windows running side by side. Except one is more locked down than the other.&lt;/p&gt;
&lt;p&gt;These VMs are isolated into things we call Virtual Trust Levels. VTL 0 is normal world. It runs all your usual stuff. Your kernel, LSA, explorer, your browser, etc. Regardless of whether you have VSM running or not your stuff runs in VTL 0.&lt;/p&gt;
&lt;p&gt;But with VSM enabled we have another VTL -- VTL 1. This is secure world. It runs a different instance of your kernel, but highly optimized for just a special purpose, as well as a separate user mode also highly optimized for a special purpose.&lt;/p&gt;
&lt;p&gt;Think of VTL 1 as a side kick. Not quite the hero. Doesn't do everything the hero does, but is super useful in a pinch.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We'll stop using this analogy now because that's as far as it can be taken.&lt;/p&gt;
&lt;p&gt;So lets recap. Have secrets living in user mode, can be accessed by evil things running as the user with a little bit of effort. Have virtual secure mode, cannot be accessed by evil things running as the user.&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;With me so far?&lt;/p&gt;
&lt;p&gt;What if we moved those secrets out of user mode and into virtual secure mode so evil things can't access them?&lt;/p&gt;
&lt;p&gt;And so Credential Guard was born.&lt;/p&gt;
&lt;p&gt;&lt;img style="text-align: center; float: left;" src="https://syfuhsblog.blob.core.windows.net:443/images/blobid0_637424620754224446.png" alt="EoL2Pb2VQAAUuvV.png" width="338" height="147" data-filename="EoL2Pb2VQAAUuvV.png" /&gt;Credential Guard is this thing called LsaIso.exe. It's the isolated version of LSA because it lives in Isolated User Mode, AKA user mode of VTL 1 (as opposed to regular user mode in VTL 0).&lt;/p&gt;
&lt;p&gt;Processes that run in VTL 1 IUM are normal processes. They're exe's compiled to x64. They're just special in that they don't get to rely on a lot of stuff normally found in Windows.&lt;/p&gt;
&lt;p&gt;Because VSM runs as this hybrid thing, it shares certain resources between VTL 0 and 1, such as the process list. The IUM processes are projected into your process list, which is why you can see it. Sorta. It lets you see some things, but not everything. Also can't kill 'em.&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net:443/images/blobid2_637424621309724232.png" alt="EoL38E6VQAAYWoQ.png" width="449" height="599" data-filename="EoL38E6VQAAYWoQ.png" /&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net:443/images/blobid3_637424621309820869.png" alt="EoL38E6VQAAYWoQ.png" width="433" height="586" data-filename="EoL38E6VQAAYWoQ.png" /&gt;&lt;img src="https://syfuhsblog.blob.core.windows.net:443/images/blobid4_637424621309904209.png" alt="EoL38E6VQAAYWoQ.png" width="433" height="586" data-filename="EoL38E6VQAAYWoQ.png" /&gt;&lt;/p&gt;
&lt;p&gt;When your VTL 1 starts up it eventually starts LSA. LSA is this thing that manages all the security on your machine, and is where all your secrets normally live in memory.&lt;/p&gt;
&lt;p&gt;As it starts up LSA checks for Credential Guard. One of the shared resources between VTL 0 and VTL 1 is a communications channel -- RPC. It's always RPC. Even when it never leaves the box it's RPC or it's special friend LPC, but it's still RPC.&lt;/p&gt;
&lt;p&gt;And this communications channel is locked down. Only VTL 0 SYSTEM services can communicate over it, which LSA is, so your run of the mill evil thing can't talk to it. It requires a bit more effort if you're evil.&lt;/p&gt;
&lt;p&gt;Anyway, this RPC channel is built in such a way that it acts as an oracle. You ask it a question and it gives you a weird answer. This is important because we have to be careful about what it leaks into normal user mode because evil things.&lt;/p&gt;
&lt;p&gt;What kind of questions can you ask it? Well, lets walk through a logon first for context.&lt;/p&gt;
&lt;p&gt;Way back in the beginning of time I wrote that thread about password logon. You type your password into the textbox. This textbox lives in VTL 0 normal user mode.&amp;nbsp;&lt;a href="https://syfuhs.net/what-happens-when-you-type-your-password-into-windows"&gt;What Happens When you Type Your Password into Windows? (syfuhs.net)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The password is passed to LSA, and LSA hands it off to Credential Guard. You're doing Kerberos so you also pass a flag saying "heeeeeey can you give me the stuff I need to make Kerberos work".&lt;/p&gt;
&lt;p&gt;And so Cred Guard does. You gave it some data, told it to encrypt it using the password, and out came the encrypted goo and a handle to the secret. You never see the secret again.&lt;/p&gt;
&lt;p&gt;This is one of those important things to note: the password is unprotected for a brief period of time, but once it's in Cred Guard it's safe, as opposed to stuck around in memory forever.&lt;/p&gt;
&lt;p&gt;Anyway, no LSA has this encrypted goo. Can't reeeeeally do anything with it so it fires it off to KDC. The KDC does it's normal Kerberos thing and returns a TGT encrypted to the user's password.&lt;/p&gt;
&lt;p&gt;Aha, but LSA doesn't have the password anymore. What do? LSA passes this encrypted blob to Credential Guard, plus the handle to the password and asks Cred Guard nicely to decrypt the blob. And it does, returning to it *most* of the important stuff.&lt;/p&gt;
&lt;p&gt;The one thing it doesn't return to LSA is the TGT session key. Or rather, it returns the session key but encrypted to a key only known to Cred Guard, so if someone could steal the blob out of memory it'd be useless.&lt;/p&gt;
&lt;p&gt;Now the machine needs a service ticket to itself, or the user is opening a file share or whatever it is people do.&lt;/p&gt;
&lt;p&gt;LSA has this TGT (useless on it's own) plus the session key (super important) that's been encrypted to a key it can't use. LSA fires a request off to the KDC and KDC does it's thing, responding with a service ticket, encrypted to the TGT session key. Can you guess what's next?&lt;/p&gt;
&lt;p&gt;Only the session key can decrypt to response, and only Credential Guard can decrypt the session key. So LSA hands it both and asks it nicely to decrypt the thing. It does, returns the decrypted service ticket to LSA, which hands it off to the caller, and then off to the app.&lt;/p&gt;
&lt;p&gt;And that's all Credential Guard does. You ask it a question and it gives you an answer. But you have to ask the right question.&lt;/p&gt;
&lt;p&gt;This is why these legacy and annoying APIs don't work anymore. They ask the question, but don't supply all the right details and get back a weird answer. It's not exactly wrong, just...not useful.&lt;/p&gt;
&lt;p&gt;This is also why certain things are outright broken by design. Legacy protocols like MS-CHAP that make it super easy to reverse the password through cryptoanalysis are blocked because it breaks the guarantee Credential Guard provides.&lt;/p&gt;
&lt;p&gt;Not to mention unconstrained delegation. We're trying to protect your TGT from being stolen and used on other machines. Unconstrained delegation is Stealing Your TGT as a Service (PS, that's the name of my new consulting firm).&lt;/p&gt;
&lt;p&gt;Now all of this hinges on the fact that you have a user mode process in user world communicating with secure world. As an attacker why don't I just turn that off?&lt;/p&gt;
&lt;p&gt;Well, yeah. You can do that. At some point you can tamper with the machine enough that it's not really your machine anymore. We can make it a lot harder to do though.&lt;/p&gt;
&lt;p&gt;Remember LSA PPL? It prevents stuff from tampering with LSA. That goes a long way to protecting the LSA, but isn't perfect because you can bypass it through the kernel. Thanks to another VSM feature you *can* protect it: HVCI. HVCI watches kernel mode memory for modifications.&lt;/p&gt;
&lt;p&gt;We did a whole thing about this last year:&amp;nbsp;&lt;a href="https://techcommunity.microsoft.com/t5/windows-it-pro-blog/comprehensive-protection-for-your-credentials-with-credential/ba-p/765314"&gt;Comprehensive protection for your credentials with Credential Guard and HVCI - Microsoft Tech Community&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Anyway, that's Credential Guard. It's a relatively small feature, but an incredibly useful tool for protecting your user secrets.&lt;/p&gt;</description>
  <author>site@syfuhs.net</author>
  <category>Windows</category>
  <category>Credential Guard</category>
  <category>Security</category>
  <category>Twitter Thread</category>
  <category>Authentication</category>
  <guid isPermaLink="false">https://syfuhs.net/how-windows-defender-credential-guard-works</guid>
  <pubDate>Tue, 01 Dec 2020 23:34:00 GMT</pubDate>
</item></channel>
</rss>