BLASTPASS SANS HackFest

Document
Resource Thumbnail

The BLASTPASS SANS HackFest presentation focuses on a zero-click zero-day exploit chain that affects iOS and macOS devices, which involves a series of vulnerabilities including a flaw in PassKit, the blastdoor security feature, Address Space Layout Randomization (ASLR), Pointer Authentication Code (PAC), and a buffer overflow vulnerability in the Huffman tables used in WebP compression.

Full Transcript / Content

--- Page 1 --- --- Page 2 --- BLASTPASS CVE-2023-41061 & 41064 Overview & Exploit Chain Threat Briefing SOC-Class.com || Montance® LLC 2Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 3 --- Christopher Crowley – Montance® LLC - Background: root on (Ultrix/VMS) employer systems at 15 years old (80s #CYBER) - Sectors: Defense, Education, Energy, Government, Software Development, Financial, Telecom… - SANS Senior Instructor. Consultant, SOC-Class.com author. Teaches: SEC575, SEC511, SEC504,… Montance® LLC 3 --- Page 4 --- Christopher Crowley – Montance® LLC - Slide deck download: https://montance.com/pres - SANS website will also have it - Please use this information for yourself, your organization, and to help your community - @CCrowMontance (infrequent) - https://mgt517.com/linkedin Montance® LLC 4 --- Page 5 --- Quick History: CVE-2021-30860 - FORCEDENTRY SOC-Class.com || Montance® LLC 5Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 6 --- Information Sources - There’s a history of Citizen Labs tracking NSO: - Citizen Labs FORCEDENTRY 2021-09-13 blog: https://mgt517.com/cl-forcedentry earlier 2021-08-24 blog post: https://mgt517.com/cl-forcedentry-0 - Apple Security Update 2021-09-13: https://mgt517.com/apple-forcedentry ^^^ Link shortener links are case sensitive --- Page 7 --- Zero-click Zero Day - Dangerous zero-click zero-day exploit discovered - Zero-day: exploit found without a patch available - Zero-click: user interaction not required - Patch Now! for CVE-2021-30860 and CVE-2021- 30858 to defend iOS, macOS, watchOS against the exploit - Zero day exploit code dubbed FORCEDENTRY by Citizen Labs (who disclosed it to Apple) --- Page 8 --- Attribution: NSO Trivia: a Pegasus is not a Unicorn SOC-Class.com || Montance® LLC 8Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 9 --- Attribution in General - First, attribution is tricky business and may not make much difference to you. Would your actions change if it was NSO or NSA who developed this? - The disclosure of a zero day means that other capable threat actors are aware of this flaw and may quickly develop an exploit prior to patch deployment - Pegasus install cited in Citizen Labs post, other details withheld in an OPSEC maneuver to aid victim discovery; likely also substantial unknowns on the rest of the details (** will discuss their previous data) --- Page 10 --- Attribution in General - US Defense Science Board schema: $T, $M, $B - Reuse, discover, and create/introduce flaws - This is the work of $M level actor - Difficult and damaging, but not an existential threat for most, nor the creation of a flaw - Sad state of affairs, but zero-days happen, you should already be ready to mobilize and shift gear $B create $M discover $T reuse --- Page 11 --- Value of Attribution - If you are in a position to (or have to regardless) investigate, there are a large number of specific IOCs posted in the Citizen Labs blogs - Previously cited operators of Pegasus infrastructure, and the specific IP address deployments of those operators - Review IOCs from CL post, also @craiu (Kaspersky) detailed thread on twitter for attachment inspection: https://mgt517.com/forcedentry-forensic - This list of resources is constantly shifting --- Page 12 --- Citizen Labs Basis for NSO Attribution - Phone was infected with Pegasus spyware - NSO is a software provider, Pegasus is its product - FORCEDENTRY (’21) CASCADEFAIL: - Incomplete deletion of data from DataUsage.sqlite - Rationale: to reduce evidence of spyware activity, the ZPROCESS table is modified, however the ZLIVEUSAGE table isn’t modified and the discrepancy is useful - Citizen Lab blog says they’ve only observed this from Pegasus; SQL query when performing forensic analysis to determine if the phone you are assessing is exhibiting same behavior: SELECT "CASCADEFAIL" FROM ZLIVEUSAGE WHERE ZLIVEUSAGE.ZHASPROCESS NOT IN (SELECT Z_PK FROM ZPROCESS); --- Page 13 --- Citizen Labs Basis for NSO Attribution - FORCEDENTRY (‘21) setframed: - Distinctive process name “setframed” as part of the July 2020 Al Jazeera targeted attacks (also attributed by Citizen Lab to NSO) forensic analysis performed. Citizen Labs blogpost indicates this detail wasn’t publicly disclosed previously - Blog indicates this is a process name associated with this intrusion spyware --- Page 14 --- Citizen Labs Basis for NSO Attribution - BLASTPASS (‘23): - “Citizen Lab found an actively exploited zero-click vulnerability being used to deliver NSO Group’s Pegasus mercenary spyware.” - “We expect to publish a more detailed discussion of the exploit chain in the future.” From: https://mgt517.com/blastpass - No details, technical corroboration, etc. - I asked for more details: no response; didn’t expect it tbh - So, confidence and trust based on previous assessments --- Page 15 --- BLASTPASS: Limited Exploit Details SOC-Class.com || Montance® LLC 15Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 16 --- Relationship between CVE-2023-41061 & CVE-2023-41064 SOC-Class.com || Montance® LLC 16Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 17 --- 41061: Wallet / 41064: ImageIO - Citizen labs found the exploit, did preliminary analysis, provided details to Apple - Citizen Lab cited as CVE-2023-41064 credit - Apple appears to have identified the blastdoor circumvention (CVE-2023-41061) within PassKit - CVE-2023-41064 is also be related to CVE- 2023-4864 (will discuss later) --- Page 18 --- CVE-2023-41061 Validation Issue Apple Wallet SOC-Class.com || Montance® LLC 18Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 19 --- iOS Wallet / PassKit Update Wallet: “A validation issue was addressed with improved input validation.” - CVE credit is to “Apple” (patch announcement for iOS 16.6.1: https://mgt517.com/41061) --- Page 20 --- CVE-2023-41064 Buffer Overflow ImageIO SOC-Class.com || Montance® LLC 20Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 21 --- Buffer Overflow - Buffer overflows: a category of programmatic flaw. If the space allocated to store process the result value is inadequate the resultant write of data can result in overflowing a buffer in memory. - This fix is addressing the starting point of a zero-click exploit chain, let’s look into that in a little more detail --- Page 22 --- CVE-2023-41064: ImageIO - Buffer Overflow patched by CVE-2023-41064 - Citizen lab blog cites malicious images sent via iMessage to victim, and the corresponding PassKit flaw as part of the exploit chain - https://mgt517.com/blastpass - iMessage delivery > PassKit processing outside blastdoor > ImageIO exploit --- Page 23 --- Zero clicks I give… SOC-Class.com || Montance® LLC 23Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 24 --- Zero Clicks - For mobile devices, there isn’t a service side opportunity for remote code execution - Mobile Attack surface preso I gave in 2020: https://mgt517.com/mobile-attack - Attackers seeking remote code execution are largely relegated to messaging apps to process content without user interaction (anyone remember Stagefright?) --- Page 25 --- Blastdoor (1 of 3) - In response to previous zero click exploits, Apple developed blastdoor for iOS 14 - This is a “tainted data” processor which severely limits the processing done on data sent over SMS/iMessage as ingested to phone - Based on Google Project Zero writeup - https://mgt517.com/p0-blastdoor - BLASTPASS name: PassKit violating blastdoor --- Page 26 --- Blastdoor (1b of 3) From: https://mgt517.com/p0-blastdoor (Speculated) PassKit involvement required here: cue 41061 --- Page 27 --- Blastdoor (2 of 3) - (‘21) apsd -> identitydservicesd -> imagent -> MessageBlastDoorService -> imagent -> IF:serializedData? -> IMTranscoderAgent <<< - (‘21) In the “CL-Pearls” writeup they discuss two types of crashes involving IMTranscoderAgent - Type1: copyGifFromPath:toDestinationPath:error in ImageIO to render .psd files (27 of the same sent) - Type2: copyGifFromPath:toDestinationPath:error in CoreGraphics for decoding JBIG2 data in PDF file (4 different PDF files sent) --- Page 28 --- Blastdoor (3 of 3) - PassKit details for pass parsing - Little public material available - Similar scenario as in FORCEDENTRY - Special attachment type (wallet) requires moving data out of blastdoor protected data segment into the wallet context, which enabled the exploitation to take advantage (this is speculated / unverified) - Satisfying item #4 of the list of items (on the next slide) --- Page 29 --- Zero Click Necessary Components - According to Project Zero post, zero-click needs: - Memory corruption vulnerability (buffer overflow in ‘23) - Remotely break ASLR (unknown currently) - Code execution (unknown currently) - Sandbox escape (PassKit in ‘23) - Pointer Authentication Code (PAC) evasion - To overcome blastdoor’s protections: overseeing the process of ingesting iMessages, dyld shared cache rerandomized for each service start, ASLR brute mitigation by doubling restart times between each crash --- Page 30 --- Zero Click Necessary Components - According to Project Zero post, zero-click needs: - Sandbox escape (Presumed: PassKit in ‘23) - My speculation on the PassKit and related sandbox specifications is there’s some service (XPC seems reasonable) that enables transfer of attachment to PassKit and starts the exploit --- Page 31 --- Zero Click Necessary Components Memory corruption vulnerability (CVE-41064 in ‘23) Remotely break ASLR (unknown currently) Code execution (unknown currently) Sandbox escape (CVE- 41061 / PassKit in ‘23) PAC (discussed in p0 blog post) --- Page 32 --- PAC - That blog post indicates that pointer authentication codes (PAC) weren’t an issue for that specific exploit under assessment (iOS 12.4) - ARM protection as of ARM v8.3 that associates code calling code to protect against ROP / JOP style execution - Requires exploit to develop primitives in complicated ways to assure the calls are accepted as valid (I.Beer post on ImageIO IPC) --- Page 33 --- Exploit Info & Speculation - Synthesizing info from two blog posts from citizen labs, Apple report, the Project Zero blogpost on the functional teardown of Blastdoor, PassKit flaw - We have an understanding of the majority of the components necessary to accomplish the CitizenLab reported - Buffer overflow cited - Movement from PassKit flaw to WebP --- Page 34 --- CVE-2023-41064 (and CVE-2023-4863) Ready for the curveball? SOC-Class.com || Montance® LLC 34Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 35 --- WebP Lossless Encoding Patch - Presuming PassKit’s “validation issue” was leveraged to get to ImageIO, scant details related to 41064, except for something interesting… - ImageIO supports WebP; Apple reported WebP bug on Sept. 6, 2023; urgent Chrome patch - Ben Hawkes, “Based on this, it seems likely that the BLASTPASS vulnerability and CVE-2023-4863 ("the WebP 0day") are the same bug.” - https://mgt517.com/hawkes-webp --- Page 36 --- WebP Algorithm Logic Flaw - WebP fix details: https://mgt517.com/webp-oob - Huffman table (tree structure originally) used to perform lossless compression - Vulnerable webP code is from buffer sizes defined based on fixed size tables for memory allocation; resulting in overflow - Fix checks size; allocates space for larger requests --- Page 37 --- Down the WebP-Hole (1 of 3) - Processing is intended to deliver lossless image encoding and provide compression to reduce size - Starts getting mathy… to reduce image size, frequency analysis is performed on image pixels - Specific output bits are mapped to a tree tracking sequences, frequently occurring bits are reduced to smaller sequences than the original bits - The bit length provides a unique mapping, but the Huffman table is needed to recover original data down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai --- Page 38 --- Down the WebP-Hole (2 of 3) - Which means the size would increase, so the Huffman tables are also compressed the same way - Hawkes hypothesized (VP8L is another name for webp) VP8LBuildHuffmanTable/BuildHuffmanTable method call would be the candidate for shifting huffman_table pointer past pre-calculated buffer size (since the pre-calculation was fixed in the patch this is targeted) - He then tried to create a table that would create an exploit situation down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai --- Page 39 --- Down the WebP-Hole (3 of 3) - As it turns out, even with some related code (Mark Adler enough.c referenced by Google) he couldn’t create a table that was vulnerable - enough.c was only 8-bit color code, so dead end - Spends lots of time creating tables, but couldn’t create invalid tables - Modifies the ReplicateValues, finally established a condition creating an invalid table down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai --- Page 40 --- WebP-Hole Exploit POC - In order to establish the invalid table, he’s dealing with the last 5 tables, but can’t generate tables big enough to cause errors - So, the POC builds 4 tables to fill the space expected for the 5 tables, then adds a final invalid table with ReplicateValue which causes the out of bounds write to occur . down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai --- Page 41 --- WebP-Hole Exploit POC - This creates the invalid fifth table, corrupting memory, but still within the constraints of the math for the Huffman tables - From craft.c: down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai --- Page 42 --- WebP-Hole Exploit POC dwebp output: down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai Hawkes Post @mistymntncop POC --- Page 43 --- WebP-Hole Exploit POC Dwebp output: down the rabbit hole, but make it a webP hole instead of rabbit, using Huffman encoding Image from: dream.ai Hawkes Post @mistymntncop POC --- Page 44 --- WebP Pervasive Attack Surface - WebP attack surface is extensive - CVE-2023-4863 (chrome) and CVE-2023-5129 (later rejected as they pushed libwebp generally back into 4863) - At the time of writing of several of the initial analyses, it was speculated that Android was vulnerable to it - Acknowledged in October update: --- Page 45 --- WebP Flaw Discovery Speculation - Hawkes then talks about trying to find this bug through fuzzing and says none of the current fuzzers could do it; speculates manual effort - He built the invalid table because of the patch - A mathy-math muthamather developed the exploit as a novel concept against Huffman tables - My thoughts: WebP is relatively new, in ImageIO, open source, so good target / attack surface - https://mgt517.com/hawkes-webp --- Page 46 --- Unknowns & Expected Forthcoming Information SOC-Class.com || Montance® LLC 46Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 47 --- Speculation on Future Patches - We know a fraction of the details - We don’t know: - the PassKit blastdoor escape details - ASLR and PAC details - Keep up w/ details on the related CVE: - Google WebP related, probably other image compression math logic - Hardening of blastdoor further --- Page 48 --- Lockdown Mode SOC-Class.com || Montance® LLC 48Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 49 --- Mitigation Offering From Apple - Lockdown mode would thwart attack - This was speculated by Citizen Lab, then confirmed by Apple for this exploit - If you are paranoid, and/or have the sort of exposure discussed here, use Lockdown mode --- Page 50 --- Recap SOC-Class.com || Montance® LLC 50Copyright 2023 Montance® LLC - All Rights Reserved. All Wrongs Reversed? --- Page 51 --- Zero-click Zero Day - Dangerous zero-click zero-day exploit discovered - Zero-day: exploit found without a patch available - Zero-click: user interaction not required - Complicated exploit chain - Bypassing blastdoor, ASLR, and PAC - Zero day exploit code dubbed BLASTPASS by Citizen Labs (who disclosed it to Apple) - Lockdown mode would have prevented it --- Page 52 --- Your Action Items - It’s complicated, more details in the various blog posts - Think about the relationship between initial entry (PassKit in this case) and ultimate exploitation (WebP in this case) - See similar post from a couple months before BLASTPASS: https://mgt517.com/web-gpu Safari -> GPU exploitation by Ian Beer (iOS 16.4.1 and 16.5 fixed these) - Chain: CVE-2023-28205, CVE-2023-28206, CVE-2023-32409 --- Page 53 --- Christopher Crowley – Montance® LLC - @CCrowMontance - Slide deck (this and others) https://montance.com/pres (as in presentations) at my website - Questions? Montance® LLC 53

Related Q&A

  • Q: Overview
    A: Presentation details for BLASTPASS SANS HackFest