{"id":30934,"date":"2020-12-07T16:30:25","date_gmt":"2020-12-07T21:30:25","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=30934"},"modified":"2021-07-13T11:53:37","modified_gmt":"2021-07-13T15:53:37","slug":"tcc-doesnt-prevent-protected-folders-from-being-listed","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/12\/07\/tcc-doesnt-prevent-protected-folders-from-being-listed\/","title":{"rendered":"Sandbox Doesn&rsquo;t Protect Files From stat()"},"content":{"rendered":"<p><a href=\"https:\/\/lapcatsoftware.com\/articles\/disclosure3.html\">Jeff Johnson<\/a> (<a href=\"https:\/\/twitter.com\/lapcatsoftware\/status\/1333781184376147968\">tweet<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=25266743\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/lapcatsoftware.com\/articles\/disclosure3.html\"><p>I discovered that an application can use the venerable Unix command-line tool &ldquo;ls&rdquo; (list directory contents) to bypass both TCC (Transparency, Consent, and Control) and the sandbox, enabling unauthorized access to file metadata in directories that are supposed to be protected.<\/p><p>[&#8230;]<\/p><p>It&rsquo;s been almost a year since I reported it to Apple. This is well beyond the bounds of &ldquo;responsible disclosure&rdquo;, which is typically 90 days after reporting an issue to a vendor. I&rsquo;ve never been paid a penny by the Apple Security Bounty Program and doubt I ever will.<\/p><p>[&#8230;]<\/p><p>I chose the example of <code>~\/Library\/Safari\/LocalStorage<\/code> because Safari names the files in this directory according to the web sites that you visit! Also note that the output of long format <code>ls -l<\/code> contains the last modification date of the files. Thus, one possible privacy violation from this technique is to learn the user&rsquo;s web browsing history.<\/p><\/blockquote>\n<p>I sort of discovered this issue by accident a few years ago while tracking down a bug. One of my apps uses Full Disk Access, but there is no API to determine whether that has been granted. Some of my code had been assuming that if it could test whether a particular file in a protected folder existed, it must have Full Disk Access. But it turns out that you can do this even without access.<\/p>\n<p>Apple even sort of <a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsfilemanager\/1415645-fileexistsatpath\">documents this<\/a>, saying for <code>-[NSFileManager fileExistsAtPath:]<\/code> that:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsfilemanager\/1415645-fileexistsatpath\"><p>App Sandbox does not restrict which path values may be passed to this parameter.<\/p><\/blockquote>\n<p>It&rsquo;s not really clear what this means because how could the sandbox prevent you from <em>passing<\/em> a value? So maybe we&rsquo;re meant to assume that it <em>works<\/em> for any value. On the other hand, the documentation goes on to say:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsfilemanager\/1415645-fileexistsatpath\"><p>If the file at <code>path<\/code> is inaccessible to your app, perhaps because one or more parent directories are inaccessible, this method returns <code>NO<\/code>.<\/p><\/blockquote>\n<p>This implies that without access you <em>can&rsquo;t<\/em> test whether a file exists. But my experience is that you <em>can<\/em>. (I&rsquo;ve not looked into whether there&rsquo;s a difference between the sandbox and TCC protections.)<\/p>\n<p>In any event, whether or not Apple considers this a bug, I think it&rsquo;s a real privacy issue. If this is the expected behavior, it should be documented so that apps can be designed with this in mind. Maybe apps that store sensitive data should obscure their filenames.<\/p>\n<p>Secondly, why is Apple still investigating this issue a year later? The engineer who designed this should know whether it&rsquo;s the intended behavior off the top of their head. So the fact that the report didn&rsquo;t immediately come back as &ldquo;not a bug&rdquo; implies that either it is a bug (and one wonders how such a whopper could remain for so long) or that the report is not being actively investigated. Either way, this is more evidence that Apple is not serious about the bug bounty program.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/07\/03\/mount_apfs-tcc-bypass-and-privilege-escalation\/\">mount_apfs TCC Bypass and Privilege Escalation<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/07\/02\/safari-privacy-protections-bypass\/\">Safari Privacy Protections Bypass<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/04\/28\/mac-sandbox-escape-via-textedit\/\">Mac Sandbox Escape via TextEdit<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/12\/20\/mac-bug-bounty-program-opens\/\">Mac Bug Bounty Program Opens<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/10\/09\/file-system-events-privacy-protections-bypass\/\">File System Events Privacy Protections Bypass<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/09\/25\/bypassing-mojave-security-protections\/\">Bypassing Mojave Security Protections<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/09\/10\/mojaves-new-security-and-privacy-protections-face-usability-challenges\/\">Mojave&rsquo;s New Security and Privacy Protections Face Usability Challenges<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jeff Johnson (tweet, Hacker News): I discovered that an application can use the venerable Unix command-line tool &ldquo;ls&rdquo; (list directory contents) to bypass both TCC (Transparency, Consent, and Control) and the sandbox, enabling unauthorized access to file metadata in directories that are supposed to be protected.[&#8230;]It&rsquo;s been almost a year since I reported it to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2020-12-07T21:30:28Z","apple_news_api_id":"35ab0ec3-3e18-429f-b0a4-cf81fa9b560c","apple_news_api_modified_at":"2021-07-13T15:53:41Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAg==","apple_news_api_share_url":"https:\/\/apple.news\/ANasOwz4YQp-wpM-B-ptWDA","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,2095,30,1609,1666,1891,355,71,103,53,1960],"class_list":["post-30934","post","type-post","status-publish","format-standard","hentry","category-technology","tag-apple-security-bounty","tag-exploit","tag-mac","tag-macos-10-14","tag-macos-10-15","tag-macos-11-0","tag-privacy","tag-programming","tag-safari","tag-sandboxing","tag-transparency-consent-and-control-tcc"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/30934","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=30934"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/30934\/revisions"}],"predecessor-version":[{"id":30942,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/30934\/revisions\/30942"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=30934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=30934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=30934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}