1 00:00:00,000 --> 00:00:01,820 All right, thanks everybody for coming out here today. 2 00:00:03,420 --> 00:00:07,260 So we are three researchers from Lookout Mobile Security. 3 00:00:07,480 --> 00:00:11,260 We like to do a lot of nerdy things on cell phones and poke around with them. 4 00:00:11,840 --> 00:00:14,580 So we're going to be talking on Android permissions today 5 00:00:14,580 --> 00:00:19,280 and some of the fun things that we can do with and without them. 6 00:00:20,840 --> 00:00:22,620 So the things we're going to talk about today, 7 00:00:23,160 --> 00:00:28,300 we're going to do a brief, boring overview of the Android internals 8 00:00:28,780 --> 00:00:33,440 just to get people who don't have any context of what some of these components are 9 00:00:33,440 --> 00:00:34,700 up to speed a little bit. 10 00:00:35,720 --> 00:00:39,040 Then we're going to talk about the security and permission model 11 00:00:39,040 --> 00:00:42,200 and a little brief overview on that and how the sandboxing works. 12 00:00:43,260 --> 00:00:46,120 At that point, then we'll talk about some of the fun things that we can do 13 00:00:47,100 --> 00:00:48,740 with permissions and without permissions 14 00:00:48,740 --> 00:00:54,680 and then talk about how we can use the system logging to leverage a lot of stuff as well. 15 00:00:55,100 --> 00:00:57,900 And then we're going to talk a little bit about routing 16 00:00:57,900 --> 00:00:58,280 and how we can use the system logging to leverage a lot of stuff as well. 17 00:00:58,300 --> 00:01:00,740 Android phones and some of the fun things with that. 18 00:01:00,940 --> 00:01:07,120 And then, of course, mitigation and what we can do to kind of approach these problems. 19 00:01:08,460 --> 00:01:11,760 So first thing, Android internals. 20 00:01:13,560 --> 00:01:18,420 So the Android manifest is basically just a big XML file 21 00:01:18,420 --> 00:01:23,220 that every Android application needs to have. 22 00:01:23,460 --> 00:01:27,700 The manifest is going to define your package name, 23 00:01:27,700 --> 00:01:32,220 which is a unique identifier for every application that's going to be in the market. 24 00:01:32,420 --> 00:01:34,820 And this is going to be your com.android.whatever. 25 00:01:35,660 --> 00:01:37,620 That's your package name that you usually see. 26 00:01:38,740 --> 00:01:43,660 Also, it's going to describe all the various components within the application itself. 27 00:01:45,180 --> 00:01:48,600 Any receivers, broadcast receivers it's going to have, 28 00:01:49,140 --> 00:01:53,220 activities that it has, any services, that kind of stuff. 29 00:01:54,020 --> 00:01:56,120 Also, this will declare all the permissions. 30 00:01:56,760 --> 00:01:57,680 Both permissions and permissions are going to be declared. 31 00:01:57,700 --> 00:02:01,500 Permissions that your application needs to access a lot of the protected APIs 32 00:02:02,700 --> 00:02:05,460 and also permissions that your application requires 33 00:02:05,460 --> 00:02:08,340 for other applications to interact with its components. 34 00:02:10,160 --> 00:02:13,760 Activities are basically just UI screens for Android, 35 00:02:13,980 --> 00:02:16,680 a way for the user to interact with the application. 36 00:02:17,360 --> 00:02:21,360 The activities themselves are just composed of a bunch of UI widgets called views, 37 00:02:21,600 --> 00:02:24,420 which are your button views, text views, that kind of stuff. 38 00:02:24,900 --> 00:02:27,680 The activities themselves are managed in what's called a UI widget. 39 00:02:27,680 --> 00:02:28,820 It's called an activity stack. 40 00:02:29,600 --> 00:02:35,480 Basically meaning that any new activity created is going to be at the top of that stack on the screen 41 00:02:35,480 --> 00:02:39,300 and any other UI screens are going to be down below that on the stack. 42 00:02:39,580 --> 00:02:45,400 The most foreground activity is going to be the running activity in an active state 43 00:02:45,400 --> 00:02:50,340 and any activities down below it on the stack are going to be in a pause state 44 00:02:50,340 --> 00:02:53,760 where they're not running, not doing anything, and just saving state. 45 00:02:54,800 --> 00:02:57,120 The activities will remain in that stack 46 00:02:57,680 --> 00:03:03,840 until they finish, or the system can yank them out and kill them if memory is running low. 47 00:03:07,120 --> 00:03:10,540 Applications can also start other applications' activities remotely. 48 00:03:11,640 --> 00:03:16,140 The activity itself is going to run within the process of the remote application. 49 00:03:16,640 --> 00:03:21,660 In a situation where you've requested location permissions 50 00:03:21,660 --> 00:03:24,800 and you want to have the user turn on their GPS 51 00:03:24,800 --> 00:03:27,020 and you detect that that's not enabled, 52 00:03:27,680 --> 00:03:32,800 the system can start the settings activity with all the location settings 53 00:03:32,800 --> 00:03:35,520 so they can enable that and then once that activity finishes 54 00:03:35,520 --> 00:03:37,380 they'll be back at the previous screen. 55 00:03:38,360 --> 00:03:43,480 Since that's running in its own applications process, 56 00:03:43,920 --> 00:03:48,260 the collie won't necessarily have access to any of the data in that activity. 57 00:03:48,560 --> 00:03:51,380 If you're starting your own activities within your own application, 58 00:03:51,640 --> 00:03:54,580 then you'll of course be able to have access to that. 59 00:03:55,860 --> 00:03:57,400 Activities themselves can... 60 00:03:57,680 --> 00:04:02,920 have permissions enforced on them so that other processes can't start activities within 61 00:04:02,920 --> 00:04:07,320 your application without having requested whatever permission that you set. 62 00:04:08,840 --> 00:04:16,920 Intents for Android are basically a way for applications to do simple IPC so that they 63 00:04:16,920 --> 00:04:23,820 can send an event or an action along with data, which is usually in the form of a URI. 64 00:04:23,820 --> 00:04:34,020 So if we want to start up a browser, we can send an action view intent with a URL as our 65 00:04:34,020 --> 00:04:39,120 data and that will fire up the browser using that intent. 66 00:04:41,720 --> 00:04:46,840 As we said, they can be used to start activities with startActivity. 67 00:04:47,000 --> 00:04:50,920 We can also broadcast intents using sendBroadcast. 68 00:04:51,180 --> 00:04:53,320 This basically just sends out... 69 00:04:53,320 --> 00:04:53,800 ... 70 00:04:53,820 --> 00:04:54,240 ... 71 00:04:54,240 --> 00:04:55,120 an intent en masse. 72 00:04:55,320 --> 00:05:00,660 So for instance, anyone that would want to be notified about an SMS being received, 73 00:05:00,840 --> 00:05:06,820 an intent will be fired off across the system to anyone that wants to know about that event. 74 00:05:07,320 --> 00:05:11,080 There will be two types of intents that you can receive that way. 75 00:05:11,320 --> 00:05:17,420 There are just normal regular intents, which are just sent out en masse, no particular 76 00:05:17,420 --> 00:05:23,520 order all at once, and you can't actually abort those intents or use the... 77 00:05:23,520 --> 00:05:25,280 ...result from those. 78 00:05:25,480 --> 00:05:27,140 And then you also have... 79 00:05:27,140 --> 00:05:29,380 ... ... 80 00:05:30,960 --> 00:05:31,840 ... 81 00:05:31,840 --> 00:05:32,880 ... 82 00:05:32,880 --> 00:05:33,780 ... 83 00:05:33,780 --> 00:05:34,980 ... 84 00:05:34,980 --> 00:05:35,540 ... 85 00:05:35,540 --> 00:05:35,560 ... 86 00:05:54,120 --> 00:05:59,600 We can do an ordered broadcast, which is sending them out sequentially to each of the different 87 00:05:59,600 --> 00:06:05,380 receivers where when one receives it, it'll get the result from the previous one, be able 88 00:06:05,380 --> 00:06:08,880 to do whatever processing it wants on that. 89 00:06:09,080 --> 00:06:15,660 It can also abort the intent if it wants to, or abort the broadcast so that no one else 90 00:06:15,660 --> 00:06:19,300 further down the line will be able to receive that, and then they can also send their result 91 00:06:19,300 --> 00:06:20,740 to the next receiver down the line. 92 00:06:21,800 --> 00:06:25,340 We can declare our broadcast receivers in two different ways. 93 00:06:25,400 --> 00:06:30,820 We can either register them dynamically within our application, or we can have a static receiver 94 00:06:30,820 --> 00:06:32,020 tag within our manifest. 95 00:06:33,680 --> 00:06:39,580 Also, our broadcast receivers can also have permissions enforced on them, so that you 96 00:06:39,580 --> 00:06:43,520 can either request that you need to have a certain permission if you want to send something 97 00:06:43,520 --> 00:06:48,900 to me, or that if you're sending out a broadcast, only broadcast receivers that have requested 98 00:06:48,900 --> 00:06:50,340 this permission can receive that. 99 00:06:52,380 --> 00:06:57,180 Services are a component that sounds just like what they are. 100 00:06:57,340 --> 00:06:59,180 They do work in the background. 101 00:07:00,420 --> 00:07:04,140 They aren't actually a separate process or running in a separate thread. 102 00:07:05,000 --> 00:07:09,280 Any processing is going to run in the main thread of the application, so if you're going 103 00:07:09,280 --> 00:07:14,380 to do any kind of CPU-intensive work or blocking, you're going to want to spin off your own 104 00:07:14,380 --> 00:07:15,340 thread from your service. 105 00:07:15,800 --> 00:07:20,220 This essentially just acts like an activity without any UI. 106 00:07:20,340 --> 00:07:25,940 Like all the other components, these can also enforce permissions for access to them. 107 00:07:27,480 --> 00:07:34,100 With the security and permission model, we all know that all the processes are running 108 00:07:34,100 --> 00:07:37,660 in a sandbox, and everyone's aware about the security around that. 109 00:07:37,860 --> 00:07:40,740 The sandbox itself is not the VM. 110 00:07:40,880 --> 00:07:43,340 A lot of people think that the Dalvik VM is the sandbox. 111 00:07:43,620 --> 00:07:44,660 This is not the case. 112 00:07:44,820 --> 00:07:49,580 The sandbox is actually just Unix user permissions. 113 00:07:52,380 --> 00:07:56,640 You have your UID and GID for every process. 114 00:07:57,220 --> 00:08:02,880 Every application is essentially a different user on the system, so they don't have access 115 00:08:02,880 --> 00:08:09,700 to each other's data on the file system, and then they're also just running in a multiprocess 116 00:08:09,700 --> 00:08:13,020 environment where they are going to have segregated address spaces. 117 00:08:13,680 --> 00:08:20,020 Each application running is going to have its own lightweight VM. 118 00:08:20,020 --> 00:08:29,060 This is the Dalvik VM, which is just a Java-like VM that is based off of passing through registers 119 00:08:29,060 --> 00:08:30,060 rather than on the stack. 120 00:08:30,940 --> 00:08:33,880 If you're able to break out of this VM, you gain nothing. 121 00:08:34,120 --> 00:08:37,580 If you're able to get native code execution, you're still going to be running the same 122 00:08:37,580 --> 00:08:41,940 process with the same user privilege that the VM itself had. 123 00:08:43,660 --> 00:08:47,840 Applications can both request to share a UID so that they're essentially both running as 124 00:08:47,840 --> 00:08:48,480 the same user. 125 00:08:48,480 --> 00:08:52,080 Then they can share data on the file system and some other things. 126 00:08:52,300 --> 00:08:58,460 Both applications need to request that explicitly, and both applications would need to be signed 127 00:08:58,460 --> 00:08:59,500 with the same signer key. 128 00:09:02,320 --> 00:09:08,820 Permissioning is essentially just a more fine-grained enforcement of access to various 129 00:09:08,820 --> 00:09:12,140 protected APIs on the system or content. 130 00:09:12,480 --> 00:09:18,460 Any application that wants to be able to access the Internet or receive SMS or any kind of 131 00:09:18,460 --> 00:09:21,540 service or look at your contacts, they're going to have to request specific permissions 132 00:09:22,100 --> 00:09:23,240 to be able to do that. 133 00:09:24,060 --> 00:09:26,120 These are, as I said, declared in the manifest. 134 00:09:28,380 --> 00:09:32,720 With that, David's going to talk about some of the fun things that we can do with these. 135 00:09:35,860 --> 00:09:36,580 Thanks, Anthony. 136 00:09:38,040 --> 00:09:46,600 Now I want to talk about a little bit of Android development and why permissions are important, 137 00:09:46,820 --> 00:09:48,140 why you ask for them in the first place. 138 00:09:48,460 --> 00:09:50,560 And do we need to ask for them? 139 00:09:51,480 --> 00:09:54,920 The motto here, why ask for permission when you can ask for forgiveness? 140 00:09:56,420 --> 00:10:03,440 The reason why permissions matter is because they gate what an app can do, and the user 141 00:10:03,440 --> 00:10:06,100 is displayed them when they install an application. 142 00:10:06,380 --> 00:10:09,560 You install Pandora Radio from the Android market. 143 00:10:09,640 --> 00:10:13,560 You see this screen here that tells you different things it can do. 144 00:10:13,680 --> 00:10:14,740 It can access the network. 145 00:10:15,020 --> 00:10:16,680 That seems appropriate. 146 00:10:16,860 --> 00:10:17,480 It's Pandora. 147 00:10:17,480 --> 00:10:18,120 It's Internet radio. 148 00:10:18,360 --> 00:10:19,260 It should be able to. 149 00:10:19,340 --> 00:10:20,540 It can read your phone state. 150 00:10:21,000 --> 00:10:24,980 That's presumably to pause playing of the radio when you get a phone call. 151 00:10:26,380 --> 00:10:32,760 So users can look at a screen like this, and they can decipher to some degree whether 152 00:10:32,760 --> 00:10:36,680 or not those are appropriate permissions for the application. 153 00:10:37,400 --> 00:10:38,980 So let's go to another example. 154 00:10:39,660 --> 00:10:41,500 Here are two different TikTok toe apps. 155 00:10:42,120 --> 00:10:47,080 One of them only requests Internet and to be able to view the network state. 156 00:10:47,080 --> 00:10:48,920 So maybe it has a high score. 157 00:10:49,120 --> 00:10:50,560 Maybe it has multiplayer. 158 00:10:51,320 --> 00:10:57,100 But this other one requests system tools, mount and unmount file systems, which just 159 00:10:57,100 --> 00:10:57,660 sounds strange. 160 00:10:57,980 --> 00:11:01,720 So if I were you, I would download the one that only accesses the Internet. 161 00:11:04,120 --> 00:11:08,340 And so what does it mean if you request zero permissions? 162 00:11:09,060 --> 00:11:12,660 That means when you click install from the market, it just starts downloading the app. 163 00:11:12,880 --> 00:11:13,840 There's no warnings. 164 00:11:13,920 --> 00:11:16,500 It doesn't warn you at all about what an app can or can't do. 165 00:11:16,500 --> 00:11:22,480 And so I think that a lot of users will probably assume if they don't see that screen that 166 00:11:22,480 --> 00:11:24,020 they shouldn't worry about that app. 167 00:11:24,080 --> 00:11:30,000 That app can't do anything harmful to me because it's not requesting any permissions. 168 00:11:30,180 --> 00:11:31,660 The OS isn't warning me at all. 169 00:11:32,220 --> 00:11:36,740 So we're going to show all sorts of fun things you can do with zero permissions. 170 00:11:37,520 --> 00:11:41,400 So some of these are silly, and some of them have more serious ramifications. 171 00:11:42,440 --> 00:11:44,700 So the first one is reboot. 172 00:11:45,420 --> 00:11:50,940 There's a reboot permission that's actually marked as signature or system. 173 00:11:51,320 --> 00:11:56,000 And what that means is that it's not actually grantable to apps from the marketplace. 174 00:11:56,720 --> 00:11:59,800 This permission would be denied if you requested it. 175 00:12:01,460 --> 00:12:07,920 You have to either be signed by the device signer or be in the system directory in order 176 00:12:07,920 --> 00:12:09,740 for you to be able to be granted this permission. 177 00:12:10,560 --> 00:12:13,680 You could say that Bob the Guardian is protecting this permission. 178 00:12:14,700 --> 00:12:17,080 A reboot joke fell flat on this audience. 179 00:12:18,780 --> 00:12:20,860 All right, thank you. 180 00:12:23,320 --> 00:12:25,440 But Bob isn't going to stop us. 181 00:12:26,280 --> 00:12:28,560 So there are a couple different approaches to do this. 182 00:12:30,340 --> 00:12:33,380 The easiest one involves toast notifications. 183 00:12:33,940 --> 00:12:39,660 So here a toast notification is a way to notify you of something that goes on in the background. 184 00:12:40,520 --> 00:12:43,900 So in this case, you're in the keypad activity. 185 00:12:43,900 --> 00:12:51,320 And a toast pops up to tell you about something else that's going on in the OS that some other 186 00:12:51,320 --> 00:12:51,780 app is doing. 187 00:12:53,360 --> 00:12:56,440 So here's just the basic hello world for a toast. 188 00:12:56,660 --> 00:12:59,020 And then I've thrown it inside a while-through loop. 189 00:12:59,140 --> 00:13:03,080 So we're just going to create as many toasts as we can and see what happens. 190 00:13:03,560 --> 00:13:11,380 Every time that you create and display a toast, it creates a weak JNI reference in the Android 191 00:13:11,380 --> 00:13:12,140 system server. 192 00:13:14,680 --> 00:13:23,400 And when you get to 2001 global references, the system says I can't let you do that, Dave, 193 00:13:26,240 --> 00:13:32,660 and throws a sig-seg V and crashes the phone. 194 00:13:33,280 --> 00:13:34,340 So that's cool. 195 00:13:34,440 --> 00:13:35,960 You can get the OS to reboot. 196 00:13:36,620 --> 00:13:37,480 That's pretty fun. 197 00:13:37,680 --> 00:13:43,660 But during this process, it would display a little toast on the screen that would say 198 00:13:43,660 --> 00:13:44,600 something like hello world. 199 00:13:45,040 --> 00:13:49,320 Now you could do something fun with this like display a countdown timer to when your phone 200 00:13:49,320 --> 00:13:49,920 was going to reboot. 201 00:13:50,740 --> 00:13:54,340 But you could also maybe we can make this even more hidden. 202 00:13:55,080 --> 00:13:57,360 So there's also this idea of a custom toast. 203 00:13:58,040 --> 00:14:01,980 So a custom toast is any view I can display on the screen. 204 00:14:02,240 --> 00:14:05,460 So here this custom toast is Powder Toast Man. 205 00:14:05,720 --> 00:14:09,280 Just an image of Powder Toast Man appears, fades in, would fade out. 206 00:14:09,500 --> 00:14:12,260 But you could also just create a view with nothing in it. 207 00:14:12,260 --> 00:14:17,940 So you just create an invisible view, you pop it up, and after about 20 seconds of this 208 00:14:17,940 --> 00:14:19,840 loop running, the phone reboots. 209 00:14:22,500 --> 00:14:27,220 So that's one cool thing that we can do, that any app can do, because this requires 210 00:14:27,220 --> 00:14:27,900 zero permissions. 211 00:14:29,440 --> 00:14:33,600 So without any warning, an app could reboot your phone if they wanted to. 212 00:14:34,960 --> 00:14:41,040 So now that your phone is rebooting and it starts to boot up, there's a permission called 213 00:14:41,040 --> 00:14:42,080 receive boot complete. 214 00:14:42,260 --> 00:14:45,960 And this shows up in the Android permission screen. 215 00:14:46,020 --> 00:14:51,220 It says allow app to start at startup or something along those lines. 216 00:14:51,320 --> 00:14:55,440 But the idea here is that the app would automatically start, right? 217 00:14:55,840 --> 00:15:03,060 So this one is a little embarrassing, because you can just comment out the request for the 218 00:15:03,060 --> 00:15:04,200 permission and it still works. 219 00:15:04,980 --> 00:15:07,000 Works in all Android versions. 220 00:15:07,600 --> 00:15:11,420 So any app can start on boot, regardless of whether or not they ask for permission. 221 00:15:11,720 --> 00:15:12,240 So that's one cool thing about this. 222 00:15:12,860 --> 00:15:18,580 And so you can imagine, you could combine that with the previous toast in a loop, and 223 00:15:19,120 --> 00:15:22,380 you would have a phone that would be rebooting every 20 seconds. 224 00:15:24,160 --> 00:15:28,520 So then another thing, this one there's not actually permission for, but another interesting 225 00:15:28,520 --> 00:15:37,060 thing that developers of malicious and non-malicious applications would like is to be able to start 226 00:15:37,060 --> 00:15:38,580 their app on installation. 227 00:15:40,340 --> 00:15:42,240 So you can imagine that... 228 00:15:42,260 --> 00:15:44,080 You could use this with a couple other attacks. 229 00:15:44,560 --> 00:15:49,400 Maybe you don't want them to know that running your applications caused it to reboot. 230 00:15:49,620 --> 00:15:52,560 So instead you just reboot 20 seconds after they install the app. 231 00:15:52,880 --> 00:16:00,140 Or you could imagine this would be while you're in the Google market, and you've just finished 232 00:16:00,140 --> 00:16:04,140 installing an app, and you're kind of used to the fact that an app can't run until you 233 00:16:04,140 --> 00:16:04,760 launch it. 234 00:16:05,000 --> 00:16:09,920 So you could also maybe pop up a phishing dialogue at this point, asking for their username 235 00:16:09,920 --> 00:16:10,480 and password. 236 00:16:10,680 --> 00:16:10,840 Okay. 237 00:16:10,840 --> 00:16:15,740 And they totally wouldn't see it coming because apps aren't supposed to be able to run until 238 00:16:15,740 --> 00:16:17,240 you run them for the first time. 239 00:16:18,760 --> 00:16:22,740 So there's not a permission for this, but Google Analytics does this. 240 00:16:23,200 --> 00:16:29,380 So this snippet of code here to add to the Android manifest is actually from the Google 241 00:16:29,380 --> 00:16:30,740 Analytics for mobile SDK. 242 00:16:32,540 --> 00:16:35,280 And you just throw that in there. 243 00:16:35,420 --> 00:16:40,180 And this is to track the refer. 244 00:16:40,440 --> 00:16:40,820 Okay. 245 00:16:40,840 --> 00:16:41,500 So this is from the market. 246 00:16:41,620 --> 00:16:49,340 So say whether I clicked on some AdMob link or something like that, and then this would 247 00:16:49,340 --> 00:16:50,800 send it off to the Google Analytics server. 248 00:16:51,000 --> 00:16:53,360 But we don't need to use their receiver. 249 00:16:53,660 --> 00:16:54,780 We can just write our own receiver. 250 00:16:56,100 --> 00:17:01,020 So here we just created our own receiver instead of using theirs. 251 00:17:02,060 --> 00:17:05,340 And now we can launch on install. 252 00:17:05,640 --> 00:17:08,220 But there are some caveats with this. 253 00:17:08,540 --> 00:17:08,720 Okay. 254 00:17:08,720 --> 00:17:12,120 So it actually does require a refer to be included in the URL. 255 00:17:13,200 --> 00:17:16,360 So you can imagine two main scenarios where that would happen. 256 00:17:16,640 --> 00:17:20,920 One, they click on an AdMob link inside another application or on the Internet. 257 00:17:22,200 --> 00:17:26,640 And you can see there's all this refer data that's attached to it that tells you what 258 00:17:26,640 --> 00:17:28,720 campaign it was a part of and things like that. 259 00:17:29,100 --> 00:17:34,400 Another way is if they clicked on just any old link in a browser, you could just append 260 00:17:34,400 --> 00:17:36,940 your own refer info on it just so that this would happen. 261 00:17:36,940 --> 00:17:44,320 However, on Android 2.2 on Froyo, the Android market now always includes refer info. 262 00:17:44,700 --> 00:17:46,440 So this now always works. 263 00:17:47,560 --> 00:17:53,140 They include refer info of things like in this example, it says that we downloaded it 264 00:17:53,140 --> 00:17:58,600 from the games tab, the free section, and it was row index 34. 265 00:17:58,840 --> 00:18:00,040 So it gives you all sorts of cool info. 266 00:18:00,380 --> 00:18:03,480 But we can also use it here to start on install. 267 00:18:04,720 --> 00:18:06,520 So the next thing that I want to talk about. 268 00:18:07,280 --> 00:18:09,640 I like to call the circle of death. 269 00:18:10,020 --> 00:18:13,940 And this is basically just a hostile takeover of the UI. 270 00:18:14,940 --> 00:18:16,300 So it's pretty simple. 271 00:18:16,500 --> 00:18:19,660 You just launch an activity, consume all key press events. 272 00:18:20,140 --> 00:18:25,380 So here in the on key down method, we're just returning true, which says we handled 273 00:18:25,380 --> 00:18:26,140 this key press. 274 00:18:26,640 --> 00:18:28,300 Don't pass it on to anyone else. 275 00:18:29,000 --> 00:18:34,340 So this allows us to catch every key press except for the home button and a long press 276 00:18:34,340 --> 00:18:35,120 of the home button. 277 00:18:35,120 --> 00:18:38,720 Which is a shortcut to allow you to switch between applications. 278 00:18:41,320 --> 00:18:43,400 So we need to do something else also. 279 00:18:43,600 --> 00:18:44,700 So what can we do? 280 00:18:44,780 --> 00:18:47,800 We can just relaunch our activity when it exits. 281 00:18:49,540 --> 00:18:54,580 Now unfortunately it's not as easy as just starting the intent for our activity and it's 282 00:18:54,580 --> 00:18:55,280 on destroy event. 283 00:18:55,560 --> 00:19:00,540 We have to be a little more clever than that because Android detects that and doesn't fire 284 00:19:00,540 --> 00:19:02,460 off the intent in that case. 285 00:19:03,020 --> 00:19:04,860 So what we can do instead is. 286 00:19:04,860 --> 00:19:05,820 Create a circle of death. 287 00:19:06,520 --> 00:19:10,460 So just when our activity is destroyed, we just launch a service. 288 00:19:11,000 --> 00:19:14,200 And this service just launches our original activity. 289 00:19:14,900 --> 00:19:18,480 So all we have to do in the on destroy event, we start a service. 290 00:19:18,700 --> 00:19:22,980 And all that service does, start an activity and then can just finish itself. 291 00:19:25,800 --> 00:19:30,860 And you can imagine the ramifications here. 292 00:19:31,260 --> 00:19:34,840 It's actually a pretty easy work around to get something like this off. 293 00:19:34,840 --> 00:19:39,720 You can actually boot up into what's called safe mode, on Android. 294 00:19:39,980 --> 00:19:45,460 You usually just hold in the trackball while you're starting up your phone and all non-system 295 00:19:45,460 --> 00:19:48,200 apps aren't allowed to run. 296 00:19:49,860 --> 00:19:52,560 And so here I just want to show a quick demo. 297 00:19:52,660 --> 00:19:53,480 Hopefully this will work. 298 00:19:54,240 --> 00:19:59,180 I know that you guys can't really see this, but hopefully you'll be able to hear it. 299 00:20:05,280 --> 00:20:11,680 So here's an application that I've installed on here. And you can imagine that you could 300 00:20:11,680 --> 00:20:16,940 use this in all sorts of different ways, right? You could force someone to pay $5 on PayPal 301 00:20:16,940 --> 00:20:23,840 to get rid of this. If I can mash all the keys I want, I can't get out of here. All 302 00:20:23,840 --> 00:20:32,200 I can do is turn the screen off, but I'm still here. So let me just pull the battery out 303 00:20:32,200 --> 00:20:42,300 there. And once again, you can imagine that it's very easy to combine that with something 304 00:20:42,300 --> 00:20:48,320 like the start on boot, and you've created some serious mayhem. But all of this is just 305 00:20:48,320 --> 00:20:56,140 kind of for fun. There's not, none of that is all that serious. But let's talk about 306 00:20:56,140 --> 00:20:59,340 something, something that might be a little cooler. 307 00:21:00,040 --> 00:21:01,520 So let's say, 308 00:21:01,620 --> 00:21:02,180 Okay. 309 00:21:02,640 --> 00:21:06,080 Let's say there's an application that doesn't request permission to use the Internet. 310 00:21:06,280 --> 00:21:12,020 Maybe you would assume that it's fairly safe and that it can't contact a server. So you're not 311 00:21:12,020 --> 00:21:17,080 so worried about the fact that it's requesting your location or all sorts of other things. You 312 00:21:17,080 --> 00:21:21,420 just say, oh, that can't access the Internet. I'm not so worried about it. I don't care that it 313 00:21:21,420 --> 00:21:26,720 can read my contacts. But just because it doesn't request the Internet doesn't mean that it 314 00:21:26,720 --> 00:21:32,180 can't exfiltrate some data anyway. So even though its sandbox can't access the Internet, 315 00:21:32,180 --> 00:21:37,760 that doesn't mean, all of the other sandboxes around it can. Or most of them can. So you 316 00:21:37,760 --> 00:21:42,900 can just ask your neighbor. So the easiest way to do this would be to just pop open a 317 00:21:42,900 --> 00:21:50,920 browser and point it at some URL and include some parameters in it. So here you can imagine 318 00:21:50,920 --> 00:21:56,900 that you send your latitude and longitude off to some server. But there's a problem 319 00:21:56,900 --> 00:22:02,160 with this. It does pop open a browser. The browser would appear and the user would be able to access it. 320 00:22:02,160 --> 00:22:07,160 It would be like, huh, that's kind of strange. Why is there a browser on the screen? So then the 321 00:22:07,160 --> 00:22:13,320 question is, is there a way that we can do this secretly? If you attempt to pop open the browser 322 00:22:13,320 --> 00:22:19,160 and then pop open another activity on top of it, obscuring the activity actually causes the on 323 00:22:19,160 --> 00:22:25,520 pause event to happen, which stops the page from loading. So that won't actually work. We have to 324 00:22:25,520 --> 00:22:32,140 do something a little more clever. So how about we only pop up the browser when the screen is 325 00:22:32,160 --> 00:22:37,760 off? Your screen is off for, you know, what, 16 hours a day anyway. It's okay if we only get 326 00:22:37,760 --> 00:22:45,760 Internet during those times. So let's say, so there's a couple of things that you need to keep 327 00:22:45,760 --> 00:22:50,520 in mind here. You need to be able to close the browser when the screen turns back on. And you 328 00:22:50,520 --> 00:22:56,100 probably want to redirect to a safe URL so when the user does launch their browser again later, 329 00:22:56,220 --> 00:23:02,140 they're not on some weird page. So here's the basic code that does that. You want to make sure that 330 00:23:02,160 --> 00:23:08,900 you just ask the power manager if the screen is on. If it is, you, or if it's not, then you send 331 00:23:08,900 --> 00:23:19,020 off data to some server. And if it is on, then you, and the browser is displayed, then you launch 332 00:23:19,020 --> 00:23:25,340 the home activity. So you just send an intent to launch the home screen. You don't even need to 333 00:23:25,340 --> 00:23:29,240 kill the browser because that would actually require some permissions. We can launch the home 334 00:23:29,240 --> 00:23:30,560 screen for free. No permissions. 335 00:23:32,160 --> 00:23:37,440 So this is cool, and it allows us to send data out from our application even though we haven't 336 00:23:37,440 --> 00:23:43,760 requested permission to do so. But what if we want to be able to receive a response, too? So what 337 00:23:43,760 --> 00:23:50,540 about two-way communication? So there's a couple approaches here. The simplest would be to just 338 00:23:50,540 --> 00:23:56,040 pop open a browser to a page with a downloadable content type. So we just send it off, point it at 339 00:23:56,040 --> 00:24:02,000 this zip, downloads it, it puts it in the SD card downloads directory. Anyone can read the SD 340 00:24:02,000 --> 00:24:08,740 card. There's no permission to do so. So, but there are some downsides here. One, it creates all 341 00:24:08,740 --> 00:24:13,300 these notifications. So if you put your phone in your pocket and you pulled it out later, you'd have 342 00:24:13,300 --> 00:24:19,580 like 800 notifications or something like that. And then the other thing is that it creates all of 343 00:24:19,580 --> 00:24:24,960 these, it actually creates all of these files on your SD card. In order to clean that up, you need 344 00:24:24,960 --> 00:24:31,480 to request the right external storage permission, which isn't actually that big of a deal because if 345 00:24:32,000 --> 00:24:37,000 your target SDK is 3, that permission didn't exist yet and you are automatically, you automatically 346 00:24:37,000 --> 00:24:43,040 request it. So if you go through the market, a lot of applications request this. So I think most 347 00:24:43,040 --> 00:24:49,140 people just tune this permission out. But I think we can do a little better. So how about a 348 00:24:49,140 --> 00:24:55,820 custom URI receiver? So Google Maps uses the Geo protocol. They just register on this Geo 349 00:24:55,820 --> 00:25:01,820 protocol. So like Geo, colon, latitude, longitude. If you click on a link that's of that format, it 350 00:25:01,820 --> 00:25:01,980 pops up. So if you click on a link that's of that format, it pops up. So if you click on a link that's 351 00:25:01,980 --> 00:25:02,480 of that format, it pops up. So if you click on a link that's of that format, it pops up. So if you 352 00:25:02,480 --> 00:25:06,240 that keeps the URL from getting broken up, apps open, the Google Maps application. Now we can do 353 00:25:06,240 --> 00:25:15,780 the same thing with our application with no permissions. So we just request the net hack 354 00:25:15,780 --> 00:25:25,980 scheme. So the net hack protocol, the host here is data, which is basically another way to 355 00:25:25,980 --> 00:25:31,880 think about this. If this was the YouTube activity, the scheme would be HTTP, and the host 356 00:25:31,880 --> 00:25:37,320 would be YouTube.com. And that allows it so when you click on a YouTube link inside the 357 00:25:37,320 --> 00:25:43,480 browser, instead of showing you the web page, it pops up in the YouTube app. So what we 358 00:25:43,480 --> 00:25:48,160 would do on the server side is we would just redirect that page that we're sending, that 359 00:25:48,160 --> 00:25:53,900 we're pointing the browser to, to something like NetHack, call in data, and then append 360 00:25:53,900 --> 00:26:00,080 any additional information that we want to the end of it. Now, I'll note that this is 361 00:26:00,080 --> 00:26:04,780 actually an activity and not a receiver, even though we're using it like a receiver. The 362 00:26:04,780 --> 00:26:10,680 reason why is because activities are meant to be things that happen in the foreground, and 363 00:26:11,180 --> 00:26:14,900 this is meant to be used for something that happens in the foreground. This is supposed to 364 00:26:14,900 --> 00:26:19,240 be you click on a link or something like that. It's not supposed to be a page redirecting 365 00:26:19,240 --> 00:26:27,400 while your phone is off in your pocket. So here's just the basic receiver code, the 366 00:26:27,400 --> 00:26:29,320 receiver, because it's actually an activity. 367 00:26:30,720 --> 00:26:39,180 We can just log the URI and you see all the data that's associated in it. The data is 368 00:26:39,180 --> 00:26:45,960 available on the intent. This activity is actually, it's not seen as long as we call finish 369 00:26:45,960 --> 00:26:50,200 inside the on create. We've never created anything on the screen. The user doesn't know 370 00:26:50,200 --> 00:26:56,500 anything is up. And even if they did, their phone is off in their pocket. So once again, same 371 00:26:56,500 --> 00:27:00,040 caveat from before, you probably want to send, send, send, send, send, send, send, send, send, 372 00:27:00,040 --> 00:27:04,020 send, send, send, send, send, send. You can't send the user to a safe page afterwards. So 373 00:27:04,020 --> 00:27:13,360 when they open their browser, they don't see something funky. So let's see if it works. So, on 374 00:27:13,360 --> 00:27:21,740 the top here, I have my Apache logs. I know this is dangerous to be showing. And on the bottom 375 00:27:21,740 --> 00:27:30,020 here, I have ADB log cat output for my emulator here. So as you can see, I'm using the 376 00:27:30,040 --> 00:27:38,600 Apache logs. Nothing is going on. And then if I, let me go to the home screen. If I turn the 377 00:27:38,600 --> 00:27:44,840 screen off, and I'll note that the emulator, this is as off the screen gets on the emulator. But 378 00:27:44,840 --> 00:27:49,200 really this would be a black screen. We can see here already that there's some activity 379 00:27:49,200 --> 00:27:59,820 happening in log cat down here. And we've got, we've got data. We are, so that's the upload. 380 00:28:04,280 --> 00:28:11,100 That's the upload. And then let's see if we got the response. And here we go. There's the 381 00:28:11,100 --> 00:28:26,680 response. My secret. So there you have it. Two-way communication with an app with zero 382 00:28:26,680 --> 00:28:30,020 permissions. So now that I've told you this, I'm going to show you a little bit of the 383 00:28:30,040 --> 00:28:35,320 cool stuff that you can do with zero permissions. I'm going to turn it over to Tim who's going 384 00:28:35,320 --> 00:28:45,140 to tell you lots of cool stuff you can do with just one permission. How many of you guys have 385 00:28:45,140 --> 00:28:52,780 written Android code before? All right. So I'll try to go through the interior here pretty 386 00:28:52,780 --> 00:28:58,860 quickly. But this is, you know, a typical example of how you write data to the system logs. Most 387 00:29:00,040 --> 00:29:04,060 people don't know this. And, you know, it's relatively simple. It's an easy to use framework. 388 00:29:04,220 --> 00:29:11,000 And this is how we debug a lot of stuff. So there are actually four, four different log devices 389 00:29:11,000 --> 00:29:19,200 that are available on a typical handset. In fact, up until 2.2 there were three. And now we've 390 00:29:19,200 --> 00:29:28,680 seen the appearance of a fourth in 2.2. So devlog events is not the main application debug log. This 391 00:29:28,680 --> 00:29:33,040 is actually supposed to be for diagnostic events that are typically used by integrators 392 00:29:33,620 --> 00:29:40,020 or, or, you know, people working on the core system. Devlog radio is actually a lot, you 393 00:29:40,020 --> 00:29:44,880 typically see a lot of radio command stream data flying around in here. And also some 394 00:29:44,880 --> 00:29:49,440 interesting events about registering and unregistering from networks and that kind of stuff. And 395 00:29:49,440 --> 00:29:56,300 then we have devlog main is actually where your typical, you know, log.d, log.e, whatever 396 00:29:56,300 --> 00:29:58,660 output from a, from an application. And that's a pretty common application, and it's a pretty 397 00:29:58,680 --> 00:30:07,040 is going to go. So you access these logs using the Logcat utility. A lot of people have probably 398 00:30:07,040 --> 00:30:11,940 used that and just seen that typically you're going to see a big stream of data because 399 00:30:11,940 --> 00:30:15,320 there's an awful lot of chatty stuff that's going on in the device at any particular point 400 00:30:15,320 --> 00:30:22,980 in time. So ability to read the system logs is actually gated by the read logs permission. 401 00:30:22,980 --> 00:30:28,980 The shell account is granted this permission so that when you have ADB debugging enabled, 402 00:30:29,140 --> 00:30:34,600 you can do ADB Logcat from a host system that's tethered through a USB cable and see things. 403 00:30:35,280 --> 00:30:42,020 But you can kind of think of read logs as an alias for read everything, as we're going 404 00:30:42,020 --> 00:30:48,740 to show here in a second. And it's worth noting that the documentation on the read logs permission 405 00:30:48,740 --> 00:30:52,780 actually recommends that the developers be careful about what they disclose. 406 00:30:55,620 --> 00:31:02,900 So we put a client together and this is an Android service that only requests read logs 407 00:31:02,900 --> 00:31:08,260 and internet. And as you guys have just seen in this room, internet is actually just to 408 00:31:08,260 --> 00:31:13,940 make it easier to write the POC here. David demonstrated that that's not really required. 409 00:31:14,780 --> 00:31:20,400 So the client downloads a set of policies from the server and they're basically regular 410 00:31:20,400 --> 00:31:22,460 expressions that script the logs. 411 00:31:22,460 --> 00:31:25,980 logs and feed interesting stuff back to the server component for analysis. 412 00:31:27,240 --> 00:31:32,800 So just to kind of flip through the structure of the client here quickly, we have a logcat 413 00:31:32,800 --> 00:31:41,240 device class that wraps basically the logcat command and opens that channel, sets up line-oriented 414 00:31:41,240 --> 00:31:46,620 reader. We have a log monitor, which is kind of the core event loop here, going through 415 00:31:46,620 --> 00:31:53,820 processing that data, matching it against the filter sets, and deciding what to actually 416 00:31:53,820 --> 00:31:59,000 deliver back to the back end. And this is all set up as a service so that it can run in the 417 00:31:59,000 --> 00:32:04,260 background so that we don't have to keep an activity up in order to actually do useful work. 418 00:32:06,300 --> 00:32:13,460 So the server is a Rails server. It basically supplies policy command and control and 419 00:32:13,460 --> 00:32:16,600 processes the device data. So we have per device policies. We have a lot of different 420 00:32:16,620 --> 00:32:22,580 policies, and it's the receiver for stuff that we're sending back to the back end. It 421 00:32:22,580 --> 00:32:27,540 provides an interface to explore the logs that we've collected, and in a couple of cases 422 00:32:27,540 --> 00:32:33,620 does some interesting extraction of particularly interesting bits of data and post-processing 423 00:32:33,620 --> 00:32:33,880 on that. 424 00:32:35,900 --> 00:32:40,340 So what do I mean by policies, and what are we actually doing with this stuff? Well, 425 00:32:40,400 --> 00:32:46,600 we basically decided to kind of do a survey of, you know, what kind of data we're going 426 00:32:46,620 --> 00:32:53,540 to find in the logs. Started with just a few random keywords, things like insert, update, 427 00:32:53,740 --> 00:32:57,540 delete. These are things that you're going to see in SQL statements, and that might be an 428 00:32:57,540 --> 00:33:04,180 interesting target looking for stuff that's going through SQLite. Intent, you know, that's a 429 00:33:04,180 --> 00:33:10,680 core concept in the system. Content, we have content providers that are throwing a lot of data 430 00:33:10,680 --> 00:33:16,600 around. HTTP, anything that's protocol related. And we also put together a couple of 431 00:33:16,600 --> 00:33:22,300 pieces of targeted data. So things like, you know, first name, last name. A particular targeted 432 00:33:22,300 --> 00:33:29,520 made up phone number. Things that, you know, might be pushing through applications. And, you 433 00:33:29,520 --> 00:33:36,160 know, we set up this initial set of expressions and started pushing data through, you know, 434 00:33:36,180 --> 00:33:43,660 channels that are commonly used, different applications. And then started to dig into what we 435 00:33:43,660 --> 00:33:44,620 found on the other side. 436 00:33:46,840 --> 00:33:53,180 So one of the first things that we tripped over with SQL keywords is that actually in 2.2, there's 437 00:33:53,180 --> 00:34:03,140 kind of a new series of log data that appeared in the event log. And the event log, for the most part, 438 00:34:03,260 --> 00:34:07,680 at least in 2.1, doesn't seem to contain anything that, you know, makes a lot of sense when you're 439 00:34:07,680 --> 00:34:11,840 just kind of looking it over. But this data is a little bit more interesting. So there's 440 00:34:11,840 --> 00:34:16,380 apparently a hook in the SQLite driver that actually logs the first 64 characters of a 441 00:34:16,600 --> 00:34:21,640 sampling of queries that are run through that driver. And sample rate is based on query 442 00:34:21,640 --> 00:34:27,460 execution time. So we don't see every single query, but we do see some subset of queries 443 00:34:27,460 --> 00:34:34,720 accessing databases really all over the system. Now, we didn't find any major smoking guns 444 00:34:34,720 --> 00:34:39,660 here, but it's something that developers should really be aware of. Don't, you know, don't 445 00:34:39,660 --> 00:34:44,120 put sensitive data directly into your SQL statements. Parameterize them because they may show up 446 00:34:44,120 --> 00:34:45,320 in places that you didn't intend. 447 00:34:46,940 --> 00:34:51,660 There's a similar hook that does the same thing for content providers. And, you know, 448 00:34:51,700 --> 00:34:56,880 here's an example, not terribly interesting, but some data that actually is disclosed. 449 00:34:57,160 --> 00:35:03,700 For instance, when you're actually doing a phone number lookup in the main contact application. 450 00:35:07,000 --> 00:35:12,760 But, you know, like I said, we have this series of permissions that gate access to 451 00:35:12,760 --> 00:35:16,580 different pieces of system data. And a lot of these things actually happen in the same 452 00:35:16,600 --> 00:35:21,560 way. You actually end up turning up in the system logs. So there's actually a get tasks 453 00:35:21,560 --> 00:35:29,560 permission that allows you to retrieve a list of the most recently accessed activities 454 00:35:29,560 --> 00:35:36,900 in the system. As it turns out, those activities are, when Intensify are to launch those activities, 455 00:35:37,040 --> 00:35:41,140 those are also logged. So if you're just scanning the system logs, you can put that data together 456 00:35:41,140 --> 00:35:46,580 and construct the same thing. There's actually a, there's a dump permission that gets you 457 00:35:46,600 --> 00:35:53,160 access to crash dump data about applications. And, lo and behold, all of that data also 458 00:35:53,160 --> 00:36:01,440 happens to be in the logs. So you can pull it up, too. But there's some more interesting 459 00:36:01,440 --> 00:36:08,320 things. So there's a permission read history bookmarks, which actually gates access to 460 00:36:08,320 --> 00:36:16,580 browser history on the device. And as we can see here, when the browser activity is 461 00:36:16,600 --> 00:36:21,660 launched, you actually get some log data about the URL that was accessed. But furthermore, 462 00:36:21,720 --> 00:36:26,400 there are other applications that are on some devices, and a lot of this stuff is a bit 463 00:36:26,400 --> 00:36:31,820 variable between the different OEM system images, that may actually log quite a bit 464 00:36:31,820 --> 00:36:37,160 more data. So here we can see an example of a bookmark activity, which takes screenshots 465 00:36:37,160 --> 00:36:46,120 of pages that are accessed and keeps them in the browser UI, of a Google search for 466 00:36:46,120 --> 00:36:46,420 something. 467 00:36:48,540 --> 00:36:54,520 And also, by the way, you can see things like authentication token data here, too. And 468 00:36:55,340 --> 00:37:03,200 Kevin and John, also from Lookout, talked about a pretty serious authentication disclosure 469 00:37:03,200 --> 00:37:07,780 vulnerability that was found out there. And this is another channel where the same kind 470 00:37:07,780 --> 00:37:15,100 of thing can happen. So when you're developing back ends for mobile applications, be aware 471 00:37:15,100 --> 00:37:16,480 of the data that you're sending out. 472 00:37:16,600 --> 00:37:18,320 It may end up where you didn't expect it. 473 00:37:19,340 --> 00:37:26,020 Another interesting thing, there's a permission that gates read SMS. And as it turns out, 474 00:37:26,040 --> 00:37:30,840 when the debug levels are turned up, which they are on some system images out there, 475 00:37:31,240 --> 00:37:39,800 then when you send SMS, we see not only the content, but also the recipient logged. 476 00:37:40,380 --> 00:37:46,580 We also found an interesting application out there that had read SMS log in. And it's a 477 00:37:46,580 --> 00:37:47,000 very interesting application. 478 00:37:47,000 --> 00:37:49,240 And it's a very interesting application that has read SMS permissions that was just turning 479 00:37:49,240 --> 00:37:54,060 around and logging the content of all received SMS to the system logs. So here we can pretty 480 00:37:54,060 --> 00:37:59,000 much scrape out both sent and received conversations only with the read logs permission. 481 00:38:01,920 --> 00:38:08,140 There are also components on one system that log the contact data that goes through all 482 00:38:08,140 --> 00:38:16,000 the fields of the activity in the contact manager. And so this actually pulls out these 483 00:38:16,000 --> 00:38:22,120 pieces of data and logs it here, along with the label of the field that was accessing the 484 00:38:22,120 --> 00:38:26,980 data. And so we can reconstruct your contact database for any contact that you access. 485 00:38:30,200 --> 00:38:37,680 And perhaps most interesting to us in some sense, read logs can be an alias for access 486 00:38:37,680 --> 00:38:45,980 course location. So on GSM devices, up until 2.1, and this has been fixed in 2.1, there's 487 00:38:46,000 --> 00:38:50,240 a couple of things that can be fixed in 2.2, by the way. The network location provider would 488 00:38:50,240 --> 00:38:57,780 actually log the LAC and the cell ID of the tower that your device hops to when it connects to a 489 00:38:57,780 --> 00:39:02,040 new tower. That in and of itself doesn't tell us anything interesting, but we'll get to that in 490 00:39:02,040 --> 00:39:13,400 just a second. The CDMA sets actually log the full latitude and longitude of the tower in many 491 00:39:13,400 --> 00:39:13,740 cases. 492 00:39:16,320 --> 00:39:22,240 There's a very prominent clock and weather application that runs on a lot of handsets out 493 00:39:22,240 --> 00:39:27,900 there that also logs the equivalent of course location data to the system logs on a periodic 494 00:39:27,900 --> 00:39:37,300 basis every few minutes. And I mentioned the radio logs before. The radio logs, as it turns 495 00:39:37,300 --> 00:39:45,980 out, also disclose the cell ID and the LAC in addition to the MNC and MCC. So we can actually 496 00:39:46,000 --> 00:39:54,900 pin down operator and location and tower identity. So what do we do with that? Well, we take 497 00:39:54,900 --> 00:40:02,880 that and we can use a database like the Ericsson cell ID database, and we can actually turn 498 00:40:02,880 --> 00:40:08,340 that into a latitude and longitude for the tower that you're talking to, and that gets us 499 00:40:08,340 --> 00:40:15,680 equivalent to course location. But we can actually do better, because as it turns out, the full 500 00:40:16,000 --> 00:40:20,280 fine location data, which should be gated by access fine location, shows up in a lot of places. 501 00:40:20,440 --> 00:40:24,280 That same widget that I was talking about logging course location data actually happens to log 502 00:40:24,280 --> 00:40:33,080 the GPS coordinates as well. The underlying GPS infrastructure on several devices that we looked 503 00:40:33,080 --> 00:40:38,720 at is logging the latitude and longitude out of the GPS location provider, and the underlying 504 00:40:38,720 --> 00:40:45,100 libraries are as well. Now, you know, one thing to point out is that this only happens when you're 505 00:40:45,100 --> 00:40:49,860 actually actively interacting with the GPS. So it's not like you're getting constant, you know, 506 00:40:49,880 --> 00:40:55,500 foot-by-foot movement. But it is enough to put together to tell a pretty good story, like a story 507 00:40:55,500 --> 00:40:59,660 about three guys who started at their office in, you know, south of Market in San Francisco, 508 00:40:59,900 --> 00:41:08,880 walked down to the corner, caught a cab, headed down the 101 to San Francisco International 509 00:41:08,880 --> 00:41:12,720 Airport, where they checked in the terminal and boarded a Virgin flight. 510 00:41:14,820 --> 00:41:23,460 And flew southwest down to Las Vegas. Arriving at McCarran, and you can actually see the, you know, 511 00:41:23,480 --> 00:41:30,860 you can see us touching base here, in the terminal, going out to pick up some bags. Taking a cab 512 00:41:30,860 --> 00:41:38,460 across town to Caesars Palace, where we checked in at the front desk, went up to our room, dropped 513 00:41:38,460 --> 00:41:42,700 our stuff off, went over to, went over to San Francisco Airport, where we checked in at the front desk, 514 00:41:42,720 --> 00:41:46,640 got our speakers registration for Black Hat, went back down to our room to work on slides until 515 00:41:46,640 --> 00:41:54,000 4 o'clock in the morning. Until we left a few days later and took another cab across town to the 516 00:41:54,000 --> 00:42:01,420 Riviera to check in for DEFCON 18. So now that I've talked a little bit about this, I'm going to 517 00:42:01,420 --> 00:42:05,660 turn it over to Anthony, and he's going to talk a little bit about the ultimate permission. 518 00:42:13,980 --> 00:42:18,700 Thanks, Tim. So we're going to rush through this a little faster as we're running out of time here. 519 00:42:19,860 --> 00:42:25,660 So essentially we know that Android phones aren't necessarily this, like, perfect utopia of, like, 520 00:42:25,660 --> 00:42:30,340 open source, like, hardware that we can all do whatever we want with it. A lot of phones are shipping 521 00:42:30,340 --> 00:42:36,260 locked right now. And a lot of people are forming entire communities around this idea of being able to 522 00:42:36,260 --> 00:42:41,380 root their phones and be able to do a lot of modification. I'm just curious, how many people in this room 523 00:42:41,380 --> 00:42:46,740 have an Android phone? Okay. How many people in this room with an Android phone have rooted it? 524 00:42:48,180 --> 00:42:55,500 Okay. How many people that have rooted a phone have not issued an update or a patch because they didn't 525 00:42:55,500 --> 00:43:00,220 want to lose that method of being able to root their phone? Okay. That's good. That's good. 526 00:43:03,560 --> 00:43:10,340 So what are some of the ways that we're able to get root on these phones? Some of the methods that 527 00:43:10,340 --> 00:43:11,360 people are using are... 528 00:43:11,380 --> 00:43:17,700 So looking at older Linux kernel bugs, there have been a lot in the past few years. So basically you can 529 00:43:17,700 --> 00:43:23,860 look up on lists like Full Disclosure and see what kind of stuff is available. This is a list of all the 530 00:43:23,860 --> 00:43:31,020 various kernel releases for each major version of Android, with 3.0 coming out in the future, which should 531 00:43:31,020 --> 00:43:40,160 be using 2633 or 2644. Also, you can take a look at older unpatched libraries and binaries that are 532 00:43:40,160 --> 00:43:46,060 shipping on the system. I know one of the first Android vulnerabilities that were found were back when it 533 00:43:46,060 --> 00:43:51,440 was still just an SDK before there was actually any hardware. It was in some of the imaging libraries. 534 00:43:51,780 --> 00:43:59,000 It was an overflow that Alfredo Ortega on the core team found. But pretty much a lot of the ways that we've 535 00:43:59,000 --> 00:44:06,940 been looking for vulnerabilities on Linux apply to Android since it's running on Linux. So let's take a look at 536 00:44:06,940 --> 00:44:08,260 this specific case study. 537 00:44:09,260 --> 00:44:18,940 This is a vulnerability that came out recently that was very similar to the lib-udev-vuln CVE-2009-1185 that was 538 00:44:18,940 --> 00:44:27,820 discovered by Sebastian Kramer. I would like to point out that we did incorrectly state at Black Hat that this 539 00:44:27,820 --> 00:44:36,340 vulnerability was in fact CVE-2009-1185, but Android itself does not use lib-udev. But they, in their implementation 540 00:44:36,340 --> 00:44:46,500 of handling uvents, proceeded to recreate the exact same bug. And Sebastian took his exploit that he wrote 541 00:44:46,500 --> 00:44:53,720 originally for that and was able to port that to run on Android. Upon finding out when the exploit was published, 542 00:44:53,960 --> 00:45:00,680 Android had that patched within four days, which was really good to see. The exploit itself is just a failed check 543 00:45:00,680 --> 00:45:05,420 of the netlink messages and where they came from. Did they come from the kernel? 544 00:45:06,340 --> 00:45:15,080 Or did they come from user space? So we took this and we patched it. Or not patched, I'm sorry. We packaged this 545 00:45:15,080 --> 00:45:21,640 exploit back into JNI code to run within an APK so that we could test this on a lot of different phones. 546 00:45:22,800 --> 00:45:29,320 So who's vulnerable to this? We ran this APK that would root a phone and added a connect back shell to it. 547 00:45:29,400 --> 00:45:36,320 It turns out that currently every flagship phone of every major carrier in the U.S. is vulnerable to this. 548 00:45:36,340 --> 00:45:43,520 It's being rooted by this right now. I would like to point out that it is fixed in 2.2. Any devices that we tried 549 00:45:43,520 --> 00:45:52,460 with that on it didn't work, which is good. And as we said, Android has patched this within days of finding out 550 00:45:52,460 --> 00:46:06,320 about it. Oops. So we feel that this is kind of creating a problem in the community. People are trying to root 551 00:46:06,340 --> 00:46:12,540 their phones so that they can do all this modification. And they're kind of looking at rooting this as a vehicle 552 00:46:12,540 --> 00:46:20,420 for that and kind of ignoring the security aspect of this that while you have this small subset of people that want 553 00:46:20,420 --> 00:46:26,680 to do this to their phones, you have this larger population that have Android phones that have no interest in this. 554 00:46:26,780 --> 00:46:31,860 And they're sitting around with insecure phones because people in these communities don't want to divulge details 555 00:46:31,860 --> 00:46:36,320 on their root processes so that OEMs carriers can't get these things rooted. 556 00:46:36,340 --> 00:46:45,040 So yeah, as we talked about, we know why people are modifying their phones or rooting their phones for modification. 557 00:46:45,900 --> 00:46:54,180 Also, another reason people are doing this is because the patching process is slow. Android is coming out with releases 558 00:46:54,180 --> 00:47:02,680 so fast that a lot of these OEMs and carriers that are doing a lot of heavy modification to the system, they can't 559 00:47:02,680 --> 00:47:06,320 necessarily port all those changes to these new releases and make sure that they're going to work. There's a lot of tests 560 00:47:06,340 --> 00:47:11,100 and testing that has to go involved. Also, people are just doing this for an addition of features they don't necessarily 561 00:47:11,100 --> 00:47:21,920 want to pay for. So what can we do about this? As a user, we've had great demonstration that using just one single permission 562 00:47:21,920 --> 00:47:29,300 to read logs, we would be able to steal most of the private data on a phone and be able to ship that off to a server 563 00:47:29,300 --> 00:47:36,280 and be able to communicate with that. So don't assume that a lack of permissions means that it can't actually do anything 564 00:47:36,340 --> 00:47:46,460 Keep your phone patched when you have those releases. Also, as a developer, the users are trusting you with a lot of this 565 00:47:46,460 --> 00:47:53,200 private data. So if you're asking for these permissions to read their SMS because you want to provide some third-party SMS 566 00:47:53,200 --> 00:48:00,400 app, don't log their SMS for everyone else on the system to see. Just be paranoid about the kind of things that you're logging. 567 00:48:00,600 --> 00:48:06,320 Also, make use of the permissions that you can enforce on your application. 568 00:48:08,600 --> 00:48:15,840 Don't send intents with private data in them because anyone else can set up a receiver and be able to read that data. 569 00:48:17,740 --> 00:48:23,180 OEMs, you should be doing a lot of the same things that developers are doing as far as being careful about the things that you're logging 570 00:48:23,180 --> 00:48:31,800 and your changes to the system. If you guys aren't being a good example for everyone, why should they have to worry about 571 00:48:31,800 --> 00:48:34,340 what they're logging if you guys are already doing it? 572 00:48:35,320 --> 00:48:36,320 Also, keep in mind that OEMs don't have to worry about what they're logging if you're already doing it. 573 00:48:36,340 --> 00:48:42,020 So having libraries and kernels and all that kind of stuff patched up to date would be a really great thing to see. 574 00:48:42,800 --> 00:48:48,900 So with that said, thank you everyone for coming. We'll be available in the Track 1 Q&A room for questions.