Okay, so my name is Moxie Marlinspike. I'm here for the Institute for Disruptive Studies. It's like an anarchist think tank. I'm going to be talking about some new tricks for defeating SSL in practice. I eventually hope to leave you guys with undetectable man-in-the-middle attacks against SSL connections. But it's part of a story. So I'm going to start, you know, I hate to repeat myself, but I'm going to start with the old and eventually come to the new. So the story starts with this concept of basic constraints. And that story starts with certificate chaining. So when people think about certificates, they usually think about certificates coming in pairs. They think of two types of certificates. CA certificates, you know, these things that are sort of all powerful, they're embedded in your web browser. And then site certificates. These are the things that identify leaf nodes or any given end entity. But sometimes the picture is a little bit more complicated. Instead of just two certificates, there could be more. You could have a certificate chain. The idea itself kind of makes sense. Perhaps you'd like to delegate signing authority to a third party, but that third party doesn't have their certificate embedded in every web browser since 1996. So what do you do? You sign the third party. They sign your certificate, and they, in turn, sign your certificate. And so, you know, when you get one of these things, you apply, you know, you hand the whole thing to a web browser and the web browser deals with it, okay? And, you know, it could be more than three. You can have any number of intermediate certificate authorities in the chain. I don't think that there's any standard that says how many is the maximum. I think it's implementation specific. I know for Firefox, it's like 25. So you could have a certificate chain with 25 intermediate CA. So the question is, how do we verify these things? You know, you get a certificate chain. What do you do? And what everyone says is you start with a leaf node, and you verify that the name on the leaf node is the same as the name of the site you're trying to connect to. Then you verify that the leaf certificate hasn't expired, and then you check its signature. And if the signing CA is in your list of trusted root certificate authorities, you stop. Otherwise, you move one up the chain, and you repeat. So here's, you know, a picture from IBM's website today, and, you know, it has a little graph about validating these things. And, you know, they lay it all out in the same way of you start with a leaf node, and you keep going back up. I've said before that I feel like when looking for security vulnerabilities, a good place to start is places where developers might not understand the full scope of what's going on, and yet feel really good about the solutions that they implement. So, for instance, when validating a certificate chain, it's tempting to use a simple recursive function. And this is a situation where, you know, a developer might implement a solution and think, man, I used recursion today, and it was awesome, you know? It was like the same function calling itself over, you know? But the results of sort of a naive recursive attempt at validation is that you will ensure that a certificate chain is completely valid. It's complete, but nothing more. And here's what I mean by that. So let's say you have this picture, a fairly common picture. Some root certificate authority, a couple of intermediate CAs, and then your leaf node that identifies a website you own, like thoughtcrime.org. It's a website I have. So what is to stop me from doing this? Creating another certificate for some other website, paypal.com. And then signing it with mine. And then my leaf certificate. And then passing that whole chain to any client. If you go back and you look at what people say about how you validate these things, we haven't really done anything wrong. You know, all the signatures are valid. Nothing's expired. The chain itself is intact. And the root CA is embedded in the web browser and trusted. But we just created a certificate for paypal, and we're not paypal. So the missing piece is this somewhat obscure field called baselink. Basic constraints. The idea is that not all certificates should be able to do all things, right? Like if you have an end entity certificate for a website, that should really only be used to identify your website. It shouldn't be used to sign other certificates or for key revocation or anything like that. The problem was that back in the day, when most certificate authorities would issue certificates, they would just leave this field out. And you would think that, like, if you were writing an SSL implementation and you were sort of checking a certificate, if this thing was just absent, you would assume the conservative thing, that this is not a certificate authority certificate. But it turns out that whether the field was there or not, most SSL implementations just didn't bother to check it. What this meant was that anyone with a valid leaf note certificate for any domain could create and sign a leaf certificate for any other domain. It essentially meant that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. And what this meant was that anyone who had a valid leaf note certificate had a CA cert. SNF. It works like you'd expect. Let's say you have a client and a server. Client's trying to connect to the server using SSL. It's trying to connect to PayPal. SSL SNF would perform a man in the middle attack. So it intercepts the client's connection request to the server and generates a certificate for the site that the client is trying to connect to. So it generates a certificate for PayPal.com on the fly. And then it signs it with any random leaf node certificate that you give it. And then it passes the whole chain back to the client. Simultaneously on the server side, it makes a normal SSL connection to the server and then starts passing data back and forth between the client and the server. The important thing is that in the middle here, the data is in the clear. And you can log it or modify it or do whatever you want. Okay. So the question is, post disclosure, you know, 2002 was a while ago. Is this thing still useful? Is this tool still useful? So first, you'd be surprised who still doesn't check basic constraints. The second thing was that even after browsers had been patched, this tool was pretty effective because you would be surprised, you know, most of the time users would just click through the dialogues. And there's actually some kind of cool stuff you could do where, like, a lot of SSL users would start to validate a certificate and then as soon as something was wrong with the certificate, they would pop up a dialogue telling you something was wrong. And, like, the second thing that they do after checking the name is check the time stamp to see whether it's expired or not. So you could on the fly create certificates that expired ten minutes ago. The signatures are totally bogus, like, completely fucked. And it would pop up the dialogue that's like, something's wrong! This certificate expired ten minutes ago. And, you know, most users would be, like, well, it only expired ten minutes ago. I mean, one's you know, it's not that bad, you know. So, you know, but it wouldn't tell you about the signature problems or whatever, you know, because it would just get right there and stop. So, yeah, so it was still useful in that sense. And then it's still just useful as a general tool for man-in-the-middle attacks on SSL. Like the folks that did the MD5 hash collision stuff, they used this tool to deploy their CA cert, right, because once you get a CA cert, that's nice, but how do you do, like, on the fly man-in-the-middle attacks, right? Well, generate a certificate on the fly, sign it with whatever certificate you give it, and then pass the thing back to the client, right? And that's exactly what this does. And so then there's other uses yet to be disclosed another day and today. More lately I've been talking about SSL stripping. I've been talking about it a lot lately, so I'll try and be kind of brief. But SSL stripping is fundamentally about the concept of bridges, right? So, the thing is that SSL... 007 007 007 007 007 is useful, but how it's deployed really matters. On the web, SSL is almost never encountered directly. Very few people type HTTPS colon forward forward slash something into their URL bar. Most people type bankofamerica.com enter. And so, my sort of thesis is that SSL on the web is really only encountered in one of two ways. It's either encountered as a 302 redirect from an HTTP URL, so it's either encountered by somebody typing bankofamerica.com enter into their URL bar, which makes an HTTP request to the server. The server responds with a 302 redirect that says, please, instead, connect to HTTPS colon forward forward slash bankofamerica.com, and the browser just sort of gets upgraded to SSL. And then the second way is through clicking on links, right? So most users browse along, and eventually they encounter a link that says sign in or shopping cart or checkout or whatever. And that's the moment where they encounter SSL on the web. Both of those points are bridges between an insecure and a secure protocol. And they're weak points. So, the idea is that maybe we can attack SSL before we even get there. So in the past, you know, SSL sniff would go after the SSL connection itself, right? Its job was to man in the middle the actual SSL connection. And so I wrote a different tool, called SSL strip. And what it does is perform man in the middle attacks on the HTTP connections that will inevitably happen before an SSL connection. And that's not hard at all, because it's not a secure protocol. So SSL strip basically just does a man in the middle attack on all the HTTP connections on a network, and it watches the traffic go by. And in its most basic form, it looks for these two points, links and 302 redirects. And if it sees an HTTPS link, it swaps it for an identical, HTTP link, and it keeps a map of what has changed. If it sees a 302 redirect, it looks for the location header, which is where the redirect URL will be. And if it sees an HTTPS link in there, it swaps it for an identical HTTP lookalike, and it keeps a map of what has changed. Then it continues to watch the HTTP traffic go by. And if it sees a request for a URL that it's stripped, it proxies that out as SSL to the server. Right? So the server never knows anything's wrong. It's getting SSL connections on the URLs that it expects to get SSLed to. SSL connections for. And, you know, on the client side, it still just happens to be HTTP. And then you just keep watching the HTTPS traffic come back from the server, and you keep a map of all the relative CSS links, JavaScript links, you know, all that stuff, right? Because that should be, those should be SSL connections too. And of course you log everything that you want to log. So how does this look, right? So the idea behind most of this stuff is that there's been sort of an evolution in the way that browsers deal with what I would call positive or negative feedback. It used to be in the past that browsers, I felt, had this strong emphasis on positive feedback, right? That little padlock icon was everywhere. You know? It was in the status bar, down in the bottom right, you know, Firefox's entire URL bar would turn gold. You know, there's all these things telling you, this is secure, right? And by contrast, if there was a problem, it would just pop up a dialogue. You know? But today I feel like there's been this evolution of toning down the positive feedback and ratcheting up the negative feedback. So all the little lock icons, there's just sort of less and less of them. You know, there's less things to tell you that things are secure, and more things to tell you that things are really bad, right? There's not just dialogue boxes anymore. Like on Firefox, if there's a problem, it actually, the page renders out to say there's something really wrong. It takes something like five clicks or something to get through that. I mean, it's not the thing that users just click OK anymore. Right? And so, the idea is that if you can avoid the negative feedback, you're in really good shape, right? And if you fail to trigger the positive feedback, maybe it's not so bad. That most user experiences, they just browse along until they encounter something that says, look out, there's something very wrong. And until they see that, they don't think anything's amiss. So how does this basic attack look? This SSL stripping attack, right? So this is like Gmail's login page on Firefox 3. You know, this is the secure version. This is the strip version. It's pretty subtle, no dialogue boxes, nothing saying everything is wrong, you know. This is Safari, right? This is the secure version. This is the strip version. Show it to you again. So there's the only thing on Safari is if you look at the top right, there's that little blind embossed padlock. That's the thing that disappears. So not bad, right? And this evolution of positive and negative feedback really helps this technique, right? So this is I've been talking about this a lot, but this is just the starting point for this type of attack. Once you start to attack this bridge between HTTP and HTTPS, there's a whole ecosystem of things that you can do. One of the ways that I one of the things I suggested of a different direction you can go from there is adopting homograph attacks to work in this situation as well. There's a whole bunch of stuff that I've already written about it that if you're interested you can find elsewhere. So the question today is where can we go from here? The larger question for me is where do we need to go from here? I maintain that this stripping attack is deadly in practice and will be deadly for a long time. In field testing it has 100% success rate. Seriously, even there was some response to this where people were like, oh, this is a matter of user education. Users don't know what they're doing. So I gave the same talk just about SSL stripping at Black Hat Europe in Amsterdam. For like 20 minutes before the talk I ran SSL strip on the network and I got 100 passwords from so-called security professionals. So I put their passwords up on a slide that was like, see? If you see your password here, you also fell victim to this. Anyway, so this is deadly in practice, but what do we need? So there's some places that this technique does not reach. One of them is people that are starting to use bookmarks now for their secure sites. So there's people that have their Gmail login bookmarked to be HTTPS. So they don't expose the bridge. And then the other thing is other protocols. There's plenty of SSL-based protocols like IMAP, IMAP-S, SMTPS, POP3S, you know, IRC, SSL over IRC, stuff like that. And those protocols don't expose this bridge. SSL VPNs, stuff like that. So what we need is a different technique to attack these points. Okay. So let's start thinking about that. The first thing is what's up with certificates, right? Everyone always talks about certificates, but what are they really? They're actually these pretty simple structures. The basic point of a certificate is to identify some subject and convey that subject's public key. The certificate is thought to be good because it's issued by some issuer that people might think is trustworthy. And it's known to be authentic based on that issuer's signature. This is what a certificate looks like. This is Google's certificate. And you can see that the subject is Google and it's issued by thought and there's some public key in there. Now, when designing a secure protocol, the three big things that you're after are secrecy, authenticity, and integrity. Most people talk about secrecy. They think of encryption and they think secrecy. But if you don't have authenticity and integrity, you don't have anything. They're critical, and we will see why. The basic SSL beginnings of a handshake look like this. Client sends a message to the server that says, hello, I am some client. I use SSL version whatever. These are the cipher suites that I support. I also like these compression methods and here's a random number and some other information. The server responds, yes, hello, I am the server. I also support this version of SSL whatever. I think we should use this cipher suite and this compression method. And, by the way, here is my certificate. So, as soon as the client gets the certificate, the first thing it's going to do is look at the subject and it's going to make sure that it's the same thing that's what we're trying to connect to. So it's going to compare the subject with whatever you typed into the URL bar on your web browser or whatever you typed into the mail server field for your IMAP client or whatever you typed into the server field for your IRC client or for your VPN software or whatever. And this is really where the problems for us begin as attackers. Because we can perform a man in the middle attack here. We can intercept the client hello and we can respond with our own server hello that says, yes, I am the server whatever. But we have to send a certificate. And what do we send? We can't send the real certificate from the actual server because it has a public key in it that we don't have the corresponding private key for and as soon as they start encrypting things, we won't be able to decrypt them. So this is a problem. So let's start by looking back into the past. So like in 2000, the late 90s or whatever, things were different. When I was applying for certificates to exploit this basic constraints vulnerability that I talked about I just needed to get a certificate for a domain that I owned. And back then it was crazy. There was notaries. I had to show actual state ID to people. There were phone calls with actual people involved. I actually remember talking on the phone with this guy at VeriSign at one point and he was like grilling me. And I was thinking to myself my god, how am I going to prove to this guy that I am me? And this was totally legit. I just needed to get a cert for my domain. That is a bygone era. Today it's all about this thing, online domain validation. this whole process was no reason all this stuff has been replaced by a website. You go to the website and you submit your certificate signing request. A certificate signing request is another basic structure. It's defined by the standard PKCS number 10. And it just has a few things in it. It's like the registration number that the thing supports, the subject, public key, and whatever attributes you might want. So here again is our old friend, the subject. This is the exact value that will later be included in the certificate that is issued by the certificate authority. Ideally, we might want it to say something like bankofamerica.com. When you submit a certificate to a certificate authority and it has bankofamerica.com as the subject, the first thing that the certificate authority does is look at the root domain. It does a whois lookup for that and pulls out whatever contact information is in the whois record. And then it sends an email or makes a phone call or something to whoever that might be. The important thing here is that it only looks at the root domain. Because this is where that information is contained. It doesn't give a shit about subdomains. It doesn't care if it's www or it could be certificate authorities or totalripoff.bankofamerica.com. If you submit that, it will dutifully look up bankofamerica.com, pull out the whois record, and send whoever some contact email. There's no one to be offended. There's no one looking at this. This is an automated process. I am simplifying things a little bit. Subjects are not just an ASCII string in this thing. It's actually this structure called a distinguished name. To understand this structure, you have to understand that the X.509 standard is a total nightmare. There have been three revisions over the course of 20 years. Parts of the standard have literally been lost and then found again. I'm not kidding. When the 1988 standard was being updated to the 1991 standard, whoever was just cutting and pasting it over forgot to cut part of it out and paste it in. That was published as the standard. People implemented the standard based on what was published. After the implementations were out there, they put it back in. But then it was like, there's all these implementations that already do it the wrong way, but it's kind of the right way because for a second it was the right standard. It's crazy. The standard says you do this, but really what you do is this because there's this time where they forgot part of the standard. What you do is you get the thing and you validate it. If that doesn't work, you try this other thing. It's insane. It's seriously insane. The original sort of vision for these distinguished names was that each distinguished name would fit into this global information directory tree. For instance, if I were going to get a certificate with a distinguished name in it, it would say country, United States, state, Pennsylvania, locale, Pittsburgh, organization, institute for disruptive studies, organizational unit, research and development, oxymarlin spike. In practice, when people are filling these things out, they get to locale and say, what the fuck is locale? And then just type whatever they want in there and the whole thing falls apart. My favorite quote is from this one guy who was trying to implement X509 and he says, there's nothing in any of these standards that would prevent me from including a one gigabit MPEG movie of me playing with my cat as one of the RDN components of the distinguished name in my certificate. But, you know, whatever. In practice, none of this stuff really materialized and at the end of the day, especially when we're talking about certificates that are used with SSL, basically all implementations just ignore everything in the distinguished name except for the common name. And the convention is that in the common name field you put your domain, whatever domain the certificate is valid for. So this is where bankofamerica.com would go in this common name of the certificate, of the distinguished name of the certificate. So how is the common name represented in a certificate? It's this, you know, X509 is specified by, it's an ASN.1 formatted deal. So a common name is basically the sequence that identifies it as the common name and then a string type. There are many different string types that are supported, but you can imagine one of the most common is just like an ASCII string, so an IA5 string. And an IA5 string looks like this. There's a one byte value that identifies it as an IA5 string, 0x16. And then there's a one byte length field that specifies the length of the string to follow. And then there's the actual value of the string, one byte per character, the ASCII byte per character. So essentially, the common name field is a Pascal string. People remember Pascal strings, the way it worked was there was a preceding length field for every string that's X number of bytes and it would specify the length of the string to follow. This is different from how C strings are represented. In C, your pointer to the string is just the pointer to the first character in the string and you have no idea how long the string is and then you have to walk through the string until you encounter a null character and the null character indicates that you've gotten a null character. So really, I guess one important thing to notice is that in Pascal strings, a null character has no special meaning. It's just another character in your character string and it's not imbued with any special meaning. Anyway, so we'd like to get some certificate with a subject that has a common name of www.paypal.com The problem is that we don't own paypal.com, but I do own thoughtcrime.org So I could put thoughtcrime.org in the common name field of a certificate and it would look up who has information for me and everything would be fine. And again, I can put whatever I want. I can get www.thoughtcrime.org I can get verisigneedschildren.thoughtcrime.org Even things that are just totally nonsensical www.thoughtcrime.org It doesn't have to exist. They don't care. They don't give a shit about it. They totally ignore it. www.paypal.com nullcharacter.thoughtcrime.org So if I submit my certificate signing request for www.paypal.com nullcharacter.thoughtcrime.org they will dutifully look up thoughtcrime.org in the Whois database pull out my contact information and contact me. So then, you know, okay. Now we're doing our man in the middle attack we intercept the client hello we send back server hello yes I am the server whatever and my certificate is www.paypal.com nullcharacter.thoughtcrime.org First thing the client is going to do is check the subject. So they look in the URL bar we typed in paypal.com they want to compare it to the subject and the certificate. That code might look like this. You know, char star destination equals get domain we're connecting to char star common name is get common name from certificate and if everything is okay str comp destination and common name will be the same. And str comp is going to do this, right? You have the pointer to both of these values and it's going to check the first character in both strings and make sure they're the same. And if they are it's going to continue with the next character and it's going to keep going until it encounters a null character which indicates that this is the end of the string and so it's going to return success. What this means is that in the eyes of most SSL implementations this certificate is completely valid for www.paypal.com So what are most SSL implementations? So if you look at the implementations themselves NSS is vulnerable the Microsoft Crypto API is vulnerable GNU TLS is vulnerable and what that means is that all of the products that use those things are vulnerable. The product that uses the Microsoft Crypto API is vulnerable to this attack when validating X.509 certificates. The popular thing are web browsers Firefox is vulnerable because it uses NSS Internet Explorer is vulnerable because of course it uses the MS Crypto API Chrome is vulnerable, also for the same reason and then Lynx is vulnerable Curl is vulnerable Mail Clients, Thunderbird is vulnerable Outlook is vulnerable, Evolution is vulnerable Pidgin, AIM, IRSSI Center ICQ Even SSL VPNs are vulnerable AEP, Citrix, a bunch of stuff I couldn't even test them all Basically almost everything Now we've updated SSL SNF and we have a first cut of this We perform a man-in-the-middle attack and if we have a null prefix certificate for the site the client is going to connect to we send that back and complete the man-in-the-middle attack, otherwise we just let everything go through So how does that look compared to what we were talking about earlier Login page, secure site This is the secure version This is the attack version I'll show that to you again Secure version Attack version Essentially there is no visible difference Even if the user were to inspect the certificate it tells you that it's www.google.com still because again it has to display the C string and when it displays it, it null terminates it If you look at the view certificate thing and actually look at the values of the certificate again everything looks indistinguishable There's nothing that a user can do to know that they have been attacked So what are some disadvantages to this attack To me the biggest disadvantage is that I think targeted attacks are lame I think phishing is too much work I don't want to have to get the certificate for this one site or whatever and then try and get everyone to go to that thing Really what you want to do is man-in-the-middle an entire network and get everything that everyone is doing You don't want to have to anticipate I think they're going to visit these sites or whatever Sometimes you don't even know You don't even know what's going to happen You want to just get everything and sometimes things are valuable that you didn't even know about So maybe there's another trick in here somewhere that we can use to accomplish our goal So the first thing we might try is actually looking at the source of any SSL implementation that does this matching So we can start with NSS which is the thing that Firefox and Mozilla products use So you can start and look at the source Don't look at it too carefully Just let your eyes go out of focus Without actually looking at any individual line Just look at the shape of it It's terrible, right? All these nested conditions The like, how it arcs out like that It's too long This thing goes on for like four pages or whatever Just looking at the shape of this code You know There's a bug in here somewhere Right? So then your eyes start to clear And you look at the very first line Register int x y Register This must be like 14 year old code Nobody uses register shadowing anymore The compilers just ignore it, right? And then you get another signal That maybe something is amiss And then you look a little bit further And you get to the wildcard matching And you look at that And you're like, wow This is probably the least efficient way That you can do this And then you realize, wow You can get a certificate for Star null character dot thoughtcrime dot org And this will match any domain This is actually better than having a CA cert Because if you have a CA cert You actually have to create another certificate And sign it to present it to someone If you have this thing You can just hand them the same thing over and over again And it matches for everything There's also other really weird stuff in there If you don't want to use a null character You could get star tilde dot thoughtcrime dot org That would also work It supports grouping Which is weird So like, because wildcard certificates are a little Extra, or they cost more money So if you don't want to shell out for a wildcard certificate You can just get like Paypal dot com, or mail dot google dot com Or etrade dot com Or bank of america dot com Null character dot thoughtcrime dot org And then you only have to Pay for one certificate this way And Of course, here's your remote exploit in here If you look at how it supports the grouping It allocates Based on the length of the string Which is going to be calculated Based on whatever null character might be in there And then It loops through the string again Looking for close paren Just ignoring wherever the Null character might be And then it just copies until it hits the Null character So if you have a string like this You allocate a buffer that's this big And then you copy this much data And this is actually The star is actually aligned to make this exploitable There are so many things that should have Stopped this from being exploitable The first thing you're like, okay, well there's no way I can get shellcode past the unicode filters And then you look at the unicode filters and you're like No, actually I can't get the shellcode past the unicode And then it's like, oh but they Stir dupe on it, so that would terminate the Null character thing, and then you're like No, but if you put a tilde in there, it just replaces that With a null character So anyway, the star is really aligned to make this exploitable Which is kind of insane Oh, the other nice things about this is that No signature is required, you don't have to get a CA To sign your shellcode, because Again, when I was talking before about how SSL implementations used to just Stop at the first thing that they found that was wrong And pop up a dialog box that was like This expired ten minutes ago, whatever So they went to fix that, and so now whenever they find anything that's wrong They continue validating and check everything So that they can pop up a dialog that's like X, Y, and Z is wrong And so, you know Even if the signature is bad on the certificate That you hand to the browser, it's like okay, the signature is bad But I better check the common name to make sure That I know whether to display an error or not And of course then you You know, exploit the client Anyway, so Now we have a second cut of SSL sniff And we perform our man in the middle attack And if there's a null prefix Certificate available for whatever The client is trying to connect to We use that, otherwise if the client Is NSS Then we pass them the universal wildcard certificate This works for everything So now basically we're in a situation Where SSL sniff has to fingerprint the network To know what clients are what so that it knows What to attack in which way So it fingerprints the network And every NSS client's communication is intercepted And then for the non-NSS clients All the certs that you have are used And whatever Non-vulnerable clients exist are left alone So that you don't get detected So what do we have to worry about As attackers, right The two things that come to mind for me are Certification and updates So the first thing Is that it would be unfortunate if some Bitter certificate authority audited their System, discovered that A bunch of certificates had been issued with null characters in them And then went to revoke those certificates And then updates is that It would be unfortunate if Some bitter SSL implementation actually Fixed their thing and then our tricks Stopped working So let's start with certificate revocation These days it's all about this thing called Online certificate status protocol And the deal is that whenever an SSL stack Sees a new certificate, like something that it hasn't seen Since it's been running in this session It makes a quick request to The OCSP URL that's embedded In the certificate to check with the signing CA Right, so basically what happens is Every time an SSL stack sees a Certificate, it makes a quick lightweight Request to the certificate authority that says Hey, is this thing still valid, have you revoked this yet Right And the stack gets a signed response Back from the OCSP provider So as attackers this is really deadly for us Because if a certificate gets revoked It's gone Instantly, right The old world of the certificate revocation lists Where there was like, you know One per certificate authority And each one is like 700 megabytes long Because it's just a list of every certificate that's ever been revoked ever You know, that wasn't working So they went to this model and it's a deadly model For attackers who are forging certificates Right So, you know, here again is Google's certificate And you can see that there's this OCSP URL Embedded in the certificate and every time A browser sees this it'll make a quick Request out to ocsp.thought.com And see what's up So Let's look at OCSP, how does this thing work Right The basic OCSP response that comes back from the Certificate authority looks like this It's basically a one byte response status And then some response bytes The actual data that Tells you what's going on with the status Right And the response bytes look like this There's basically some data that says This is the deal, this is what's going on And there's a signature in there And, you know, as an attacker This could be a problem It might be difficult to forge this signature Which is, you know, kind of a drag But if you look at this signature The interesting thing about it Is that it only covers Some of the response data Notably what it doesn't cover is all this other stuff Including the response status And the response bytes themselves are actually Optional, depending on the status Right, so if we look at You know, what the status options are The status structure looks like this Right, so you can either send You know, one of these things And so ideally we'd like to send If we were like spoofing the OCSP provider What we'd like to do is send back successful But we can't, or it might be difficult to send back successful Because if we did we'd have to include The optional response bytes And that has a signature in it that might be difficult for us to forge So we can't send back successful Right, so maybe we could send back something else So if we start to look through these things Alright, what else do we got Malformed request Eh, that doesn't sound that good Or we could You know, we could send Internal error Eh, that also doesn't sound good Because it has the word error in it And then you get Try later Well that doesn't sound bad at all You know It's not really implying that there's a problem You know Definitely not a problem with our certificate It's just saying try back later It's even sort of suggesting that it might be successful at a later date You know Try back later and it could work good So the interesting thing about try later Is that You don't have to include the optional response bytes When you send try later So all you have to send back is The response itself Which is a single byte value that's literally Three The ASCII character three So all you have to send back is 0x33 And it turns out that when you Send that back for Every SSL implementation that I've tried They all agree that it also doesn't sound too bad So what this essentially means Is this entire standard This whole OCSP thing Can be defeated by the number three So now okay Third cut we have an OCSP or SSL We do everything that we do before And now if we see an OCSP request For any of the URLs that are embedded In the forged certificates that we're using We man in the middle of that And send back three And yeah So even if the certificates get revoked No one will ever know Okay the other thing we've got to worry about is updates You know Just by talking to you today People are probably going to try and fix this So it used to be that people Like downloaded software And of course it's a rapidly changing world There's You know more and more bugs There's more and more at stake And you want to try and get the The patches into people's hands Faster and faster So a lot of people have felt the need To deploy this self updating software So this is bad news for us Right because that means that Things get patched quicker There's a lower window for attacking software But it also seems like Their update mechanisms Might be kind of a dangerous idea right You have software out there that's just like Connecting somewhere and downloading other stuff And just running it right So maybe there's something we can do about our problem So Let's look at the Mozilla system When you install Firefox or Thunderbird Or any of the Mozilla products It comes with this feature called automatic update service And that's enabled by default The way this works is You make an SSL connection Periodically I think once a day The browser makes an SSL connection to the update server And it says hello I am You know whatever Firefox version whatever Here's my build ID for my operating system Linux Windows whatever My locale NUS whatever Channel stable nightly Do you have any updates for me And the update server responds As a matter of fact I do Here's a totally unsigned blob of data That I would recommend that you Just run The deal is that they depend On their SSL connection for All the security of the system Right The idea is that since all of this is transmitted over SSL No one could ever possibly You know intercept these requests So You know we just send this data Back through there and everything should be fine And by default the minor updates Are downloaded and installed silently And they only prompt the user Once everything is done Once everything has been downloaded and installed It says hey we updated your system Restart now you know And the interesting thing is that the update server Is the thing that reports the version number Of the update So the update server is essentially what determines whether Software gets installed silently or not So the problem is going to be That as vendors start to release patches for this vulnerability The update mechanisms themselves Are vulnerable right Because all we need is our universal wildcard cert Or a null prefix cert for Windows2.mozilla.org And we can take control of the update mechanism To deliver whatever payloads we want So this could be anything It could be a rootkit that logs keystrokes It could be something that sends all the traffic to you It could be a completely legitimate image That just happens to include our own CA certs for future use Or just to be confusing it could be A totally different app you know You could like get the update and it's like Thank you for updating to Galleon 0.0.3 You know or just like you update And then notepad opens The other cool thing is that this works not just for the Mozilla binaries but for the extensions too So all the addons auto update Where they connect to addons.mozilla.org Over SSL and they say hey do you have anything new for me And it says yes here you go run this thing So even if you don't want to mess with Like rootkitting the binary you can just Rootkit whatever addon you want Which is actually just as good because you can do anything from an addon I taught I did a training At Blackhat called intercepting secure communication And at the end we did an exercise Where we had like a little malware competition for this Vulnerability and the people that Won had an addon that Basically anytime that you Posted data to a form it also Posted a copy to them So it's like the man in the middle attack that keeps on Giving or whatever you know So anything you know the problem is that in order to patch Your system for this effectively you're not going to be able To trust anything that comes through automatic updates Or actually at this point anything that has ever Come through automatic updates Um so now SSL sniff I have a The fourth cut is an updated aware SSL sniff so it does everything before It does all the fingerprinting OCSP denial All this stuff and now it also watches for Update requests and um if it Sees one you can specify On the command line uh you know You know update these platforms with this Binary and you know if you see an addon Update it with this thing or whatever And so it'll just hijack the updates and Install code on your computer Um okay As a quick postscript to all of this stuff Stripping null characters From certificates is not a solution So there's like a couple of Um stacks that aren't vulnerable to the thing That I've been talking about so far like Safari and opera aren't vulnerable to that Um but they appear to just strip the Null character from the common name Before they compare it right so if you get paypal.com Null character thoughtcrime.org they strip It and then compare it so it becomes Paypal.com.thoughtcrime.org And so that stops this attack But it actually opens up an attack vector For a different attack um So the weird thing is That like some certificate authorities are vulnerable To this internally right So if you submit a csr For paypal.com null character.thoughtcrime.org The Certificate authority itself trips over the null character And tries to validate the cert against Paypal.com so it thinks that You're paypal.com um But the interesting thing is that when you actually get the Cert back it gives you the Entire thing that was originally in the subject Right um so You know the problem is that uh You know we're not paypal so we can't You know we would not be able to get a cert that way But you can do other things right so you could Register a domain like sitekey.ba And then You get a certificate for sitekey.ba Null character inc of america.com And so When the cas are like internally vulnerable They'll they'll like Do the authentication thing against sitekey.ba Which you own right but then what you Actually get back is sitekey.ba Null character inc of america.com Um Right and so then when you actually Present this to a ssl stack that Strips the null character uh It becomes sitekey.bankofamerica.com And that would validate correctly Against bank of america so basically Every ssl Implementation i think is vulnerable To some variation of this Um so in conclusion Uh we have a man in the middle attack that will Intercept communication for i think Almost all ssl and Tls implementations in the case of Nss we only need a single certificate um And we get all the traffic we defeated Ocsp as implemented uh we can hijack the Auto updates for applications and extensions We've got an exploitable overflow So in short we've got your Passwords your communication and control Of the software that runs on your computer So um ssl Ssl strip uh the thing that i was Talking about the beginning is available on my website It's been available for a while um Ssl sniff the old version Is available on my website and The new version that supports all of these New attacks will be available on my website Sometime between Today and monday Um so you Can download all that stuff there at thoughtcrime.org Thanks Um