{"id":45455,"date":"2024-10-21T14:06:07","date_gmt":"2024-10-21T18:06:07","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=45455"},"modified":"2024-10-21T14:06:07","modified_gmt":"2024-10-21T18:06:07","slug":"tcc-and-gatekeeper-bypasses","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2024\/10\/21\/tcc-and-gatekeeper-bypasses\/","title":{"rendered":"TCC and Gatekeeper Bypasses"},"content":{"rendered":"<p><a href=\"https:\/\/wojciechregula.blog\/post\/change-home-directory-and-bypass-tcc-aka-cve-2020-27937\/\">Wojciech Regu&#x142;a<\/a> (September 2021, <a href=\"https:\/\/twitter.com\/_r3ggi\/status\/1436052132592029697\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/wojciechregula.blog\/post\/change-home-directory-and-bypass-tcc-aka-cve-2020-27937\/\">\n<p>I was looking for code injection opportunities that may allow reaching TCC bypasses. My simple shell script discovered a potential victim - <code>\/System\/Library\/CoreServices\/Applications\/Directory Utility.app<\/code>. It had (and has) the following private TCC entitlement[&#8230;] This entitlement allows the Directory Utility to modify the user&rsquo;s records stored in the <code>\/var\/db\/dslocal\/nodes<\/code> directory.<\/p>\n<p>[&#8230;]<\/p>\n<p>After some time I stumbled across the above-mentioned Matt Shockley&rsquo;s article on how he was able to bypass TCC only by changing the <code>$HOME<\/code> directory via <code>launchctl<\/code>. I was really curious about how Apple fixed that vulnerability so I started reversing the TCC. Turns out that now TCC takes the information about the user&rsquo;s home directory from the <code>getpwuid<\/code> function.<\/p>\n<p>[&#8230;]<\/p>\n<p>I was really shocked that Apple decided that this vulnerability is not eligible for the bounty. [They later changed their mind.]<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/wojciechregula.blog\/post\/macos-red-teaming-bypass-tcc-with-old-apps\/\">Wojciech Regu&#x142;a<\/a> (March 2022):<\/p>\n<blockquote cite=\"https:\/\/wojciechregula.blog\/post\/macos-red-teaming-bypass-tcc-with-old-apps\/\"><p>This post shows how to bypass the macOS privacy framework (TCC) using old app versions.<\/p><p>[&#8230;]<\/p><p>Summing it up - there is no version information. It is exactly the same architectonical problem as the macOS Keychain has. In most cases it is possible to get an older version of the &ldquo;donor&rdquo; application (without the hardened runtime flag), inject to it, and thus abuse its TCC permissions.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/www.sentinelone.com\/blog\/session-cookies-keychains-ssh-keys-and-more-7-kinds-of-data-malware-steals-from-macos-users\/\">Phil Stokes<\/a> (March 2023):<\/p>\n<blockquote cite=\"https:\/\/www.sentinelone.com\/blog\/session-cookies-keychains-ssh-keys-and-more-7-kinds-of-data-malware-steals-from-macos-users\/\"><p>The scourge of ransomware attacks that has plagued Windows endpoints over the past half decade or so has, thankfully, not been replicated on Mac devices. With a few unsuccessful exceptions, the notion of locking a Mac device and holding its owner to ransom in return for access to the machine and its data has not yet proven an attractive proposition for attackers.<\/p><p>However, the idea of <a href=\"https:\/\/www.sentinelone.com\/blog\/ransoms-without-ransomware-data-corruption-and-other-new-tactics-in-cyber-extortion\/\">stealing valuable data and then monetizing it<\/a> in nefarious ways is a tactic that is now common across platforms. On macOS, threat actors will quietly exfiltrate session cookies, keychains, SSH keys and more as malicious processes from adware to <a href=\"https:\/\/www.sentinelone.com\/cybersecurity-101\/what-is-spyware\/\">spyware<\/a> look to harvest data that can be recycled and sold on various <a href=\"https:\/\/www.sentinelone.com\/blog\/more-evil-markets-how-its-never-been-easier-to-buy-initial-access-to-compromised-networks\/\">underground forums<\/a> and marketplaces, or used directly in espionage campaigns and <a href=\"https:\/\/www.sentinelone.com\/labs\/cratedepression-rust-supply-chain-attack-infects-cloud-ci-pipelines-with-go-malware\/\">supply chain attacks<\/a>.<\/p><p>[&#8230;]<\/p><p>Session cookies can be stored anywhere, but typically they are in locations which can be accessed by the user or a process running as the user. Some locations, such as the User&rsquo;s Library Cookies folder, may be restricted by <a href=\"https:\/\/www.sentinelone.com\/labs\/bypassing-macos-tcc-user-privacy-protections-by-accident-and-design\/\">TCC<\/a> unless the parent process has <a href=\"https:\/\/www.sentinelone.com\/labs\/bypassing-macos-tcc-user-privacy-protections-by-accident-and-design\/\">Full Disk Access<\/a> or uses one of the many known <a href=\"https:\/\/www.sentinelone.com\/blog\/mojaves-security-hardening-user-protections-bypassed\/\">TCC bypasses<\/a>. Real world attacks (e.g., <a href=\"https:\/\/www.sentinelone.com\/blog\/xcsset-malware-update-macos-threat-actors-prepare-for-life-without-python\/\">XCSSET<\/a>) and <a href=\"https:\/\/github.com\/acheong08\/CVE-2022-26726-POC\">researchers<\/a> have <a href=\"https:\/\/www.blackhat.com\/us-21\/briefings\/schedule\/index.html#-ways-to-bypass-your-macos-privacy-mechanisms-23133\">consistently<\/a> shown that TCC, while often a nuisance to users, does not present a significant obstacle to attackers.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/jhftss.github.io\/macOS-AUHelperService-Full-TCC-Bypass\/\">Mickey Jin<\/a> (January 2024):<\/p>\n<blockquote cite=\"https:\/\/jhftss.github.io\/macOS-AUHelperService-Full-TCC-Bypass\/\"><p>Last year, I discovered a full user TCC bypass issue in the macOS Sonoma beta version. There was a CVE number assigned at the beginning, but removed by Apple in the release of macOS 14.0. Instead, I got the credit in their <a href=\"https:\/\/support.apple.com\/HT213940\">Additional Recognitions<\/a>.<\/p><p>According to the Apple Security Bounty program, this report should have been rewarded with an additional 50%. Unfortunately, the truth is that I was cut off 50%.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/wojciechregula.blog\/post\/tcc-bypasses-via-launch-services\/\">Wojciech Regu&#x142;a<\/a>:<\/p>\n<blockquote cite=\"https:\/\/wojciechregula.blog\/post\/tcc-bypasses-via-launch-services\/\"><p>This vulnerability was disclosed at Black Hat Europe 2022 in the talk <a href=\"https:\/\/www.blackhat.com\/eu-22\/briefings\/schedule\/#knockout-win-against-tcc---20-new-ways-to-bypass-your-macos-privacy-mechanisms-29272\">Knockout Win Against TCC - 20+ NEW Ways to Bypass Your MacOS Privacy Mechanisms<\/a>. The technique used an old Launch Services function <a href=\"https:\/\/developer.apple.com\/documentation\/coreservices\/1444955-lssetdefaultrolehandlerforconten?language=objc\">LSSetDefaultRoleHandlerForContentType<\/a> that allowed (without any restrictions) to register arbitrary applications for handling specified UTI handlers. After the UTI handling app registration, the exploit simply opens juicy files (like AddressBook or iMessages database) and TCC happily grants access to them. At that time TCC couldn&rsquo;t recognize correctly if a file was opened by launch services or double-clicked by a user.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/wojciechregula.blog\/post\/multiple-tcc-bypasses-via-sqlite-env-vars\/\">Wojciech Regu&#x142;a<\/a>:<\/p>\n<blockquote cite=\"https:\/\/wojciechregula.blog\/post\/multiple-tcc-bypasses-via-sqlite-env-vars\/\">\n<p>The technique relied on an SQLite environment variable respected by <code>libsqlite3.dylib<\/code> which made apps using the standard SQLite system API log all the SQL queries. As such queries may contain sensitive user data normally protected by the TCC - I started researching all the problematic occurrences.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/unit42.paloaltonetworks.com\/gatekeeper-bypass-macos\/\">Unit 42<\/a>:<\/p>\n<blockquote cite=\"https:\/\/unit42.paloaltonetworks.com\/gatekeeper-bypass-macos\/\"><p><a href=\"https:\/\/developer.apple.com\/forums\/thread\/706442\">Apple states<\/a> that user-installed unarchiving tools preserve quarantine. As we can see in the following examples, there are some third-party archive tools that do not enforce that, which means that Gatekeeper won&rsquo;t scan the extracted files.<\/p><p>[&#8230;]<\/p><p>In VMware Fusion, when copying a file from a host machine to a guest macOS virtual machine (VM) using VMware tools, the quarantine extended attribute will be dropped from the copied file as shown in Figure 4. This means Gatekeeper won&rsquo;t scan any files copied into the virtual machine.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/www.microsoft.com\/en-us\/security\/blog\/2024\/10\/17\/new-macos-vulnerability-hm-surf-could-lead-to-unauthorized-data-access\/\">Microsoft Threat Intelligence<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.microsoft.com\/en-us\/security\/blog\/2024\/10\/17\/new-macos-vulnerability-hm-surf-could-lead-to-unauthorized-data-access\/\"><p>The vulnerability, which we refer to as &ldquo;HM Surf&rdquo;, involves removing the TCC protection for the Safari browser directory and modifying a configuration file in the said directory to gain access to the user&rsquo;s data, including browsed pages, the device&rsquo;s camera, microphone, and location, without the user&rsquo;s consent.<\/p><p>[&#8230;]<\/p><p>Our exploit involves the following steps:<\/p><ol><li>Change the home directory of the current user with the <a href=\"https:\/\/ss64.com\/mac\/dscl.html\">dscl<\/a> utility, which does not require TCC access in Sonoma (At this point, the <em>~\/Library\/Safari<\/em> directory is no longer TCC protected).<\/li><li>Modify the sensitive files under the user&rsquo;s real home directory (such as <em>\/Users\/$USER\/Library\/Safari\/PerSitePreferences.db<\/em>).<\/li><li>Change the home directory again so Safari uses the now modified files.<\/li><li>Run Safari to open a webpage that takes a camera snapshot and trace device location.<\/li><\/ol><\/blockquote>\n\n<p><a href=\"https:\/\/nsantoine.dev\/TCCPaper.pdf\">Osama Alhour<\/a> (PDF, <a href=\"https:\/\/x.com\/fileintegrity\/status\/1847253963868897746\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/nsantoine.dev\/TCCPaper.pdf\"><p>This paper seeks to provide a comprehensive technical analysis of how TCC works internally, how it interacts with other system components, and it&rsquo;s impact on both how developers shape their applications as well as user control granting sensitive data to applications.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/06\/07\/no-bounty-for-kaspersky\/\">No Bounty for Kaspersky<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/05\/14\/no-bounty-for-kernel-vulnerability\/\">No Bounty for Kernel Vulnerability<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/02\/19\/reporting-a-full-disk-access-bug-to-apple\/\">Reporting a Full Disk Access Bug to Apple<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/12\/05\/powerdir-macos-tcc-vulnerability\/\">Powerdir macOS TCC Vulnerability<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/07\/13\/overview-of-tcc-bypasses-by-accident-and-design\/\">Overview of TCC Bypasses by Accident and Design<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/06\/04\/tcc-bypass-in-xcsset-malware\/\">TCC Bypass in XCSSET Malware<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Wojciech Regu&#x142;a (September 2021, tweet): I was looking for code injection opportunities that may allow reaching TCC bypasses. My simple shell script discovered a potential victim - \/System\/Library\/CoreServices\/Applications\/Directory Utility.app. It had (and has) the following private TCC entitlement[&#8230;] This entitlement allows the Directory Utility to modify the user&rsquo;s records stored in the \/var\/db\/dslocal\/nodes directory. [&#8230;] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2024-10-21T18:06:10Z","apple_news_api_id":"4071b737-c9e5-41df-9de9-de6fc73e0573","apple_news_api_modified_at":"2024-10-21T18:06:10Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AQHG3N8nlQd-d6d5vxz4Fcw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[2098,131,2095,1902,465,438,30,2077,2385,2598,103,48,425,1960,2251,2673],"class_list":["post-45455","post","type-post","status-publish","format-standard","hentry","category-technology","tag-apple-security-bounty","tag-bug","tag-exploit","tag-extended-attributes","tag-gatekeeper","tag-launchservices","tag-mac","tag-macos-12","tag-macos-14-sonoma","tag-macos-15-sequoia","tag-safari","tag-security","tag-sqlite","tag-transparency-consent-and-control-tcc","tag-virtualization","tag-zip-archive"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/45455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=45455"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/45455\/revisions"}],"predecessor-version":[{"id":45456,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/45455\/revisions\/45456"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=45455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=45455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=45455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}