{"id":25875,"date":"2019-07-08T14:57:41","date_gmt":"2019-07-08T18:57:41","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=25875"},"modified":"2019-07-08T16:08:57","modified_gmt":"2019-07-08T20:08:57","slug":"malformed-imessage-could-brick-iphone","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/07\/08\/malformed-imessage-could-brick-iphone\/","title":{"rendered":"Malformed iMessage Could Cause iPhone Boot Loop"},"content":{"rendered":"<p><a href=\"https:\/\/bugs.chromium.org\/p\/project-zero\/issues\/detail?id=1826\">Project Zero<\/a> (via <a href=\"https:\/\/news.ycombinator.com\/item?id=20379594\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/bugs.chromium.org\/p\/project-zero\/issues\/detail?id=1826\"><p>The method <code>-[IMBalloonPluginDataSource individualPreviewSummary]<\/code> in IMCore can throw an <code>NSException<\/code> due to a malformed message containing a property with key <code>IMExtensionPayloadLocalizedDescriptionTextKey<\/code> with a value that is not a <code>NSString<\/code>. This method calls <code>[IMBalloonPluginDataSource _summaryText]<\/code> which returns the property assuming it is a string, but this is not checked. The calling method then calls <code>-[IMBalloonPluginDataSource _replaceHandleWithContactNameInString:]<\/code> which calls <code>im_handleIdentifiers<\/code> on the <code>NSString<\/code> which is really an <code>NSNumber<\/code>, which throws an exception as the selector does not exist in that class.<\/p><p>On a Mac, this causes soagent to crash and respawn, but on an iPhone, this code is in Springboard. Receiving this message will case Springboard to crash and respawn repeatedly, causing the UI not to be displayed and the phone to stop responding to input. This condition survives a hard reset, and causes the phone to be unusable as soon as it is unlocked. The only way I could find to fix the phone is to reboot into recovery mode and do a restore. This causes the data on the device to be lost though.<\/p><\/blockquote>\n\n<p>The bug is <a href=\"https:\/\/news.ycombinator.com\/item?id=20379739\">fixed<\/a> in macOS 10.13.4 and iOS 12.3, but what about customers on previous OS versions? Now that the bug is known, they could be targeted. And it doesn&rsquo;t seem like Apple could intercept the bad messages at the server level without decrypting private messages.<\/p>\n\n<p><code>NSSecureCoding<\/code> can&rsquo;t really protect against this kind of mistake. Maybe Swift could have, depending on how the code was written.<\/p>\n\n<p>I recently ran into a similar bug with <code>AVPlayer<\/code>, where using the scroll wheel calls an internal method with the wrong data type where a number was expected, causing an exception and alert window. I&rsquo;m sure sort of thing happens all the time, throughout the iOS\/macOS and apps, but rarely are the potential consequences so dire.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/05\/10\/black-dot-unicode-bug\/\">&ldquo;Black Dot&rdquo; Unicode Bug<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/02\/15\/another-ios-crash-caused-by-sending-unicode-character\/\">Another iOS Crash Caused By Sending Unicode Character<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/05\/29\/using-siri-to-work-around-imessage-crash\/\">Using Siri to Work Around iMessage Crash<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2013\/06\/26\/can-apple-read-your-imessages\/\">Can Apple Read Your iMessages?<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Project Zero (via Hacker News): The method -[IMBalloonPluginDataSource individualPreviewSummary] in IMCore can throw an NSException due to a malformed message containing a property with key IMExtensionPayloadLocalizedDescriptionTextKey with a value that is not a NSString. This method calls [IMBalloonPluginDataSource _summaryText] which returns the property assuming it is a string, but this is not checked. The calling [&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":"2019-07-08T18:57:44Z","apple_news_api_id":"fdb23ac9-cc3b-4c7d-8347-32ae5e050768","apple_news_api_modified_at":"2019-07-08T20:09:02Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/A_bI6ycw7TH2DRzKuXgUHaA","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,1016,140,31,1610,30,1609,141,54,71],"class_list":["post-25875","post","type-post","status-publish","format-standard","hentry","category-technology","tag-bug","tag-datacide","tag-imessage","tag-ios","tag-ios-12","tag-mac","tag-macos-10-14","tag-messages","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25875","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=25875"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25875\/revisions"}],"predecessor-version":[{"id":25881,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25875\/revisions\/25881"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=25875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=25875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=25875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}