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 attempting 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 attempted validation is that you will ensure that a certificate chain is complete. But nothing more. And here's what I mean by that. So, let's say you have this picture, 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 my website. 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 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 when presented with this complete chain, Internet Explorer, Conqueror, Outlook, OpenSSL, many different SSL implementations, all considered to be completely valid. So then back in 2002, Microsoft did something particularly annoying, and I blew this up by publishing it. And Microsoft claimed, okay, this is a real vulnerability, but it's basically impossible to exploit. So I published the tool that exploits it. That tool is called SSL Sniff. It's a tool called SSL Sniff. 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 Sniff 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 note 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, like, browsers had been patched, this tool was pretty effective because you'd be surprised, you know, most of the time, users would just click through the dialogs. And there's actually some kind of cool stuff you could do where, like, a lot of SSL implementations or web browsers would start to validate a certificate. And then as soon as something was wrong with the certificate, they would pop up a dialog telling you that 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, like, on the fly create certificates that expired ten minutes ago. The signatures are totally bogus, like, completely fucked. And it would pop up a dialog that's like, something is wrong. This certificate expired ten minutes ago. And you know, most users would be like, well, it only expired ten minutes ago. I mean, you know, it's not that bad. 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, you need something that will intercept the connection, generate a certificate on the fly. Sign it with whatever certificate you give it, and then pass it 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 is useful. But how it's deployed really matters. On the web, SSL is almost never encountered directly, right? Very few people type HTTPS colon forward forward slash something into their URL bar. Most people type bankofamerica.com enter, right? 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. Right? 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 check out or whatever. And that's the moment where SSL is used. 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 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 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. That little padlock icon was everywhere. You know? It was in the status bar down at the bottom right. You know? Firefox's entire URL bar would turn gold. There's all these things telling you, this is secure. And by contrast, if there was a problem, it would just pop up a dialogue. 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. 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 okay anymore. 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. You know? And until they see that, they don't think anything's amiss. So okay. 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. Sure. 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 that I suggested of a different direction you can go from there is adopting homograph attacks to work in this situation as well. But 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, right? The larger question for me is where do we need to go from here, right? Like I maintain that this stripping attack is deadly in practice and will be deadly for a long time. That in field testing, it has 100% success rate, right? Like 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, right? And so I gave the same talk just about SSL stripping at Black Cat Europe in Amsterdam. And for like 20 minutes before the talk, I ran SSL strip on the network and I got like 100 passwords from, you know, a hundred passwords. You know, so-called security professionals, right? And so I put their passwords up on a slide that was like, see, you know, if you see your password here, you also fell victim to this, right? Anyway, so this is deadly in practice, but, you know, what do we need, right? So there's some places that this technique does not reach, right? One of them is like people that are starting to use bookmarks now for their secure sites, right? So there's, you know, people that have their Gmail login bookmarked to be HTTPS, right? So they don't have that. They don't expose the bridge. And then the other thing is other protocols, right? 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? 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, you know, trustworthy, and it's known to be authentic based on that issuer's signature. You know, this is what a certificate looks like. This is Google's certificate, and you can see that, you know, the subject is Google and it's issued by thought and, you know, there's some public key in there, right? Now when designing a secure protocol, the three big things that you're after are secrecy, authenticity, and integrity. Most people talk about secrecy, you know. They think of encryption and they think secrecy. But if you don't have authenticity and integrity, you don't have anything. They're crucial. Okay. They're critical, and we will see why. You know, 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 it's trying to connect to, right? And 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, right? 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, right? 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 at this. Looking back into the past. So like in, you know, 2000, the late 90s or whatever, things were different. When I was applying for like certificates to exploit this basic constraints vulnerability that I talked about, I just needed to get a certificate for a domain that I owned, right? And back then, it was like 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, you know? And I was thinking to myself, my God, how am I going to prove to this guy that I am me? You know? And this was like totally, you know, legit, just needed to get a cert for my domain, right? That is a bygone era. Today it's all about this thing, online domain validation, and all of this whole process was no reason all this stuff has been replaced. It's all been replaced by a website. You go to the website and you submit your certificate signing request. The 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, right? It's like, you know, version 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, right? You know, 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, right? Because this is where that information is contained, right? It doesn't give a shit about subdomains, right? It doesn't care if it's www or, you know, it could be certificate authorities or a total ripoff .bankofamerica.com, right? 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. You know, there's no one looking at this. This is an automated process. Okay. So I am simplifying things a little bit. Subjects are not just, you know, an ASCII string in this thing, right? It's actually this structure called a distinguished name. To understand the 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, like, updated to the 1998 standard, it was completely gone. I think it was 2021 standard, I think. Whoever was just, like, cutting and pasting it over just forgot to cut part of it out and paste it in. And then that was published as the standard. And then people implemented the standard based on what was published. And then after the implementations were out there, people were like, oh, shit, we forgot part of the standard. And 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, you know? And so it's like the standard, it's crazy. You know, it's like, well, okay, 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 and, like, so what you do is you get the thing and you validate it, and if that doesn't work, you try this other thing. And it's insane. It's seriously insane, right? So the original sort of vision for these distinguished names was that each distinguished name would fit into this global information directory tree, right? So you know, for instance, if I were going to get a certificate with a distinguished name in it, you know, it would say country United States, state Pennsylvania, locale Pittsburgh, organization Institute for Disruptive Studies, organizational unit, research and development, common name Moxie Marlin 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, right? 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. And the thing is that he's right. It's crazy, right? So 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, you know, 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, right? 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, you know, 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, right? This is different from how C strings are represented. In C, you know, your pointer to the string is just the pointer to the first character in the string. You have no idea how long the string is. Right? And then you have to walk through the string until you encounter a null character. And the null character indicates that you've gotten to the end of the string. So really the, you know, 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, right? Anyway. So we'd like to get some certificate. We'd like to get a certificate with a subject that has a common name of www.paypal.com, right? The problem is that we don't own paypal.com so we can't do that. 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. It doesn't have to exist, you know? They don't care. They don't give a shit about it. They totally ignore it. I can put whatever I want in there, even 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. Right? So they look in the URL bar. We typed in paypal.com. They want to compare it to the subject in 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. So every product that uses the Microsoft crypto API is vulnerable to this attack when validating certificates. You know, the popular thing are web browsers. So 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, you know, links is vulnerable. Curl is vulnerable. Mail clients. Thunderbird is vulnerable. Outlook is vulnerable. Pigeon. AIM. IR SSI. Center ICQ. Even SSL VPNs are vulnerable. AEP. Citrix. A bunch of stuff. I couldn't even test them all. Basically almost everything. Okay. So now we've updated SSL sniff and we have a first cut of this. And 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, right? So how does that look, right, compared to what we were talking about earlier? So this is Gmail's 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, you know, it tells you that it's doubled. Because, again, it has to display the C string and when it displays it, it null terminates it, right? Even if you were to 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, right? 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 it. 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, you know, I think they're going to visit these sites or whatever. Sometimes you don't even know, right? 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, okay, 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. And, you know, any SSL implementation that does this matching, right? So we can start with NSS, which is the thing that Firefox and all the Mozilla products use, right? 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. So then your eyes start to clear. And you look at the very first line. Register int xy. Register. This must be, like, 14-year-old code. You know, nobody uses register shadowing anymore. The compilers just ignore it, right? So that's, you know, 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. Star, null character, .thoughtcrime.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, like, create another certificate and sign it to, like, present it to someone. You can just, 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, like, other really weird stuff in there. Like, if you don't want to use a null character, you could get star.tildi.thoughtcrime.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.com or mail.google.com or etrade.com or bankofamerica.com. Nullcharacter.thoughtcrime.org. And 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, you know, 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, you know, a string like this, you allocate a buffer that's this big. And then you copy this much data. And this is actually, the stars actually align to make this exploitable. Like, there are so many things that should have stopped this from being exploitable. You know, the first thing you're like, okay, well, there's no way I can get shellcode past the Unicode filters or whatever. And then you look at the Unicode filters and you're like, no, actually, I can't get the shellcode past the Unicode. And, you know, then it's like, oh, but they stirdupe on it. So that would, like, terminate the null character thing. And you're like, no, but if you put a tilde in there, it just replaces that with a null character, you know. So anyway, the stars really align 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, you know, 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, you know. 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. And it just 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 certificate revocation and updates, right? 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. 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? 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, seven minutes long. It's not 100 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 will 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? So the 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, you know, basically some data that says, like, 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 the certificate or forge the signature, which is, you know, kind of a drag. But if you look at the 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 would 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 you start to look through these things, all right, what else do we got? Malformed request. That doesn't sound that good. We could send internal error. That also doesn't sound good because it has the word error in it, you know. 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 3. Actually, the ASCII character 3. 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 work. It doesn't sound too bad. So what this essentially means is this entire standard, this whole OCSP thing, can be defeated by the number 3. So now, okay, third cut. We have an OCSP or SSL SNF. 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 3. 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, right? 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 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 or, you know, 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 stuff that they need. All 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 null prefix cert for AOS2.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 root kit 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 CACerts 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. You know? I don't know. The other cool thing is that this works not just for the Mozilla binaries, but for the application itself. It has extensions, too. So all the add-ons auto-update, where they connect to add-ons.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, root-kitting the binary, you can just root-kit whatever add-on you want. Which is actually just as good, because you can do anything from an add-on. I taught... I did a training at Black Hat 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 add-on that basically any time 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? It's kind of cool. 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. 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 if it sees one, you can specify on the command line, you know, update these platforms with this binary. And, you know, if you see an add-on, update it with this thing or whatever. And so it'll just hijack the updates and install code on your computer. 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 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. 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. So the weird thing is that, like, some certificate authorities don't do that. Some of these 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. 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? So, you know, the problem is that, 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, 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. Right? And so then when you actually present this to an SSL stack that strips the null character, 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. So in conclusion, 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. And we get all the traffic. We defeated OCSP as implemented. 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. Thanks. So SSL strip, the thing that I was talking about in the beginning, is available on my website. It's been available for a while. 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. So you can download all that stuff there at thoughtcrime.org. Thanks.