{"id":1277,"date":"2022-11-03T15:58:32","date_gmt":"2022-11-03T20:58:32","guid":{"rendered":"https:\/\/www.brunerd.com\/blog\/?p=1277"},"modified":"2024-02-05T16:48:58","modified_gmt":"2024-02-05T21:48:58","slug":"detecting-and-affecting-lockdown-mode-in-macos-ventura","status":"publish","type":"post","link":"https:\/\/www.brunerd.com\/blog\/2022\/11\/03\/detecting-and-affecting-lockdown-mode-in-macos-ventura\/","title":{"rendered":"Detecting and affecting Lockdown Mode in macOS Ventura"},"content":{"rendered":"\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/support.apple.com\/HT212650\" target=\"_blank\">Lockdown mode<\/a> is new feature for macOS Ventura and for many MacAdmins we&#8217;ve been wondering how to detect this state. Why? Lockdown mode affects how macOS and Mac apps behave. This is something a helpdesk might like to know when trying to troubleshoot an issue. Also, due to some ambiguous wording by Apple, they made it seem like MDM Config Profiles could not be installed <em>at all<\/em> when in Lockdown mode, however this is not always the case. The hunt was on!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Detecting Lockdown Mode<\/h2>\n\n\n\n<p>I was looking <em>everywhere<\/em> last week: <code>ps<\/code> process lists, <code>nvram<\/code>, <code>system_profiler<\/code>, <code>kextstat<\/code>, <code>launchctl<\/code>, <code>sysdiagnose<\/code>, a <code>defaults read<\/code> dump, etc. I was looking high and low for &#8220;lock&#8221; &#8220;down&#8221; and &#8220;mode&#8221; and I got a hit in the <code>com.apple.Safari<\/code> domain in the sandboxed <code>~\/Library\/Containers\/Safari<\/code> path. While it turns out that Safari will in <em>some cases<\/em> write the button label <code>LockdownModeToolbarIdentifier<\/code> to that pref domain, it requires Safari to be launched <em>and<\/em> for the toolbar to be in non-default layout, otherwise the label name is never written! So that was a dead end.<\/p>\n\n\n\n<p>Then a little birdie on MacAdmins pointed me in the right direction and <a rel=\"noreferrer noopener\" href=\"https:\/\/snelson.us\/2022\/10\/macos-venturas-lockdown-mode-mdm-the-enterprise\/#02-nov-2022\" target=\"_blank\">blogged<\/a> about it and wrote a Jamf extension attribute! \ud83d\ude05 Turns out I had missed the value sitting at the top of the <code>defaults read<\/code> dump! (d&#8217;oh) It was there the whole time in .GlobalPreferences, I just hadn&#8217;t done a <code>diff<\/code> like I should have! <em>That<\/em> would have revealed the key uses the <code>LDM<\/code> acronym\/mnemonic: <code>LDMGlobalEnabled<\/code> Funnily enough, when I searched for this key on Google I got 5 hits and all of them for <strong>iOS<\/strong>, like <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.apple.com\/forums\/thread\/710176\" target=\"_blank\">this one<\/a> at the Apple dev forums. However they were all about Swift and iOS, here&#8217;s how to do it in shell for the current user:<\/p>\n\n\n\n<pre id=\"language-bash\" class=\"wp-block-code\"><code>defaults read .GlobalPreferences.plist LDMGlobalEnabled 2&gt;\/dev\/null<\/code><\/pre>\n\n\n\n<p>It&#8217;s a boolean value, that will not exist if Lockdown mode has never been enabled, when enabled it will report <code>1<\/code> from <code>defaults<\/code> and when disabled the key will remain and report <code>0<\/code>. What stands out is that this is a per-user preference. Since it makes you reboot I had <em>supposed<\/em> it was a system-wide setting but sure enough if you log out and into another user, Lockdown mode is disabled. Perhaps that makes sense but I&#8217;m not quite sure about that? <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Affecting Lockdown Mode<\/h2>\n\n\n\n<p>This totally blew me away: <strong>You can enable and disable macOS Lockdown mode by writing to your .GlobalPreferences preference domain!<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#turn lockdown mode off\ndefaults write .GlobalPreferences.plist LDMGlobalEnabled -bool false\n#turn lockdown mode on\ndefaults write .GlobalPreferences.plist LDMGlobalEnabled -bool true<\/code><\/pre>\n\n\n\n<p>That&#8217;s right, it&#8217;s not written to a rootless\/SIP protected file like TCC.db! Just run the command as the user and it&#8217;ll turn toggle the behavior for most things. Here&#8217;s some details of my findings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Configuration profiles<\/strong> &#8211; a restart of <strong>System Settings<\/strong> is not required, it will prohibit the manual installation of a .mobileconfig profile file. When Apple says &#8220;Configuration profiles can\u2019t be installed&#8221; this is what they mean: <strong>User installed<\/strong> &#8220;double-click&#8221; installations of .mobileconfig files <em>cannot<\/em> be done. When they say &#8220;the device can\u2019t be enrolled in Mobile Device Management or device supervision while in Lockdown Mode&#8221;, this <em>only<\/em> applies to these user-initiated MDM enrollments using a web browser that downloads .mobileconfig files. Lockdown mode <strong>does not <\/strong>prohibit enrollment into MDM that&#8217;s assigned via Apple Business Manager (ABM\/DEP). You can initiate enrollment with the Terminal command: <code>sudo profiles renew -type enrollment<\/code> A Mac in Lockdown mode will be able to successfully enroll into an MDM assigned by ABM. Once enrolled, new Config Profiles can also be installed via that same MDM, even in Lockdown Mode.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Systrem-Settings-Lockdown-MDM-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"249\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Systrem-Settings-Lockdown-MDM-1.png\" alt=\"\" class=\"wp-image-1289\"\/><\/a><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Messages<\/strong> &#8211; a restart of Messages is not required, <strong>all messages<\/strong> will be blocked immediately, attachments or not. I&#8217;m not sure if that&#8217;s a bug or not since Apple only mentions attachments, not plain messages. It does not matter if the sender is in your Contacts or whether you have initiated contact with them before (like in Facetime). Messages will be delivered to any other devices not in Lockdown mode. If Lockdown mode is turned off, those blocked messages <em>may<\/em> be delivered if sent recently enough but will appear out of sequence. For example, a device that never had Lockdown Mode turned on would see messages: 1,2,3,4,5 while a device that turns it on and then off would see: 1,2,5,<strong>3,4<\/strong><\/li>\n\n\n\n<li><strong>Facetime<\/strong> &#8211; restart not required, it will immediately begin blocking calls from anyone you have not called previously from that device. Unlike Messages though, it <em>will<\/em> show a Notification of the blockage.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Blocked-FaceTime.png\"><img loading=\"lazy\" decoding=\"async\" width=\"702\" height=\"146\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Blocked-FaceTime.png\" alt=\"\" class=\"wp-image-1279\" style=\"width:399px;height:83px\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Blocked-FaceTime.png 702w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Blocked-FaceTime-300x62.png 300w\" sizes=\"auto, (max-width: 702px) 100vw, 702px\" \/><\/a><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Safari<\/strong> &#8211; app restart <em>required<\/em>. This differs from everything else, however Safari also gives the best visual indications that Lockdown mode is enabled! On the Start Page you&#8217;ll see &#8220;Lockdown Ready&#8221;, once at at website you&#8217;ll likely see &#8220;Lockdown Enabled&#8221; unless you&#8217;ve uncheck <strong>Enable Lockdown Mode<\/strong> in the top menubar <strong>Safari<\/strong> \u2192 <strong>Settings for &lt;site&gt;&#8230;<\/strong> in which case you&#8217;ll see &#8220;Lockdown Off&#8221; in <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">red<\/mark>.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Safari-Lockdown-States-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"301\" height=\"178\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Safari-Lockdown-States-1.png\" alt=\"\" class=\"wp-image-1290\"\/><\/a><figcaption class=\"wp-element-caption\">Safari&#8217;s Lockdown Mode Toolbar states<\/figcaption><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Safari<\/strong> &#8211; Another subtle visual cue of Lockdown mode, that aligns with Apple&#8217;s &#8220;web fonts might not be displayed&#8221; guidance, can be seen on a Jamf user-initiated MDM enrollment screen, instead of a check mark you&#8217;ll see a square, take heed and turn back now! Since once you get the .mobileconfig files and fumble your way to <strong>System Settings<\/strong> \u2192 <strong>Privacy &amp; Security<\/strong>, scroll to the bottom of the list to <strong>Profiles<\/strong> (UX gripe: it <em>used to<\/em> just open the dang panel when you double clicked on them!) you&#8217;ll be blocked from installing it as seen above.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Jamf-User-Enroll.png\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"277\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Jamf-User-Enroll.png\" alt=\"\" class=\"wp-image-1282\" style=\"width:311px;height:130px\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Jamf-User-Enroll.png 665w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Jamf-User-Enroll-300x125.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>System Settings <\/strong> &#8211; an app restart is required for <strong>Privacy &amp; Security<\/strong> to reflect the current state of <code>LDMGlobalEnabled<\/code>, if it was on and you disable via <code>defaults<\/code> once you launch System Settings again, it&#8217;ll let you turn it back on with a reboot and everything!<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Mode-On.png\"><img loading=\"lazy\" decoding=\"async\" width=\"518\" height=\"645\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Mode-On.png\" alt=\"\" class=\"wp-image-1283\" style=\"width:200px;height:249px\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Mode-On.png 518w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/Lockdown-Mode-On-241x300.png 241w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/a><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>I didn&#8217;t try out the other lockdown mode behaviors for things like new Home management invitations or Shared Albums in Photos.  Still it&#8217;s <em>quite surprising <\/em>that despite the System Settings GUI making you reboot to turn it on, Lockdown mode is a <em>per-user<\/em> setting that can seemingly be enabled and disabled dynamically with a simple <code>defaults<\/code> command run by the user. With the exception of Safari and System Settings it does not require Messages and Facetime to restart! There might be other caveats, it&#8217;s hard to tell. Perhaps this is all in the realm of &#8220;works as designed&#8221; for Apple but when you, the customer, don&#8217;t know what that exact design is, it can be quite a surprise!<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Update:<\/strong><\/span> Looks like they started explaining a bit more about what happens when you enabled Lockdown Mode in macOS Sonoma<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/LockDown-Splash.png\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"1024\" data-id=\"1513\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/LockDown-Splash-989x1024.png\" alt=\"\" class=\"wp-image-1513\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/LockDown-Splash-989x1024.png 989w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/LockDown-Splash-290x300.png 290w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/LockDown-Splash-768x795.png 768w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/LockDown-Splash.png 1430w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">One more (unrelated) thing&#8230;<\/h2>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Update: <\/span><\/strong>As of Dec 13, 2022 <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931\"><strong>Bug&nbsp;174931<\/strong><\/a><strong>&nbsp;&#8211;&nbsp;Implement RegExp lookbehind assertions<\/strong> has been marked &#8220;Resolved&#8221; and the extensive <a href=\"https:\/\/github.com\/WebKit\/WebKit\/pull\/7109\" target=\"_blank\" rel=\"noreferrer noopener\">pull request<\/a> has all the gory details of the extensive refactoring that was done to implement this. \ud83c\udf89 Thanks Michael Saboff! \ud83d\ude4f Now when this will make it into Safari&#8230;. we&#8217;ll see.<\/p>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Update 2:<\/span> <\/strong>Safari 16.4, released March 27, 2023, now supports RegExp lookbehind assertions!<\/p>\n\n\n\n<p>Since this post might get a few eyeballs, I&#8217;d also like to shine a light on the perplexing fact that Safari is the <strong>only<\/strong> browser that <em>still<\/em> doesn&#8217;t support the four year old <strong>ES2018<\/strong> feature of <strong>RegExp lookbehind assertions<\/strong>?! I mean, <em>sure<\/em> it was a <strong><em>Google<\/em><\/strong> engineer who kindly filed this heads up to the WebKit team back in July of 2017 when it was a draft and a full year before it was ratified (<strong><a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931\" target=\"_blank\" rel=\"noreferrer noopener\">Bug\u00a0174931\u00a0&#8211;\u00a0Implement RegExp lookbehind assertions<\/a><\/strong>) but even a silly corporate rivalry couldn&#8217;t explain the seeming obstinance in letting this feature languish. I don&#8217;t get it, it just doesn&#8217;t make sense! There&#8217;s a <a href=\"https:\/\/kangax.github.io\/compat-table\/es2016plus\/\" target=\"_blank\" rel=\"noreferrer noopener\">nicely visualized page<\/a> of where things stand and Safari is keeping company with IE 11 on this one. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/ES-Compat-Table-kangax.github.io_.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"534\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/ES-Compat-Table-kangax.github.io_-1024x534.png\" alt=\"\" class=\"wp-image-1304\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/ES-Compat-Table-kangax.github.io_-1024x534.png 1024w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/ES-Compat-Table-kangax.github.io_-300x157.png 300w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/ES-Compat-Table-kangax.github.io_-768x401.png 768w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/ES-Compat-Table-kangax.github.io_.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Make these red islands green, Apple!<\/figcaption><\/figure>\n\n\n\n<p>So take a look at the comments on the <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931\" target=\"_blank\" rel=\"noreferrer noopener\">WebKit bug<\/a>, some are <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931#c31\" target=\"_blank\" rel=\"noreferrer noopener\">quite<\/a> <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931#c16\" target=\"_blank\" rel=\"noreferrer noopener\">funny<\/a>, others just <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931#c43\" target=\"_blank\" rel=\"noreferrer noopener\">spot<\/a> <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931#c47\" target=\"_blank\" rel=\"noreferrer noopener\">on<\/a>, and there&#8217;s even <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=174931#c15\" target=\"_blank\" rel=\"noreferrer noopener\">one from yours truly<\/a>. Perhaps add your own? Maybe when a bug gets 100 comments something special happens and we all get cake? \ud83c\udf82<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lockdown mode is new feature for macOS Ventura and for many MacAdmins we&#8217;ve been wondering how to detect this state. Why? Lockdown mode affects how macOS and Mac apps behave. This is something a helpdesk might like to know when trying to troubleshoot an issue. Also, due to some ambiguous wording by Apple, they made [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4,12,8],"tags":[25,49,24],"class_list":["post-1277","post","type-post","status-publish","format-standard","hentry","category-apple","category-os-x","category-scripting","category-security","tag-macos","tag-security","tag-shell"],"_links":{"self":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/1277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/comments?post=1277"}],"version-history":[{"count":19,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/1277\/revisions"}],"predecessor-version":[{"id":1514,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/1277\/revisions\/1514"}],"wp:attachment":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/media?parent=1277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/categories?post=1277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/tags?post=1277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}