{"id":33148,"date":"2021-07-15T16:26:19","date_gmt":"2021-07-15T20:26:19","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=33148"},"modified":"2021-07-15T16:26:19","modified_gmt":"2021-07-15T20:26:19","slug":"leaking-files-with-textedit","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/07\/15\/leaking-files-with-textedit\/","title":{"rendered":"Leaking Files With TextEdit"},"content":{"rendered":"<p><a href=\"https:\/\/www.paulosyibelo.com\/2021\/04\/this-man-thought-opening-txt-file-is.html\">Paulos Yibelo<\/a> (<a href=\"https:\/\/twitter.com\/PaulosYibelo\/status\/1377946422344048640\">tweet<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=26677112\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/www.paulosyibelo.com\/2021\/04\/this-man-thought-opening-txt-file-is.html\"><p>I quickly realized that TextEdit can be tricked into thinking the file opened is an RTF-HTML file even when the file extension is TXT. The ability to inject HTML into a TXT file obviously opened lots of potential attack vectors.<\/p>\n<p>[&#8230;]<\/p>\n<p>I found out the CSS property <code>&lt;style&gt; @import { \"url \"} &lt;\/style&gt;<\/code> was allowed to load local CSS files. However, the only scheme that worked was <tt>file:\/\/\/<\/tt> and not even <tt>http\/s:\/\/<\/tt>. While this means we can&rsquo;t make external requests, it also means we can hit or open other files that are stored locally on the device. This creates a very obvious DOS vulnerability that acts like a blind SSRF by writing a recursive file inclusion or, reading files with infinite data streams like <tt>\/dev\/urandom<\/tt>, <tt>\/dev\/zero<\/tt>. a 2kb text file can crash your mac. COOL, but completely useless.<\/p>\n<p>[&#8230;]<\/p>\n<p>While they did a good job blocking TextEdit from making external requests, [AutoFS] was the one thing they forgot when they allowed <tt>file:\/\/\/<\/tt> scheme, on OSX <tt>file:\/\/\/net\/11.22.33.44\/a.css<\/tt> connects to 11.22.33.44.<\/p>\n<p>[&#8230;]<\/p>\n<p>By combining the <code>&lt;style&gt;<\/code> CSS attribute with the <code>&lt;iframedoc&gt;<\/code> attribute, an attacker can first include an unclosed style tag,  embed the contents of the file they want to steal and then leak the content as dangling parameters to their evil site as soon as the file is open.<\/p>\n<\/blockquote>\n<p>This was <a href=\"https:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2019-8761\">addressed<\/a> in macOS 10.15.1.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/04\/28\/mac-sandbox-escape-via-textedit\/\">Mac Sandbox Escape via TextEdit<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Paulos Yibelo (tweet, Hacker News): I quickly realized that TextEdit can be tricked into thinking the file opened is an RTF-HTML file even when the file extension is TXT. The ability to inject HTML into a TXT file obviously opened lots of potential attack vectors. [&#8230;] I found out the CSS property &lt;style&gt; @import { [&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":"2021-07-15T20:26:22Z","apple_news_api_id":"be227f7f-0f79-40f2-a303-9e1d9377a083","apple_news_api_modified_at":"2021-07-15T20:26:23Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AviJ_fw95QPKjA54dk3eggw","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":[131,2095,465,30,1666,1842,355,48,1050],"class_list":["post-33148","post","type-post","status-publish","format-standard","hentry","category-technology","tag-bug","tag-exploit","tag-gatekeeper","tag-mac","tag-macos-10-15","tag-notarization","tag-privacy","tag-security","tag-textedit"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/33148","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=33148"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/33148\/revisions"}],"predecessor-version":[{"id":33149,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/33148\/revisions\/33149"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=33148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=33148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=33148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}