All right. So, hi everybody. I'm glad you guys are all here. So, I'm Craig Young. I'm a security researcher with Tripwire Vert. I write vulnerability checks for our IP360 vulnerability scanner. And I also do a lot of research on different vulnerabilities. Lately, I've been looking at a lot of different Android applications, and I've been noticing more and more that there's a lot of Android applications that don't implement SSL properly. And with the push that we've been seeing with more and more apps that are really having real-world integration, you have more and more situations where broken SSL doesn't just jeopardize privacy, but it's actually jeopardizing people's safety. So, for example, if you have a taxi application, you have the threat of kidnapping. If you have a smart car application, you have the threat of somebody being able to access or track your car. And, of course, the future, we're seeing more and more medical devices and plannable devices. There are all sorts of nasty situations which could arise. But to introduce the scenario that I'm going to talk about first, I have a little video clip, a dramatic video, a little play. Apparently, that's not the way to play it. Prevalence programs has individuals genuinely concerned with the privacy of their communications and personal data. The Snowden effect has brought SSL concerns and privacy issues to the forefront of conversations. What most of us don't realize is that there are real-world consequences to personal safety when cryptography is not implemented properly. Hackers can use a simple technique to abduct, stalk, spy, and murder, even physically harm unsuspecting victims. To exemplify, an attacker is at a bar hanging out with their hacking gear, a pineapple Wi-Fi, intercepting Wi-Fi connections. The attacker spots a potential victim who is using the Uber app to get a text. The attacker uses their smartphone to start the attack. The victim now receives a phone alert that an Uber car is on its way. The Uber driver is actually an accomplice to the attacker. The victim's Uber app shows the car driving up. The victim gets into the fake cabin and is now the attacker's captive. Security vulnerabilities in applications not only jeopardize data, but have devastating personal safety consequences. So, with that introduction, I'm sure a lot of people probably know what the vulnerability here is, but I'm going to explain it anyway, because that's what I'm talking to you guys about. So, basically, Uber locked the door, they used SSL, but they didn't quite implement it properly. They did not implement anything for checking the client's or the server's certificate, so the client Android application has no way of informing a user if you're not actually talking to the real Uber service. So, this is a real big problem, because anybody can generate a self-signed certificate, man-in-the-middle connection, start manipulating traffic. So, before I get into how I manipulate the Uber traffic, let's take a look at how you can test for this kind of issue. So, the easiest way that I've found to try and identify SSL certificate validation failures is by setting up a simple VPN. So, I use DigitalOcean as a VPS provider. I set up PPTP on there. I use my phone to connect into that. And then using Mox and Marlin Spikes SSL sniff, I found it was very easy to use IP tables, redirect traffic into there. And you can see very easily, if the application under test is not implementing SSL properly, you'll start getting requests like that, as opposed to getting an error on your device. Now, there's lots of applications that have this problem. When I started using this test methodology, I very quickly saw scary stuff coming off my phone. Like, for example, Google credentials in plain text. Not from an actual Google-made app, but from a third-party application that has millions of downloads and still has not fixed it, which is why I'm not naming them. I also saw that ISP credentials were coming out when using different media streaming applications. There's financial data that gets leaked. And we also, of course, there are libraries that get reused in a lot of different Android projects that do error reporting. And they will connect over SSL, but they won't do anything to validate the server, because typically your server might have a self-signed certificate in this situation. The result of this is that if somebody is man-in-the-middle-of-your-connection, they're able to see a lot of detailed information, like what intents you have registered on the device, sometimes what applications are actively running. There's a variety of data in there that could be used to further attacks, like JavaScript bridge attacks against Android. But back to this particular application. Of course, Android provides built-in functionality for doing SSL. There's no problems with the SDK here, but there are a lot of applications that are broken. And what I was finding is that it tends to be when you have an application that's not using a WebView, but instead making direct JSON requests, for example, the application developers very frequently implement kind of a naive trust model, which I'll get into in a minute. But the reason that this all happens, to understand this, you have to understand a little bit about the Android architecture. So Android is running on top of Linux. It's using a Dalvik VM. This is Google's own virtual machine. Now there's another one, ART. And applications are getting distributed essentially in a zip file. This zip file is renamed an APK. And you've got some Dalvik executable files, decks in there, all sorts of resources. And it's very, very easy to reverse. There's tools like Ddexer, APKtool, which uses backsmolly. And you can use these tools to start analyzing what it is that went wrong within an application, find out why the SSL is broken. So the tool that I like to use is APKtool. I like it because it's preloaded on Kali, very straightforward to use. It gives you a lot of flexibility. So all you have to do is put your APK file that you want to analyze into the user-share APKtool directory, on Kali Linux anyway. Run APKtoold, and you can disassemble that application. When you do that, you're going to get some data like this. This is not all-inclusive, but some of the highlights. You've got the manifest file, which anybody who's developed an Android application will know what this is. This has all of your permissions, information regarding certs for sharing data between applications. There's some metadata created by the application to help it rebuild itself. You've also got native libraries on there, which you could perform static analysis and start finding memory corruption vulnerabilities and things like that. You've also got your resources directory, which is full of strings, layouts, things like that. But the most interesting part is the smally code. Smally is... I believe it's Icelandic for assembly or something along those lines, because Dalvik is an Icelandic town. But anyway, so once you have this smally output, you can start searching through it. And what you're searching for is the TrustManager implementation. The TrustManager, you can see up here, it's javax.net.ssl.x509.trustmanager. You can do an fgrep through your smally directory. And you want to find any place where there's a definition for an implementation of this x509.trustmanager. And then you want to jump down to the checkServerTrusted. This checkServerTrusted function, this is what's supposed to actually do the work of figuring out whether or not the server that you're talking to has a properly signed certificate and whether it should be trusted. So you could have in here certificate pinning logic or trust logic for figuring out which CAs you trust. But if you look at this disassembly, there's not much to it here. You've got a declaration that we could throw an exception. That's the exception that you would have to throw if you wanted to tell the client that this is a bad connection to not be trusted. But all they're doing here is a return void. So there's absolutely no certificate that would not pass this validation check. So you could actually roll your own patch. When you find an application like this, you can go through these steps to find the x509.trustmanager. You can then take that checkServerTrusted function and put in code that actually does something. We'll talk a little bit about the things that you can do towards the end of this talk. But then use the APK tool. It will rebuild up your package to an APK file. You just need to sign it then, and you can load it onto your Android device. And even if an application developer is not fixing their application and keeping an SSL vulnerability in there, you could, in theory, continue to use the app without risking man-in-the-middle. So for the sake of comparison, this is also from the Uber app. By the way, I don't know if this was clear, but that first code sample, that was from the Uber app. That was the root of this problem. This is also from the Uber app, but this is part of the PayPal SDK. And if you see, this is just the beginning of the checkServerTrusted function, because it actually does stuff. And PayPal is smart enough to know that they don't want your PayPal credentials winding up on anybody who has access to your connection. So under normal operations, there's really no impact from not validating the SSL certificates. You have confidentiality, you have integrity, you have authenticity of the server you're going to, in theory. But really, this all gets thrown out the window if there is a man-in-the-middle, because you don't have any logic here checking whether the server has a trusted cert. So even that SSL is preventing that somebody just passively eavesdropping would be able to listen and see what your password is, or whatever other data is going across the stream, you still have the possibility of man-in-the-middle attacks. This is particularly a risk with smartphones and tablets, because we have this wonderful thing, 802.11 Wi-Fi, which you'll hear all day long in here has all sorts of flaws, and they make it quite easy to launch a man-in-the-middle attack. So, for example, most people, when they're using their smartphone, for example, you might go to a hotel, add the Marriott Wi-Fi hotspot, and even after you've left the Marriott, you're not deleting that, and so your phone is always going to be broadcasting looking for this open network. Also, you have the situation that people have tiered data plans, so they like to go and if they see a free Wi-Fi hotspot, they're going to use it, and that gives somebody else access to their data stream. And, of course, as I was saying, the 802.11 protocol has some shortcomings. Very briefly, there's issues, for example, the fact that your devices are generally going to send out probe requests, saying all of the SSIDs that they're looking for. Your deauthentication frames are never encrypted, so that means that any client that's connected to any wireless network, 802.11 that is, regardless of the security levels that are implemented, you can send a completely plain text message and boot them off of that network, and then it becomes a race condition. If you can get a network that they're going to connect to up first before they see the network they really want to connect to, you've got them. And clients really don't have any mechanisms for validating the access point. There have been some really great ideas in this field of using certificates to improve the situation, but unfortunately there has not been really the hardware vendor cooperation in this realm to make these kinds of changes happen. There are some complexity issues when you start talking about the average consumer trying to use this stuff. So, these flaws, of course, can get exploited using Pineapple Wi-Fi, which is available through Hackshop, and it's a nice little portable pen test tool. I won't talk too much about that since I'm sure all of you guys have seen that in this room, but you can easily plug in a 4G modem stick to it so you have out-of-band access to it. You have battery pack with it so you can travel with it. You can take it into a bar, wait for somebody using the Uber app, and then start launching your attack as I showed in that video. And also you have the ability to change some of the configuration settings on the fly through hardware dip switches on the Mark 5 model. But basically, the way that the interception is going to work in this scenario, the Pineapple Wi-Fi uses a tool called Karma, also referred to as Yasager, I suppose, but this process is circular. You're just listening for the probe request that you see. When there is a probe request sent, you take whatever SSID it was looking for, and you start broadcasting that SSID and wait for unassociated clients to connect to you. A slightly more sophisticated approach, if your target happens to already be connected to a wireless network, you can use the flaw in the 802.11 protocol, or limitation I should say, that you can send a deauth frame. And this deauth frame is going to tell the client, or it's going to make the client think that the AP is telling it, you can't use this network anymore, and then you listen to the probe request the device sends out, and rinse, repeat, you're back to where you were before. So now, in order to carry out this attack, we know that SSL is broken here, but that's not enough to kidnap somebody with an Uber taxi. So there were a couple of approaches that I thought about taking for how to go through this. Primarily I was looking at whether it would be better to completely impersonate the Uber backend server, since you can present any certificate and the phone will think that it is uber.com, or you can just tamper the responses. And clearly there are pros and cons for each of these. If you're completely impersonating the backend, like meaning reconstructing the server and making it behave the way the real Uber server would, you're going to have pretty good reliability with this approach, but it's going to take a while to develop. It's going to take longer than I felt like spending for this presentation when I'm not really planning on kidnapping anybody. So I went with the approach of response tampering. This is very quick to implement, but of course it could be a little more fragile, because backend changes could cause this to break. But the choice that I made, as I said, is to do the tampering method. With the tampering methods, you've got a couple of tools that are already available which you could use. Mallory is a great example. It was released by DefCon or BlackHat a few years back from the Intrepidus group. It's essentially a transparent TCP proxy. It has great support for SSL. It will do automatic regex replacements. So I've used it in the past, for example, to strip out gzip encoding from requests and change a user agent string from a flash player to do some things, let's just say. But it's also a little bit clunky for this kind of task, because I want it to run on the pineapple Wi-Fi. It's not really that beefy of a machine. And Mallory, you typically... it's a great tool for identifying vulnerabilities and working on pentest engagement, but it's not really so flexible. You've got a GUI that you're going through. I'm sure that you could script it out, but it's also not so context-aware in the way that we need to be for this approach. So another option out there, there's MITM dump, man-in-the-middle dump. This is strictly an HTTPS proxy. It has hooks in there so that you can do straight regex replacements. It's all command-driven. I believe there's even an infusion that you can get this pre-built for the pineapple Wi-Fi. Don't quote me on that, but I kind of didn't want to go with the off-the-shelf methodology. These tools, they're great for quick analysis, as I said, but you need... if you want to be able to pull off this kind of attack, you need to be aware of the application that you're attacking, and you have to be conscientious of the state that the application is in. You can't just do blind replacements of data and have something that's going to be meaningful output for the user in the end. You also have, with these off-the-shelf tools, perhaps some issues with dependencies that they're going to require on, and you're not necessarily going to be able to port it from one place to another. So I made a little Python script. It didn't take long to write, and it gave me a lot more flexibility because there's no license restrictions on it, other than the Python license restrictions, because I wrote it. It allows me to monitor the context of the application and do things statefully in an intelligent manner so that I can control the coordinates that are going in a meaningful way if I wanted to. And I made it as a single Py file that has all standard imports. So it runs right out of the box on the Pineapple Wi-Fi, or basically anything else that has Python on it. So this is kind of a block diagram of how this works. We have a listening socket. The listening socket wraps TCP connection with an SSL handler. We're using our self-assigned certificate. It spawns off a sub-process, which is doing our receive handling. And what I'm doing here, I used IP tables to redirect the traffic into the UberProxy Py file, or process. So we don't have knowledge of what the hostname you're trying to connect to is. So you have to look at the HTTP headers, and I use that information then with urllib to go out and fetch the resource. And then I can look at the response and decide... or actually, first I look at the request and decide, is this a request that I'm going to want to either forge a response to, tamper the response, or just send it back as-is? So we've got... the DS handler is the downstream handler. US handler, of course, is the upstream handler. And the DS handler is where the magic really works. But the way that the Uber app actually works, you are polling constantly for whatever the nearest vehicles are. These are JSON requests that indicate where you intend to be picked up. And you get back responses which are lists of coordinates of paths that the Uber cars have taken. So essentially it will give you a list of timestamp and latitude and longitude, timestamp, latitude, and longitude, so that the app is able to draw out on the screen how the cars are moving. So Python has great support for interpreting JSON. So I used the JSON module here to interpret these responses and manipulate them. I didn't want to inadvertently start getting Uber drivers coming out to my house while I was working on this, so I didn't actually go through the whole process of man-in-the-middling the purchase process. I also wanted to avoid any PCI complications. So I decided to do a demo to show that you can control the path of the vehicles simply by making it so that the vehicles would all converge upon the location where the request is being made to pick up the taxi. And of course, if you wanted to, or if somebody wanted to actually use this in a real-world environment, you would want to go through Google Maps or some other mapping service, take the coordinate where the victim is, and actually mark it so that you're having the taxis drive on the road. If you'll see here, the demo that I made of this video will work. You can see we're going to... it's a little bit fuzzy, but we're going to make the taxis drive out to Alcatraz over the water. They probably don't float like that in real life, but... Then, if you look on... I'm going to try and pull up the terminal. Yep, so this is my script running. This is a Nexus 7 with the Uber app installed on it. I'm just going to launch the Uber app, and you can see right away we start getting these requests out. You really can't read that so well. Let's turn up the font a little bit on that. I don't know if I can adjust the resolution without messing everything up. Is that a little better? Yeah, so you can see there's the nearest cab requests, and if we wait... Well, so right here, it's having a little bit of trouble determining my location inside the building, so we're not actually getting to the point where we can see the cab locations, but if we stepped outside and we were in a city where Uber actually operates, you would start seeing lots of geolocations for the Uber taxis in here. So back over to the slide deck. Those are some nice flowers, but that's not what I wanted to show you. So I reported this issue back in March 2014. I also reported similar issues to six or seven other vendors. Uber was very, very excellent about responding. They were very happy to hear about this from me rather than hearing about this from the Federal Trade Commission or whoever would be investigating that, and by the time May came around, they had a complete revamp of the app, which does not have this problem in it. So if you use Uber, you want to make sure your app is up to date. I'm not sure. It might have asked for new permissions, so you could be waiting if you don't explicitly tell it to update. Anyway, other apps that I looked at, since the manufacturers have not really been responding so well, I'm not comfortable with disclosing the particulars of the brands. I hope you all understand why. But a lot of cars these days, this is one of the things that I was looking at, they all have telematic systems which connect over typically CDMA networks, and you have smartphone apps that go along with them which allow you to do things like remote start your car, unlock the doors, find your car on a map, send directions to it. And what I found was with my car in particular, and none of you know what kind of car I have, right? So that's good. But you're able to, if you just intercept one connection from this app, you can start unlocking the doors, you can find the car on a map, and if you wanted to, you could use this to stalk somebody, you could use this to go watch their movement, wait until they park, say they're going into a shopping mall, you walk up, unlock the doors, you could plant a listening device if you're polite but wanting to be kind of intrusive, or you could plant a bomb if you wanted to. You could also follow somebody around from a distance without being exposed. So, if you wanted to exploit this, it's actually very, very simple, because you really don't even need to write any code yourself. Moxie's SSL sniff is more than enough to get the credentials. Once you have the credentials, you can forge all of the requests that you need for this. So, for link stars, what I'm calling it, obviously not the real name, I alerted them back in February, I alerted the car manufacturer in February, that is, I also alerted Google Play in March 2014 of this and several other applications in the same and other disciplines, and as of July, I have not gotten any responses, so it would seem that app developers really don't take this situation seriously. And there are other areas of concern, and there are going to continue to be more and more problems. I mean, we're having people with defibrillators implanted into them that have pacemakers that feed data into their cell phone and send it out to a doctor, allowing the doctor to make a response and send a charge to somebody's heart. If you could manipulate that data stream and make the doctor think that somebody's just had a cardiac event, you're talking about potential murder. So, also, I don't know how many people have been following BlackHat or were at BlackHat, but there were some references about various home security systems, and these things have a lot of the same problems, that they're either using encryption, but not using it properly so that you can man-in-the-middle it, or they're just using proprietary RF protocols that are plain text, and I'm sorry, I forget the name of the researcher, but there were two different researchers that have been showing recently that you could very easily use this to cause a flood of false positives or just disable or burglar alarms. These problems are beyond just 802.11 and smartphone apps. The mass availability of software-defined radio opens up the door to all sorts of different RF protocols being subject to attacks due to poorly implemented or not implemented encryption. So, how can you actually stay safe? If you're talking about the Wi-Fi aspect of things, you want to turn off Wi-Fi when you're not using it. You probably want to keep Wi-Fi off most of the time that you're at DEF CON, for example. You shouldn't be connecting to... or, I'm sorry, you only want to connect to SSIDs that are broadcasting their names, in my opinion. There are some issues with connecting to non-broadcast SSIDs, which can make it easier for somebody to man-in-the-middle your connection. It's kind of ongoing research, but I'm just going to say, not broadcasting your SSID, it doesn't really help you from a security perspective, and it can actually hurt you from what I've been seeing. If you're going to use open Wi-Fi, all right, but use it and then remove the profile from your device. You don't want to leave any profiles on your devices that are for open Wi-Fi. And if you're using an application that maybe has some kind of sensitive data or might have some ramifications in the real world, you can use that testing strategy that we went over in the beginning of setting up a PPTP VPN and using a cell sniff to find out very quickly whether or not applications are vulnerable to this type of attack. So there are also some things that you can do to kind of identify if somebody is performing these types of attacks in your vicinity. For example, if you're in this room right now and you were to take out your phone and add an SSID of ABCDEFG, I would guarantee you that in a couple seconds you would see that SSID being broadcast. That's a pretty good indicator that somebody is doing something hokey around you and you might not want to use your Wi-Fi at that point. You also have a big red alert if you, say, go into a Wi-Fi signal analyzer and you see all of a sudden that there's a hundred or even six or seven SSIDs that all have really high signal strength. That's maybe not legit. There are other tricks that you can use. There are more subtle attacks that somebody might use. They might not use Karma, for example. They might just spoof a specific SSID, in which case trick number one and trick number two are not going to do anything for you. But if somebody is redirecting your traffic, chances are, or there's a good chance that they're going to be using DNS to do this. So there are systems out there that you can use and websites that you can use over SSL to compare DNS results that you get from your local connection to what the rest of the world thinks the DNS results are. And if you start getting a lot of conflicts there, then yeah, there's a good chance you've been DNS hijacked. So I want to kind of talk a little bit about how to make these things better also. First of all, there's different aspects of SSL that you need to be concerned about. It's not just checking the server certificate, but it's also you need to make sure that you have a device that has decent entropy, because your SSL is all based on random numbers in your client hello and your server hello. If those random numbers can be predicted, like DULI, CB, DRG, that's a problem for you. Perfect forward secrecy also helps out a bit. This is a good idea. The idea here is that every time you're making a connection, you're actually, the server is taking a new certificate that it's generating, it's signing it with its trusted certificate. And that way, if that trusted certificate gets compromised at some point in the future, all of the other connections, maybe data that's been recorded, you're not going to be able to get at that, or the attacker is not going to be able to get at that, unless they brute force and crack every single one of the dynamic or the ephemeral certificates that's been generated. You also, of course, want to make sure that you're supporting TLS 1.2 with strong ciphers. So, like, you want to use the Galois counter mode and AES, typically. And you don't want to do self-signing in production. But, of course, this isn't completely avoidable, we'll talk about that in a second. But, one good idea, certificate pinning. Can anybody tell me what certificate pinning is? What's certificate pinning? Yeah, so, exactly. So, basically, rather than just looking that you've got a trusted certificate, you're looking to make sure that you've got a certificate that you're expecting. So, for example, the Gmail app. Even if you add a new trusted CA onto your Android device, you're not going to be able to man in the middle of the Gmail app unless you do some tricks on there to change around what certs it's looking for, because it has a pinned cert. So, I mentioned don't use self-signed certificates in production. But, of course, this is unavoidable. Over there you'll see a table full of wireless routers. All of those devices have self-signed certificates, if they have SSL at all. And this isn't going to change anytime soon. Getting a certificate signed costs money. It's not scalable to be able to have all manner of consumer products that are actually having signed certificates from a trusted authority. So, Internet of Things is going to have some serious problems if people don't start thinking about these issues. One of the approaches that I like is the trust-first approach to this. So, the first time you connect to a device, you see the SSL certificate that it gives you, you record that SSL certificate. If you ever see a different certificate, that should set off an alarm saying, user, did you change your device? Did you reset it? Otherwise, we think somebody is mucking with your connection. And this is kind of like the way Firefox works, if you want to go to a site that has a self-signed cert. But I haven't really seen this happening so much with mobile applications. I don't understand why. Maybe if some of you are smartphone developers, you can start integrating that into your apps. So, what we've talked about here, applications, Android applications specifically that are doing JSON requests, or downloading resources like a database, or doing diagnostic reports, it's really important that you have proper SSL certificate validation in all of these places. When you don't, like for example, if you're downloading a database that has contacts in it, doing that over HTTP, maybe somebody replaces your database with some cross-site scripting data in there to start accessing other stuff that's going to get loaded through a web view in your app. We talked a little bit about how to test for these issues, so hopefully this is easy to understand. If not, you can go to the Tripwire blog, and I actually have a blog post out there that gives a step-by-step process of how to set this up so that you can do end-to-end testing of Android applications for their SSL shortness, I guess we'll call it. And I just want to reiterate that people are way too trusting of Wi-Fi. You don't want to use open Wi-Fi networks, and if you don't have to, you know, anyway. Some of the tools that I talked about are listed up here, along with my contact information. Does anybody have any questions? All right, I guess that means that I explained everything very clearly. Glad to hear it. And I thank you guys all for your time, and I encourage you to check us out on Twitter.