start	end	text
0	2600	Okay, hello everyone.
2600	6100	And I think this is the time for my talk.
6100	18660	And it's now half past one, and welcome to my talk on the Android security, which I believe maybe is the only topic at this year's DEF CON on Android security.
18900	30800	So the topic of my talk is Dem Made Alive Again, Bypassing Intended Destination Checks and Introducing Launch Anywhere Privilege Escalations.
30820	33640	So a brief introduction about myself.
33640	38280	I'm currently the Center Director and Chief Security Researcher at GD.com.
38280	47260	I'm leading the Dawn Security Lab, which our lab is mainly doing anti-fraud, client security, security research, et cetera.
47260	56500	And I'm previously a winner of the Pantone and Mobile Pantone competitions, and the 2022 Pony Awards Best Privilege Escalations.
56620	63090	And I'm also a speaker at Black Hat, DEF CON, Consulate West, Recon, POC, and Hacking the Box.
64220	67420	So today's agenda is as follows.
67760	70220	My talk will be categorized into five parts.
70220	77100	The first part is the Android security backgrounds for those who are not currently Android experts.
77100	88420	And the second part will be the recap of the launch anywhere stories and mitigations and the vulnerabilities in history and can help you have a better understanding of the battery resolve.
88560	91240	And the third part is the core part of this talk.
91240	97200	It's the battery resolve vulnerability series of CVs we have found in the newest Android system.
97380	102700	And the fourth part is about using the power of ARM and MCP.
102940	105160	The final part will be summary and QA.
106860	115580	So for a quick introduction of backgrounds, I will talk about some knowledge about the intents in Android.
115860	117200	So what is intent?
117200	121960	Intents are actually the core of the IPC mechanism in Android.
121960	127800	It's actually abstraction for messages sent within and between the applications containing the embedded data.
127980	147660	And in Android, applications communicate with each other using largely, you can see a figure that activity A, if it wants to call activity B, it needs to use the start activity API call and passing intent as arguments.
147720	151500	And this API call will be processed by the Android system.
151560	155260	And in particular, it's the activity manager service.
155380	168340	And the activity manager service handles this call and actually invokes the callback, the uncreated callback of the target activity and passes intent for the activity B to process.
168460	173280	So this is a basic flow of the activities communicating with each other using intents.
174020	179560	So there are like 5 major parts, 5 parts of complements in Android applications.
179560	182200	We usually call it like 5 King Kongs.
182200	187360	And complements can be studied by intents and receive from- receive input from it.
187360	194240	And complements can declare intent filters in the Android manifest about what kind of intents they are expecting.
194480	200760	And the exception is the dynamic broadcast receiver and this is out of scope for today's talk.
200960	204000	And the expected here means that it's not always enforced.
204000	212500	It's only the intent filters criteria is only needed to be met when in the implicit intent resolving.
213900	219280	So the lower part is the screenshots of the search trampoline activity in the Android manifest.
219280	222380	I'm not sure if you can see it very clearly.
222380	235340	You can see that this activity declares an intent filter that's saying that it wants an action that named the search result trampoline and the category with the default category.
237500	256720	So intents itself uses bundle to store the key value pairs and the key value pairs can contain like primitive data types like arrays for example like intents put extra defcon 2025 and it can also contain objects implementing the serializable and the possible.
256780	262920	And objects, the serializable and the possible, they can define their custom serialization scheme.
262920	273860	And intent itself also implements possible which means that intents can contain intents that contain intents and you can loop whatever long you want and so as bundle.
276400	282600	So for the intent resolution, as we have mentioned earlier, intents can be explicit or implicit.
282740	288480	The explicit intent target is deduced from the complement set within it.
288680	298060	This means that you can call set complement on the intent and ask it to be explicitly directed to a certain complement.
298060	306340	However, for implicit intent, it must go through the resolution process if there's no complement specified in this intent.
306340	315640	The resolution process is currently defined in the resolve internal function of the resolve intent helper class of the android system.
315640	326460	And this resolution process considers intent filters of the complements, the permissions of the complements, the privilege level of the complements and also the preferred options of this activity.
326460	329760	There are lots of details here and we will go back to it later on.
329760	334740	The details are very important in the exploration of the bad resolve.
334900	347220	And also, of course, security restrictions that a normal application cannot start the protected activity or unexplored activity of other applications.
347220	350240	This is the security restrictions of the intent resolution.
350920	356500	And in the right part of the slide, we can see an example of the implicit intent resolution.
356620	367180	An application calls start activity with an implicit intent with the action android.internaction.callprivileged, which means that it wants to make a phone call.
367180	376080	And this implicit action, this implicit intent is finally resolved to the privilege call activity of comp.android.phone.
376280	383980	And we can see that this activity declares the matching intent filters, the intent actions, and the intent categories.
384060	388400	And then the onCreate function of this activity is called.
388400	398200	But there is one important point here that in order to call this activity, you need to hold the specific permission of the call from privileged.
398360	406900	So in the following slides, we will see how we use the intent privilege escalations to bypass this restriction.
407800	415700	So this is the background of the intent security and the second part will be the recap of the historical launch anywhere vulnerabilities.
416140	419320	So uh what's the non-launch anywhere?
419600	429760	Uh we recall that we have mentioned in previous uh slides that activity can perform sensitive actions like install packages, perform calls, or even execute commands.
429760	435560	And these sensitive activities should be protected with permission or is always un-exported.
435560	441820	So it cannot be accessed by a normal application uh uh application hold by attacker.
442120	449220	However, I recall that intent can contain nasty intents which will lead to the intent reduction and injection vulnerability.
449380	455160	For example, in the lower part of the slide, we can see that uh a victim application complements.
455160	463160	It contains uh a secret action or privileged action and it actually commands from the intent income.
463160	466680	However, this complement is usually protected or un-exported.
466680	471000	So an attacking application cannot directly access this complement.
471000	485380	However, if there is a vulner- if there is a vulnerability in a breach application, which we can see that it takes an intent from a possible extra and start act- and cause start activity on this possible.
485480	492860	And then the attacker application can use this breach uh breach application to attack the victim application.
492860	496160	So this is an example of the intent redirection.
496580	513940	So if this breach application is a privileged uh privileged application like the system UID applications like settings, and uh this is a juicy target for the attacker and uh this kind of vulnerabilities will be called launch hand-aware because the system UID application,
513940	519640	the settings applications, they hold the privilege to call arbit- to call arbitrary activities.
521180	532040	So uh in 2014, we have uh very typical uh example of the bar of the launch hand-aware in the android.com.android.settings.
532040	535500	This is a very old bar, but a very typical example.
535500	536720	Very classical.
536960	543960	And uh in this uh bar, we can see that uh it's in the account management functionality of android.
543960	550620	Uh the account management uh functionality android allows application to create an account.
550620	555200	And uh when it creates an account, it need to ask the settings application.
555200	561020	It sends an intent to the settings application and the settings application calls the account managers at account.
561140	574480	And here uh this uh account manager at account will call into a system server and system server will in turn invokes a callback in the at account callback of the calling application.
574480	576660	And here we mean the attacker application.
576680	586820	The attacker application passes by- passes back a bundle and this bundle is uh you- it is processed in the system server and finally passed back to the settings application.
586940	592760	And the settings application just blindly take a possible intent from it and calls that- that activity on it.
592760	596100	So this is a very classical example of a non-training weird.
597380	603540	Of course, this vulnerability gets fixed very quickly and uh this is the first round of fix.
603600	605880	And we will go back to it uh later on.
605880	608720	This is a very important fix and with many details.
608960	616500	Uh this fix can be actually categorized or summarized as that uh there is a check added in the account manager service.
616620	626280	And the account manager service uh checks that if the bundle contains an intent and if there is an intent in the bundle, it will check if the intent is allowed to start.
626460	634240	And if the intent check passed, it will then pass it- pass the intent to the settings application- pass the bundle to the settings application.
634740	643520	So uh currently all the checks are in the checking intent function of the uh account manager of the account manager service.
643520	647240	And we can see that the check is mainly as follows.
647240	658280	It's uh perform a resolve activity on this incoming intent and it checks if the target activity have this- have the same signature as the calling application.
658280	660720	Uh which means the attacker application.
660740	668760	So this check restricts that the attacker application can only use this functionality to start an activity of itself.
669040	675780	And uh it is- it is disallowed to start other activities, other privileged activities of arbitrary application.
676180	678540	So this is round one, right?
678540	679800	Round one is not finished.
679800	681260	We still have round two.
681260	688280	And uh what if the account manager service, the system server, sees a different intent as settings?
688640	693840	So maybe they see the different intents and the check will of course fail.
693840	701380	Recall that a bundle can contain the possible objects and it's the developer's responsibility to write the park and unpark code.
701500	706920	So when developers create their own code, the things will really go wrong here.
707020	712040	Uh here is an example, the CAE certificate info possible of the Samsung class.
712080	717840	We can see that the developers implements a read from possible which is the deserialization function.
717840	720920	And a write to possible which is a serialization function.
720980	727120	And there's a tiny difference here that's uh on the possession of the third length, the integer.
727140	732120	We can see that in the read from possible, it checks that if the third length is larger than zero.
732200	740060	However, in the write to possible, it checks if the third length is- is equal to zero but not if the third length is larger than zero.
740100	745700	This will cause a mismatch occurs when the possible is written and read.
746000	753880	So if you have a third length like minus uh like minus one, the mismatch will occur when the possible is written as a read.
753880	761420	So this will lead to the bundle contain different objects after the deserialization, the serialization, and then deserialize again.
761500	770540	Which will bypass the check intent check because actually now the system server that can measure uh service sees different intent as a settings.
771140	779920	And uh this uh the detail is quite complex here and uh because this is not the core part of today's talk, we will not elaborate here.
780220	783940	And uh for anyone who is interested in the next slide, give an overview.
783940	789660	And uh this kind of possible mismatch box is largely exploited in the wild.
789800	797540	So this uh figure is taken from the Google Android security team uh Hawker's Black Hat EU uh 2022 slide.
799280	812720	And uh we can see that uh uh the bundle is uh deserialized and serialized in the system server and uh because a mismatch occurs, the system server and the settings see different intent.
812860	816440	Which will lead to the launch anywhere vulnerability again.
816780	825580	So this type of vulnerability uh is largely exploited in like billions of devices in previous years.
825580	830640	And there are like more than 100 possible mismatch vulnerabilities in Android.
830640	839820	And uh literally Google wrote out many mitigations and uh currently we think the possible mismatch vulnerability is not as effective as past.
840240	843860	So now, we'll go to the third part of the talk.
843860	850540	We'll go to the bad result vulnerability which is the uh CVEs we discovered.
851040	862480	So uh recall that in the possible mismatch scenarios that uh we want to make the account manager service and the settings sees different intent to bypass the check.
862520	872560	However, what if the account manager service, the system server, and the settings see same intent but the intent is actually resolved to different target activities.
872760	880380	So we see the check from a different angle and uh we here we try to make the launch anywhere great again.
881040	893220	So looking back in the fix, uh as I have mentioned earlier that this fix uh primarily checks the target of the intent resolution of the implicit intent and check the signature of the application.
893600	900640	So uh we can see that it performs check here and literally the intent is used in the settings.
900820	906340	So there are some ideas that flow on my mind that can we do a talk tool here?
909000	919740	The core idea is that uh uh the system server checks the target user result activity and the same to the settings if the check parsed and then the settings will start its intent.
919940	924700	And the start activity itself actually implicitly calls the resolve activity internally.
924840	930420	So what if the draw solution result change between these resolves?
930700	933240	Like is it possible for a risk condition?
933820	940120	And we need to inspect the source to figure out that if there is something we can manipulate, we can risk with.
940900	953080	So the lower part of this slide is uh illustration of the check and start uh check and start code of the between the activity manager service and the settings.
953080	967340	We can see that uh uh if it possible so that we can make the when the check intent call the result activity, it will resolve to a benign activity which belongs to the attacker's application.
967340	976840	However, in the second start activity, it will resolve to a privileged activity or protected protected activity that attacker wants to start.
977000	979960	So can we like achieve this result?
980820	987960	So if you want to like uh uh exploit or find or talk to a vulnerability, you need to find your primitives.
987960	991020	What what things you can change or what can you control?
991020	1003280	The primitive here is that application is allowed to use the package manager set complement enable settings to enable or disable its own complement like activity, et cetera.
1003280	1004860	It's in run time.
1004940	1010740	And the disabled complement is considered to be vanished as if it had never existed.
1011220	1016800	So can we utilize this primitive to manipulate the resolution results?
1016800	1028940	For example, can we disable the result complement in the check run so that we can force the latter result point to a different result?
1029160	1034400	So we can see the other time window here between the activity manager service and the settings.
1034420	1043780	Like can we like disable the activity of our application so that in the first resolution, the result is our activity.
1043780	1049000	However, when the second resolution, our activity is disabled so it cannot appear in the result list.
1049000	1054460	And now the privileged activity or protected activity appears in the result list.
1054500	1057760	So this is the basic idea of our TOCTO.
1058080	1065020	However, we need to check if our TOCTO exploitation idea, is it feasible?
1065260	1081380	As we have mentioned earlier, that intent can result to a single target or multiple targets because activities can declare similar intent filters and an implicit intent may result to a list of activities.
1081660	1101920	So the first case is that when intent resolved to a single target is seen, whether it's an explicit intent or it's an implicit intent, when the intent resolved to a single target, if the target is disabled, the process fails and the exception is thrown.
1102860	1108060	And of course, the explicit intent always resolved to a single target.
1108060	1112520	Explicit means that a complement or the class field of this intent is set.
1112520	1122460	However, the implicit intent may resolve to a single target if there is only one candidate in the intent resolution.
1123080	1139760	So the lower figure illustrates that if the intent resolved to a single target and the target disappears, the target may be disabled, then exception will be thrown and the start activity will fail in the settings application.
1141340	1157920	So after we dive deep into the resolution process and we draw out a figure of the functions called and we can see that the procedure is as follows.
1158520	1170480	First, when the system server, the activity manager service start resolving on the intent, it will first check if the candidates is a single result.
1170480	1174640	If the candidate is a single result, it will just return the single result.
1174640	1178100	If there are multiple candidates, here comes a problem.
1178100	1188920	If there are multiple candidates allowing the resolution of this implicit intent, it needs to find a single target or let the user choice.
1188920	1192680	So it will first exclude the disabled ones.
1192680	1202900	And then after this exclusion, if there is still multiple targets, it will decide that if the targets have different priorities.
1202900	1218640	We know that developers can specify priorities in the intent filters and the resolution process will check is there an activity intent filter that contains the largest priority.
1218940	1226800	There is a cork here that normal applications can only declare priority zero or lower than zero.
1226800	1233240	It's a privilege of the platform application and system application to declare priority larger than zero.
1233500	1239780	So if there is a candidate that holds a largest priority, this candidate will be returned.
1239940	1250160	So if there are all candidates do not declare priority of the intent filters, it will try to find if there is a preferred target.
1250160	1252020	What is a preferred attribute?
1252020	1259120	The preferred attribute is we can see in the lower left, lower part of this slide, there is a pop-up here.
1259120	1273900	For example, when an implicit intent resolves to different targets, different candidates, a pop-up of the chooser application will be given to the user and let the user decide which activity he or she wants to start.
1273900	1281440	So if a user starts a candidate here and clicks on always, this activity will be marked as preferred.
1282040	1293940	And this will be memorized and will survive the installation or will survive the update of this application and will be used in the next resolution process.
1294100	1297820	So if there is a preferred one, this preferred one will be returned.
1298160	1307100	And if there is still no preferred one and we still have multiple candidates available, then the chooser activity, the pop-up will appear.
1310850	1316750	So we have introduced the flow of this resolution.
1316770	1320990	So the following steps is summarized.
1320990	1325750	Now we can see that first a disabled target won't be taken into consideration.
1325830	1331330	And then the largest priority is chosen and returned.
1331330	1336030	And if there is no largest priority, a preferred one will be chosen and returned.
1336030	1341190	If neither is satisfied, a chooser dialogue is a pop-up for the user's confirmation.
1342110	1349550	And however, from an attacker's perspective, which steps here we can affect or we can manipulate?
1349710	1359610	The answer is that we cannot manipulate with the priorities because I have said earlier that normal applications cannot declare priorities larger than zero.
1359730	1375470	And we cannot make this resolution point to a chooser application because the chooser application is a system platform application and it has different signatures than our attacker's application.
1375470	1383810	So if you like the check intent finds that our intent is finally resolved to a chooser activity, it's not happy with it.
1383810	1387650	Then we will like bail out and the check fails.
1387650	1394810	So the only choice left here is that we need to make our activity a preferred one.
1395790	1415610	So the whole idea is that it's like follows in the beginning of this resolution of this exploitation flow in the when the account manager service calls check intent and here we make our we supply an implicit intent and here the implicit intent will return multiple targets.
1415610	1419890	However, we have already marked our activity as a preferred one.
1419890	1427250	So here the check intent will happily find that this result is an activity that belongs to our application.
1427250	1429790	So this check is passed.
1429790	1437290	And then we disable our compliment during the time window of the account manager service and the settings application.
1437290	1451610	So when the settings application accepts this bundle and retrieves intent from it, when it calls the start activity, it will find that there is only one candidate left because our candidate activity has already been disabled.
1451610	1452570	It has vanished.
1452570	1462250	So only one result is left and it will happily start the protected or privileged activity, the target activity the attacker wants to exploit.
1462270	1466630	So here is the basic idea of our TOCTO attack flow.
1466630	1473530	However, we know that there is another important factor in TOCTO exploiting TOCTO vulnerabilities.
1473530	1476470	You need to check the time frame.
1476470	1481210	Do you have enough time to manipulate the state of the compliment?
1481210	1482870	Here we use a profetto.
1482870	1487890	Profetto is a perf application that comes within the AOSP.
1487890	1497410	It's a very useful application that it can that has inspect that the functionalities in the system server in the settings, how long do they take?
1497410	1500010	For example, how long does the resolve intent take?
1500010	1502130	How long does the start activity take?
1502190	1508590	And this is crucial for our to deciding the time window of our TOCTO exploitation.
1509470	1517530	And here using profetto, we see that there is actually two check intent calls in the system server.
1517530	1531530	And after these two checks being passed and the start activity is called in the setting application and the start activity, we can see that it in itself calls the resolve activity internally.
1532510	1537910	So it seems that we can just risk within this time window and we are good to go now.
1538330	1543550	So actually, things are not as easy as we have thought here.
1543810	1556230	And using profetto, we found that our time window is only one millisecond, which means that you can suddenly do anything in a one millisecond time window.
1556870	1563070	And except if you are Superman or Flashman, you can like manipulate this compliment in one millisecond.
1563250	1569510	However, so and we can see that the resolve intent here only takes like 0.5 milliseconds.
1570010	1573710	So given this time frame, we cannot do anything meaningful.
1573710	1581750	We need to find a way to like extend this time frame to extend to like at least tens or hundreds of milliseconds.
1584070	1592630	So here that we have several ideas that we need to get a larger time window, but which direction should we take?
1592830	1598150	Like, can we slow down the resolve intent and disable the compliment in this time frame?
1598250	1609510	However, there is a question here that if we change the compliment states and the change of the compliment state is instantly reflected in the resolution result, we will still fail here.
1609570	1616230	And can we like slow down the IPC between the system server and the settings application and disable the compliment in this time frame?
1616450	1621010	So we have two ways here and finally we choose the formal way.
1621870	1628570	To make the formal way work, we need to dive deeper into the resolve internals in the activity manager service.
1630090	1638870	So actually, the compliment information query is done or fulfilled by the compliment resolver in the package manager service.
1638870	1651170	It maintains a mapping of the four king cons, the activities service, broadcast reservers, content providers, their mappings from these compliments to the internal filters they declared.
1651230	1663770	And this information is stored in the fields, in the activity internal resolver fields, the provider internal resolver fields, the receiver internal resolver fields, and the service internal resolver fields.
1664170	1669670	And the actual resolution process is done in the computer engine.
1669670	1679410	The computer engine is the M compliment resolver, the field of the computer engine is a snapshot of the compliment resolver.
1679410	1687590	And this snapshot is fetched and updated when the package manager internal-based resolve intent is called.
1687910	1693410	And then the queries are performed on this snapshot of this compliment resolver.
1693410	1698550	The snapshot actually creates a copy of these big four mappings.
1699550	1704450	So here in the right part of the slide, we can see this is a summary of this whole flow.
1704450	1720750	The resolve internal helper, resolve internal internal calls the computer engine, query the component internals, and then call the component resolver query activity, which performs matching on a snapshot of these compliment mappings.
1720750	1729210	And then it will call the choose best activity as we have explained the steps of choosing a candidate from a candidate list.
1731370	1735630	So what is a snapshot in package manager service?
1735870	1741350	A snapshot creates a read-only current state copy of the package infos.
1741670	1746170	And the queries are done in the frozen compliment mappings and states.
1746350	1755450	So once the snapshot is taken, any changes during the time frame of this resolve intent will not be taken into consideration.
1755670	1766630	So we can see in the right part of the slide, the implementation of the resolve intent, the snapshot is created in the first argument of this resolve internal function call.
1766910	1779210	So thank you snapshot here that we know the snapshot, once it's created, it will not be modified and we can manipulate everything we want in the time frame of this function call.
1779210	1786790	And the result will not be affected by our operations because all queries are done in a frozen snapshot.
1788930	1806330	So here, we have our idea of extending the time window of this resolve intent call, and we need to find some way to extend the time spent on searching the activities of this snapshot.
1806770	1810290	Our solution here is to play with the Android manifest.
1810510	1825030	So can we like declare lots of compliments, lots of attributes, lots of intent filters, which are lots of elements which will fill up the snapshot and increase like obstacles when it's performing a linear search on these compliments.
1826290	1830030	And also, there's a very helpful flag here.
1830370	1848990	The flag debug log resolution, and when it can be parsed, it is a flag of the intent, and if the flag of the intent is enabled, we see that a logging functionality is turned on when the intent is used in the activity manager service, package manager service,
1848990	1856770	and it will do like a linear ON printing of all the categories of all the intent filters.
1856890	1878270	So we can see, we can know that if we turn this flag on in the incoming intent, it will make this resolution process slow down much more altitude because it will print all the intent filters, all the elements, and this definitely will take up much time.
1879390	1888330	So here we try to declare the intent filters with the large number of categories, and how many categories can we declare?
1888330	1890490	What's the largest number we can declare?
1890590	1904910	The upper bound here is limited by the timeout restriction of the package verification functionality in the package manager, and also it's limited by the format, the XML format of the Android manifest.
1905210	1932250	So after some trial and error, and I found that also based on the code of these parsers, we found that the 10,000 or 40,000 categories in the intent filter is small enough to make both happy, to pass all the checks, and it can also slow down the resolve intent to like 50 or more than 400 milliseconds,
1932250	1935230	and this is ideal for risk condition vulnerability.
1936230	1949790	So in the lower part, the left part of the slide, we can see here's an example of the malformed manifest, the malformed intent filter, we declared with like 30 categories.
1950250	1964970	We declared 30,000 different categories here in a single intent filter, and now the profiler shows us that the resolution process has been slowed down to like 400 milliseconds.
1965230	1968030	This is a very ideal situation for us.
1969470	1976570	So the final attack flow, the final outcome here in our profiler view is as follows.
1976590	1993910	I can see attacker application triggers the add account functionality of the account manager service, and initialize this launch anywhere attack, and this now system server receives the intent, and it performs the first check on it.
1993910	1997450	And then if the first check passed, it goes in the second check.
1997450	2014990	However, there is a background thread started in the attacker application that in the second check, the time window of the second check, the thread disables the resolution target of the complement declared in the attacker application.
2015290	2022290	So the second check also passed because the snapshot is taken in the beginning of this function.
2022290	2029610	At the beginning of this function, we haven't disabled this complement, but we disabled this complement in the middle of this function.
2029790	2044250	So after the first check and the second check is passed, this bundle and the intent is finally passed again to the settings application, which is the user of this bundle and intent.
2044250	2051350	And here, the settings application will happily start the intent and call the launch anywhere vulnerability again.
2053170	2065010	There is a small quirk here that system UI sometimes will crash on clicking the resolve activities dialogue due to the too large body of the intent filters.
2065010	2079310	Remember that if we want to make our activity a preferred one, we need to trick the users to click on the always button, always label of the preferred activity of the chooser dialogue.
2079410	2086270	However, if you declare a too large body of the intent filter, the system UI will crash here.
2086910	2097290	And reinstalling the application can bypass this restriction because installing an update to an application will not clear the preferred activity's preferences.
2097390	2107330	So the idea here is that we can install a normal version of the application and trigger the resolve and make the attacker's activity a preferred activity.
2107330	2114370	And then we install an update to the exploit application with a larger number of categories and then trigger this vulnerability.
2114370	2117990	This will give us an even larger time frame.
2117990	2130610	However, this is not mandatory because we can declare like 10,000 of categories in a single intent filter and this will not crash the chooser dialogue.
2130810	2135790	And this can still give us like 100 milliseconds of racing time.
2136110	2143770	So this is just an exploitation technique here and you can take it or you may not need it.
2145230	2155370	And this vulnerability here, the bad resolve vulnerability, has some limitations here because it is an implicit intent resolution.
2155370	2161650	So it requires a target complement to have an intent filter with data element and it requires a target complement.
2161650	2170890	The target complement we want to start the privileged or protected activity we want to start to have an intent filter with the category default declared .
2170890	2180430	So we need to have a target to extend this ability, to expand the ability of this vulnerability , of this bad resolve series of vulnerabilities.
2180850	2189370	And the idea is that here we first use this vulnerability to call the search trampoline activity with the controlled intent parameter.
2189530	2196990	And in the onCreate function of the search trampoline activity, we can see that it has a very useful gadget here.
2196990	2206270	It retrieves a string from this incoming intent and call the path UI on it, which creates an intent again from the incoming string.
2206310	2215690	So here using this gadget, we can extend the functionality, extend the ability of the bad resolve vulnerability and the cause arbitrary activity at will.
2216630	2220210	So there is another interesting detail here that we can see.
2220370	2225130	Normally you cannot directly call the search trampoline activity because there is a permission check here.
2225130	2227050	It will check the colors package.
2227050	2235810	However, using bad resolve, the color package will be setting so you can easily bypass the check and use this gadget inside the search trampoline activity.
2236630	2242030	The fix for this vulnerability in the activator service is quite simple.
2242030	2248190	It just makes the implicit intent an explicit one using the set complement or set package.
2248190	2255610	So this kills the tactile window, the whole tactile scenario of our attack.
2256790	2270230	So digging this further and why I say this is a series of vulnerability because any code snippet that calls the start activity on intent after checking the resolution result can and will be vulnerable.
2270230	2281030	And this previously discussed issue is already fixed and I have found like four other code snippets in the Android open source project that are found to have similar vulnerabilities and reported to Google.
2281030	2283990	And there are two CVs assigned already.
2286960	2293520	So for the aspiration technique, the key parameter here is a timeout before the disabling complement.
2293520	2302620	So how much time will be spent in the resolve intent when we supply a malformed manifest, a malformed intent filter?
2302620	2305240	It varies on high-end and low-end devices.
2305240	2313100	It is understandable because on high-end devices, it will have higher CPU frequency and speed so it will take less time.
2313100	2315240	It will give us less time for racing.
2315400	2321360	And for example, on Pixel 7 Pro or Pixel 8 Pro, it is like 200 to 300 milliseconds.
2321640	2328060	However, on an old phone like Galaxy S21, this can be extended to like one second.
2328600	2331720	Anyway, we can continuously retry until we succeed.
2333180	2342700	So here is the first demo that we use this vulnerability to call the log password, modify the protected activity or the settings.
2345100	2347620	So it's quite straightforward.
2347620	2354840	You just use the vulnerability to start the arbitrary protected activity to modify ping in the settings application.
2355000	2364000	So here is another demo in the Android 16 Beta 3 and this is the newest version at the time of writing of this presentation.
2364940	2370460	And I wrote a script to ease the exploitation of this vulnerability.
2370460	2376180	And this is another similar vulnerability in the restriction fragment.
2376700	2382560	And this exploitation calls the performance of phone call without any privilege.
2382820	2390580	And here there is an interesting story here that previously we used our exploit to call 911.
2390800	2398500	And after several submissions, we were told by the Android security team that please stop calling 911.
2398800	2400880	Just call other phone numbers.
2400880	2403300	But do not call 911 in your exploit.
2408860	2417560	So we can go even further that there is still a problem with the search trampoline activity because the path UI does not support possible nested possible inside.
2417560	2425800	And some windows, for example, like the owner devices, they removed this gadget in their application.
2425960	2429520	So we found another gadget, the chooser activity, come to rescue.
2429520	2433020	And the chooser activity draws a possible from intent and starts it.
2433440	2440520	The chooser activity takes an actual intent from the input and launches using the start activity as caller.
2440600	2449080	And the Android version of the chooser activity has a priority of 500, which means that it's not applicable for our bad result targets.
2449140	2461460	However, Windows, they tend to implement their own version of choosers, like Xiaomi choosers, or like owner choosers, these kind of things.
2461460	2467320	And this custom choosers mimics official chooser activity, but they do not have priorities specified.
2467340	2470480	So they can be the target of the bad result.
2471000	2474720	So does this custom choosers verifies targets?
2474760	2476900	The answer is yes, but not enough.
2477380	2483140	The right part of the slide is a summary of the different gadgets in different windows.
2483200	2489120	We can see that in Android, we have the trampoline gadget, but we do not have the custom chooser gadget.
2489120	2494600	However, on like a Xiaomi devices, we both have the trampoline gadget and the custom chooser gadget.
2495960	2506620	So for example, on the Xiaomi devices, we can change the MIUI chooser activity here with the bad result vulnerability.
2506620	2510400	And here we use bad result to start the MIUI chooser activity.
2510400	2521240	The MIUI chooser activity verifies the caller has a permission to start the target intent it passed in, the target complement that the target intent resolved to.
2521240	2525520	However, here that when we use bad result, the caller is a setting.
2525520	2537800	So this check is passed and the MIUI chooser activity will happily start the actual intent passed in and starts the victim activity without any limitations.
2538560	2541520	However, there are still like different chooser implementations.
2541520	2547640	Some Windows chooser implementations verify the caller and also verify the target needs to be exported.
2547640	2550360	So we need an additional hope here.
2550360	2555640	For example, on Honor and the Huawei devices, we change another chooser activity.
2555640	2560580	The official chooser of the Android of the AOSP here.
2560580	2578700	And so the attack flow will be like attack application use bad result to start the HW chooser activity and the HW chooser activity verifies the caller has permission to start target and verifies target is exported because here the target is a chooser activity.
2578780	2580680	These conditions are met.
2580680	2586800	So it proceeds to a chooser activity and chooser activity verifies again that the caller has permission to start target.
2586800	2589580	However, here the target is settings and chooser activity.
2589580	2591800	So this check is also passed.
2591840	2599340	So then the chooser activity calls that activity as caller and finally the victim privileged or protected activity is started.
2600720	2607540	So the final part, I'm running a little bit out of time, so I'll go quickly here.
2607580	2610720	How we can use LRM to find this kind of bugs?
2611540	2632160	It's an interesting idea that maybe LRM is a better fit for finding bugs that bad result because as I have stated earlier that bad result is not a typical like data flow vulnerabilities that you can use static analysis to find.
2632200	2640240	Maybe for this kind of flexible vulnerability, LRM has a better ability or idea to find them.
2640360	2644460	And we design our system as illustrated in the figure.
2644460	2650720	We have a manager agent which uses MCPs to fetch code from the Android USB codebase or the vendor codebase.
2650720	2654220	In the vendor closed source codebase, we use the JEP.
2654240	2659000	And I have a JEP here with a GitHub link and if you're interested you can use it.
2659080	2665580	And the manager agent retrieves a possible vulnerable code and passes it to the auditor agent.
2665580	2669900	The auditor agent has a prompt to check if the code is vulnerable to bad result.
2670100	2677000	And the auditor agent, the result, the outcome of the auditor agent will be passed to the reviewer agent.
2677140	2684440	The reviewer agent will double check if there is a false positive here or false negative here and then outcome the result.
2685420	2704480	So here the LRM of course cannot directly consume all the USB codebase, so we need to search for APIs, the possible APIs that may appear in the possible vulnerable code, the result activity series, query intended series, and feed the functions and encoding classes into LRM.
2704480	2706980	And we use different MCPs here.
2706980	2719660	We have a quick and dirty prompt that you are Android expert, you need to input output in JSON, and you have a few short example that what is a bad result vulnerability, it's a total vulnerability.
2719940	2734660	And to avoid false positive, do not consider it vulnerable if the intent has become a specific set and complement, set target, and the intent has been set an action or the intent is not used to start activity or start activity for result.
2735320	2755480	So a quick observation here is that the LRM has false negatives but have a few false positives as there are hallucinations here on whether the intent is used to start activity and sometimes lack of knowledge of the tricky details of the Android security and sometimes lazy on querying call graph.
2755880	2758280	So there is still additional work needed.
2758860	2769880	So conclusion here is that we introduced the bad result vulnerabilities and how we support it and how we use the LRM to extend and search these kind of vulnerabilities.
2771300	2780820	Yeah, so this is the reference credits and you can reach us at myxaccount and also our lab's xaccount.
2780980	2786280	So I'm not sure if we have time for QA and here is all the slides.
2786280	2787260	Thank you.
