{"id":324,"date":"2020-10-18T13:06:50","date_gmt":"2020-10-18T12:06:50","guid":{"rendered":"http:\/\/www.labtinker.net\/?p=324"},"modified":"2020-10-18T13:06:50","modified_gmt":"2020-10-18T12:06:50","slug":"the-five-trials-of-kerberos","status":"publish","type":"post","link":"http:\/\/18.135.13.153\/?p=324","title":{"rendered":"The Five Trials of Kerberos"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I said in my previous post I would discuss how I\u2019d got the Kerberos lab working. The thing is my notes were scrappy and instead of tidying them up it came to me that I\u2019d created a common real-world scenario: a poorly-documented system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Often such systems are encountered by operations staff when said systems are no longer working so let&#8217;s break things and see what needs to happen to fix them.  (If you want to go hard-core you could try setting your alarm for 2 a.m and pretend it&#8217;s a call from the service desk before reading the rest of the post)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But here are some pointers. For Kerberos authentication to work, the <strong>Firefox browser<\/strong> needed a setting changed:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/thycotic.force.com\/support\/s\/article\/Configuring-Firefox-for-Integrated-Windows-Authentication\">https:\/\/thycotic.force.com\/support\/s\/article\/Configuring-Firefox-for-Integrated-Windows-Authentication<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;and the <strong>IIS webserver<\/strong> needed configuring:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/woshub.com\/configuring-kerberos-authentication-on-iis-website\/\">http:\/\/woshub.com\/configuring-kerberos-authentication-on-iis-website\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A couple of things needed to happen on the KDC but they&#8217;re covered in the link above as I recall.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have grandly titled these five scenarios as the The Five Trials of Kerberos just because we\u2019ve got &nbsp;a bit of a mythological thing going on and it&#8217;s got a ring to it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The First Trial<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You browse to the website and you see&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"569\" height=\"229\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-12.png\" alt=\"\" class=\"wp-image-325\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-12.png 569w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-12-300x121.png 300w\" sizes=\"auto, (max-width: 569px) 100vw, 569px\" \/><figcaption>Figure 1: 401 error.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You break out Wireshark to see what&#8217;s going on and you see&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"514\" height=\"98\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-14.png\" alt=\"\" class=\"wp-image-327\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-14.png 514w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-14-300x57.png 300w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/><figcaption>Figure 2: Time to break out Google.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This one&#8217;s an easy one; all answers at the bottom of the post<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The Second Trial<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You browse to the website and see\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-15.png\" alt=\"\" class=\"wp-image-328\" width=\"598\" height=\"155\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-15.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-15-300x78.png 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><figcaption>Figure 3: Not again!<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">There are no Kerberos packets in the trace this time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The Third Trial<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now this trial is a little unusual in that I did something that broke Kerberos but the website continued working and authentication was happening. I was a little surprised by this myself though it made sense when I worked out what was going on. Anyway, the Kerberos error was this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"523\" height=\"87\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-16.png\" alt=\"\" class=\"wp-image-329\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-16.png 523w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-16-300x50.png 300w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><figcaption>Figure 4: Kerberos Error<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If I showed much more of the trace then you\u2019d probably work out what was going on and it is supposed to be a trial\u2026. &nbsp;so instead I\u2019ll tell you that if the webserver was busy you would notice the authentication server&#8217;s CPU usage has gone up compared to its usual baseline.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The Fourth Trial<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This follows the pattern of the previous trial in that Kerberos stops working but access to the website continued for the same reasons as above. However, this time there was more in the Kerberos trace:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"170\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-17.png\" alt=\"\" class=\"wp-image-330\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-17.png 506w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-17-300x101.png 300w\" sizes=\"auto, (max-width: 506px) 100vw, 506px\" \/><figcaption>Figure 5:  Skew what now?<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Of the Kerberos errors supplied thus far these are probably the least helpful.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Fifth Trial<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fifth and final trial is the trickiest as you might expect. You\u2019d probably need to be fairly unlucky to see this one in the wild\u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This time it\u2019s properly broken\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-18.png\" alt=\"\" class=\"wp-image-331\" width=\"602\" height=\"111\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-18.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-18-300x55.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 6: Credentials please!<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">There\u2019s no Kerberos at all in the Wireshark trace. There is an attempt at NTLM but obviously that\u2019s not good enough.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"84\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-19.png\" alt=\"\" class=\"wp-image-332\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-19.png 689w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-19-300x37.png 300w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><figcaption>Figure 7: Will this do?<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I won&#8217;t dwell on this one and so to the answers&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Answer One<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The ticket is not yet valid. This is because I moved the time ahead on the KDC server. Kerberos will give you 5 minutes leeway but I moved it ahead an hour. If the client time is behind you will see the error.. I tried this the other way around\u2026  so the client was at 9:35 am and the KDC at 7:34 am and the authentication still worked!!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I put this down to the token being&nbsp; within the valid time range. There are probably ways to stop this happening but we&#8217;ll move on..<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"186\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-20.png\" alt=\"\" class=\"wp-image-333\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-20.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-20-300x93.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 8: Well, it&#8217;s in the range<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Answer Two<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The eagle-eyed amongst you would have noticed the website was not being accessed by the URL &apos;web.labtinker.net&apos; but instead &apos;18.135.13.153\/&apos;  for which a CNAME entry had been created. It is possible to get to the website by a different URL but more work needs to be done. More on this later.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Answer Three<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On this occasion I had deleted the SPN on the KDC by using the command:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Setspn -d HTTP\/web.labtinker.net iis_kerb<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This meant there was no mapping between a service principal and a user. The authentication carried on working because NTLM took over when Kerberos failed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"586\" height=\"200\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-21.png\" alt=\"\" class=\"wp-image-334\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-21.png 586w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-21-300x102.png 300w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><figcaption>Figure 9: Kerberos is a no-no but NTLM worked.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When you specify negotiation schemes you can\u2019t explicitly specify \u2018Kerberos\u2019 but instead specify \u2018negotiate\u2019 and this will try Kerberos then try NTLM. In Trials 1 and 2 there was no failback to NTLM, in this trial there was\u2026 not altogether sure why the difference in behaviour.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This does lead us on to spn\u2019s. To make the negotiation work for <a href=\"http:\/\/www.labtinker.net\">18.135.13.153\/<\/a> we have to do the three following things:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\/ Set up a DNS A record for <a href=\"http:\/\/www.labtinker.net\">18.135.13.153\/<\/a> &nbsp;(CNAME didn\u2019t cut it)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\/ For firefox add it to the following parameter in &#8216;about:config&#8217;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"29\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-22.png\" alt=\"\" class=\"wp-image-335\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-22.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-22-300x14.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3\/ Input the following setspn command where iis_kerb is a domain user.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"42\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-23.png\" alt=\"\" class=\"wp-image-336\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-23.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-23-300x21.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 10<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then when we browse an d get authenticated see a ticket containing  the  18.135.13.153\/ URL.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"77\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-24.png\" alt=\"\" class=\"wp-image-337\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-24.png 605w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-24-300x38.png 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><figcaption>Figure 11: Token with 18.135.13.153\/<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Answer Four<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I saw this error when I disabled the AD account \u2018iis_kerb\u2019 which the setspn statement maps to. The website continued to be authenticated because like in Trial 3 authentication failed back to using NTLM<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Answer Five<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For this particular error I went into the configuration of the webserver itself and into the IIS configuration. I right-clicked on &#8216;Windows Authentication&#8217; which is set correctly to issue the HTTP 401 Challenge<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"103\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-25.png\" alt=\"\" class=\"wp-image-338\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-25.png 469w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-25-300x66.png 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><figcaption>Figure 12<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then I got this&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"188\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-26.png\" alt=\"\" class=\"wp-image-339\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-26.png 527w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/10\/image-26-300x107.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><figcaption>Figure 13:<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here, I unticked &#8216;Enable Kernel-mode&#8217; authentication. I must admit at the time I speed-read this as Kerberos, not Kernel but it still broke authentication!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I said in my previous post I would discuss how I\u2019d got the Kerberos lab working. The thing is my notes were scrappy and instead of tidying them up it came to me that I\u2019d created a common real-world scenario: a poorly-documented system. Often such systems are encountered by operations staff when said systems are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-324","post","type-post","status-publish","format-standard","hentry","category-authentication"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=324"}],"version-history":[{"count":0,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/324\/revisions"}],"wp:attachment":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}