So I'm here to talk about active HTTPS cookie hijacking. First of all, who am I? What do I do? I'm a volunteer Tor developer. I work on the latest Tor button release for secure Tor toggling and isolation of cookies and all that stuff, and a set of Tor scanners and libraries for monitoring Tor performance and scanning. There's a node called Torflow. General privacy advocate, censorship opponent. My day job is being a forward and reverse engineer for a network acceleration company called Riverbed. We make awesome network acceleration gear. I'm also a flexitarian, which means it's sort of like a step below vegetarian. Absolutely no meat unless it's free range or particularly delicious. Now the problem is I've had a lot more success converting vegetarians to flexitarianism than normals to flexitarianism. So I don't know if I'm not positive yet. But maybe. Maybe someday. I'm also a random hacker. I do all sorts of random stuff as the mood strikes me. I've got an IRC bot that passed the Turing test. It was quoted as a human in a magazine, a human consultant. So that was pretty good. So what am I doing? Why am I doing this? So in about two weeks, I'll be releasing code that can steal insecure HTTPS cookies. I actually announced this to BugTrack a year ago and notified Google. And there's been almost no action on it from pretty much any website for the past year. And the vector can be done from more than just local Wi-Fi networks. You can leverage Dan Kaminski's DNS hijacking attack and a whole bunch of other vectors as well, which we'll get into later. And a whole bunch of sites are vulnerable. They think that maybe they do development via HTTP and they slap HTTPS on later. And so they just don't set the bits on the cookies for convenience. So the response has been pretty good. The response is to try and raise awareness to release a fully automated tool that shows just how dangerous this is, not setting the secure bit on these cookies. And it's a very easy fix, just basically setting a property on a cookie to cause it not to be transmitted. So let's go back to the basics then. Why does this work? Or what is a cookie? How does it work? So obviously, they're used for authentication and tracking in your web browser. They're basically a variable that gets set by a website. There are a few cases. There are a few key properties that they have and that govern when they're transmitted. And that is they have a domain, a path, which they're only transmitted for sites that match the domain and path. And they have an expiration time. And then the secure bit, the SSL bit, which is what's of interest here. So last year, my announcement was sort of overshadowed by Robert Graham's hijacking attack announcement at DEF CON. Or Black Hat, I'm sorry. What was that? Basically, it was a glorified sniffer that just passively captured cookies to non-SSL websites that people were visiting on the local network. And he had a janky proxy-based interface for that, for doing that cookie setting and interception. And he did try to save path info, but it was a little bit too specific in some cases, and that could lead to issues. But he did manage to raise the alarm pretty good for at least that issue, the lack of SSL and how dangerous that is. So I'm happy with that. I'm hoping to try and do the same here and encourage sites to actually set this property. So let's take that attack a step further. If you want to grab arbitrary cookies from somebody without them actually visiting a site, basically the scenario is a user logs into a site that's not secure. Sometime in the past, they set the Remember Me flag, and then the local attacker can then inject arbitrary cookies. And they inject them into a page that's not secure. It's called an auxiliary content element, something that's an arbitrary content element, like images or iframes or what have you, that will cause the browser to transmit any cookies that it has for that domain. So in this case, injecting an image source for Yahoo into a page will cause the browser, of course, to transmit the cookies for Yahoo. It's sort of the common name for this is cross-site request forgery, but we don't really care about performing any particular action on the server in this case. We just want to cause the client to transmit its cookies, its authentication tokens. We don't care if the request succeeds or not at the server. It doesn't really matter if the actual URL is valid or an image or anything. You can then save these cookies and write them to a Firefox-compatible cookies.txt file. How does this HTTPS cookie hijacking thing work? It's very similar. Yesterday, instead of logging into the insecure service, they log into the secure service, HTTPSmail.google.com, for example. Then, with that cookie set to be persistent, later they log into www.cnn.com, for example, on an insecure network with a malicious attacker. We'll get into exactly what that is. It turns out basically every network is a malicious network as far as this attack is concerned. The attacker then can inject the same image source, but this time without the HTTPS, just HTTP. Because the SSL-only property is not set on these cookies, they just get transmitted, and then the attacker can observe and then record them. Then you can write them out to a Firefox-compatible cookies.txt and load that into your browser and impersonate that user. If you're on the local network, some sites will have, only allow me to connect from this IP address. If you're on the local network, you can spoof that IP address, borrow their MAC, impersonate them, write on their connection. Or, if it's behind you, you can do that. The NAT, the IP is the same, so you're still able to impersonate them fully. The key point here is the user doesn't even have to be using whatever service that they log into via the hostile network. How did we go all the way up there? As I said before, this is not just a problem with open wireless networks. There's tons of vectors for this. You can do, of course, the ARP poisoning attack, ARP spoofing attack. You can do the DHCP server exhaustion, where you request all the leases from a DHCP server so that it runs out, stops answering, and then you start answering for it. So then you say, oh, the gateway's over here, route everything through me, please. And then you can do this attack. Dan Kaminski's DNS hijacking attack. I believe he said that somewhere between 30 to 40% of the DNS servers out there still have a DNS hijacking attack. I'm not sure if that's true. And then you can do a fix source port so that his attack can still work. And that was the estimate of a few days ago. He may have been scanning continuously more. I've heard higher estimates from other people, significantly higher. So the other thing is we saw a couple of cable modem talks yesterday, where they were able to read the down... Sniff the downstream traffic and inject traffic into there. This attack really needs upstream to be able to capture the client, the cookies sent by the client. So the attacker sort of needs a custom cable modem that they've hacked to be able to read, capture the upstream frequencies as well. So at this point, without a hardware hack, it might not be possible. But still, a sophisticated attacker can potentially hack their modem to do this. And there is DOCSIS encryption, but it's weak. It's 56-bit. So I think that can be cracked, if it's even enabled. So how is this attack executed without sophistication? There's this utility error. It's called AirPoon, which I pronounce Poon because there's no O in Poon. And I figure Poon is just a little bit more dirty or dirty enough to be a little shocking. So it's pretty quality. But probably nobody's going to adopt that anyways. So you basically can use this tool and could inject these elements for your target domain and then use Wireshark as a script to grab those cookies and then write them out manually. Wireshark has a scriptable interface. It used to be called tetherroot.com. It's probably called T-Wireshark now, basically shell scripting type stuff. So what is this utility that I'm going to be releasing? It's a fully automated PyLoricon tool. It basically caches DNS responses. So you see a DNS request for a particular domain. You cache that name. And then you listen for SSL connections to port 443 for an IP. You look up in your cache DNS table, what was the domain for that? And you say, oh. Here is the domain for this IP. That's a target. I want to inject that into that user later. So you store it into a queue for injection. And the next time that target IP connects to any HTTP website, CNN or whatever, then you inject this DNS name into that stream and cause them to transmit their cookies. So it can be fully automated. And then the tool will write any resulting cookies out to a client. And then it will send you a cookies.txt file that you can use in Firefox 2. I haven't done Firefox 3 support yet. It's SQLite. There are Python libraries for that. I just haven't gotten to it yet. OK. So there is a little bit of configuration now. It's not 100% automatable. But it is close. So you need the path for it to be able to entice sites to transmit if they have a path restriction, like mail.google.com has the path restriction set. But that's not a problem. I mean, that's the same for every site. So you can just have a table of common sites. sites. You might also want to steal arbitrary cookies for non-SSL sites as well. You can provide a target list for that, so I want to always grab Facebook cookies or whatever in addition to any other injection. So Cookie Monster's been doing without cookies for quite a while. So they've been starting to feed him fruit. So cookies are sometimes food, you know. So he's getting pretty pissed off. So I think we need to feed him some cookies. Now, let's see. So the first target. So I've been mentioning, well, let's just do this first one. I've been mentioning mail.google.com as a target. Interestingly enough, damn it. Oh, this is not that important. I don't know if I can change the font size. So I'm just running the tool. It has some command-line arguments. It's probably good that I'm, that you can't see the font because it has a web key on there that I don't want people injecting stuff into. So it's just. . . I'm just trying to show you why some people are injecting stuff into. Just running the tool from this command line, it has a few arguments to say the interface, the key, and MAC address that you want to watch. So now I'm going to go over and hit addons.mozilla.org. Now addons.mozilla.org has a feature where you can, if you're an add-on developer, you can be a trusted add-on developer. And now what this does is allows you to upload add-ons and have them instantly be propagated to all the users that have subscribed to that particular add-on. So if there's a vulnerability in this site, and you can capture the cookies of somebody, you can potentially cause a whole bunch of users to install malicious Firefox extensions that then go on themselves, have full access to your system, they can run arbitrary code, and then when the update comes to try and revert it, they're already running other malware. So the DEF CON network has not been the greatest, but at this point I already have enough information to be able to inject the content element if the network will hold up for the success of the next request. So let's see here. Let me double check here. So now I'm going to go to CNN. And note there was a quick little refresh. It transferred some data from addons.mozilla.org, and then the page loads CNN as normal. Now, successive reloads of this user might be like, well, that was kind of weird. I had a little white page for a little while there. What the hell was that? You know, they hit reload, and the tool has noted that it's already captured the cookies, so the second time around, it doesn't inject the white screen. So now I'm going to copy these cookies over to my Firefox profile. So I guess I could try and do a K term so I could show you that. What is it? Okay, console. I'll show you that there's nothing up my sleeve here. If I can change the font, what are we doing on time? Which one? How's that? There, there, there? Eighteen. Eighteen. All right. So here's the profile that I'm going to use. There is no cookies.txt here. I'm going to copy it over from the file that I just created. What? Oh, wait. Oh, there's a cookie. Whoops. Less. Check the sleeve. No, it's empty. And there's this sketchiness. We'll get rid of that just so you know that I'm not screwing around with that. All right. All right. All right. Let's check the cookies. Copy cookies. So here's the cookies file. Less cookies.txt. And here is all the cookies that have been written out. Now we'll fire up a different browser. I guess there could be tons of things up my sleeve still, so you just have to trust me and check the tool in a couple weeks. So now we'll hit... In this other browser, which is a different profile, it has Tor button installed. This one doesn't. Hit addons.mozilla.org. And now I'm still logged in. So there's the developer tools. I can go and potentially upload a malicious extension. The same thing is applicable to Gmail. However, about 20 minutes before the talk, they changed how the cookie headers were being transmitted. And the tool stopped working. So that was a little strange. I mean, it could have been me doing something retarded. I was trying to do a couple of last-minute changes. But it sure looks like the cookie header is being transmitted in a way that wouldn't normally be... You know, it's truncated, basically. The HTTP header is not long enough to include it. So let's see here. So we'll hit... Where is this? Oh, there it is. There it is. There it is. All right, so let's hit hbsmail.google.com. And so we loaded the page, we stored the map. And then we'll hit CNN. Let's see if this works. All right. No, it's not getting it. Something changed. Oh, well. That's broken. It'll be fixed by the time I release the tool. Apologies. So Google... So, all right. Let's go back to the slides. All right. So Cookie Monster is feeling much better. We've given them at least add-ons on mozilla.org. Gmail is still vulnerable in the default configuration. So let's do... What can you do to protect yourself? So, okay. So about a week or so ago, we got a call from Google. And a week ago, Google did announce that we have... They have a HTTPS pref for... You know, if it... If you set this pref in your options, you're aware of it. Then you can say, oh, I want Gmail to be HTTPS only. So the problem with this, though, is that if you... If you're not aware of it, the default behavior of Gmail, if you're familiar, you log in via HTTPS. It'll keep you in HTTPS afterwards. And you'll think that you're secure. But you're really not. The cookie is still set without the secure bit. If you haven't set this pref and you're not aware of it. So it's my opinion that it really should be the case that Gmail is... You know, should... You know, since it already is tracking the fact that you are logging in via HTTPS and knows to redirect you to HTTPS afterwards, the cookie should still have that property. But it does not. So that would be the ideal fix. You can also use this force HTTPS. Firefox. I don't know what it's called. I don't know what it's called. But it's very complicated. You have to edit some browser preferences to be able to specify that you want to force specific domains. The UI is not done yet. The other thing you do is just log out of your SSL services when you're done. And clear your cookies regularly. And not access things outside of SSL. So, as I said before, there's another potential vector where a large portion of the Internet can be... Have their Gmail captured, especially if they're not aware of this attack. Basically, the Metasploit module for the DNS hijack has been out for a while. The Computer Academic Underground, I think, put it out. So you basically scan for these vulnerable DNS servers. You can hijack Google.com by using the glue... Spoofing the glue record after you spoof the sequence number. And then you can inject these content elements into the domain for the page that you're targeting. It would be a good idea to target Google.com because people will probably hit Google for... Before doing it pretty commonly to do a search. And then you only have to do one hijack. And you can modify this tool to passively collect these cookies at your IP. And it's a two-line change. And then... Question, question, question. Profit. Additional services that are vulnerable are... Additional services that are vulnerable are Google Docs. All the Google services haven't been updated. They've been upgraded as well. So all those cookies still are insecure. You can grab... There's a lot of corporations will store sensitive stuff in their Google Docs. The Google domain, for example, the pref to set for the domain wide is $50 a seat. So it can cost a great deal of money to be able to pay for the right to set this pref across the domain. And the individual pref has not been rolled out to the individual user accounts for the Google domain services yet. So... Little bit of thanks. I want to thank Damon McCoy. He helped out with additional wireless drivers and headers for the injection. So it would work on arbitrary networks. Colin Jackson for his force HPS work. A lot of conversations with Nick Weaver. He actually... His blog describes a bounce attack that you can use to get arbitrary Google session cookies for any arbitrary service. So if you Google for his blog post on the topic, he outlines that there. So that's another potential... Vulnerability. And then, of course, all the LoreCon and Python... PyLoreCon authors and the dpacket team. Yeah.