1 00:00:00,000 --> 00:00:06,420 All right, everyone. The title of my talk is indeed Black Ops at PKI. I think I owe 2 00:00:06,420 --> 00:00:12,640 everyone an apology for not having the talk title in the DEF CON description. I just really 3 00:00:12,640 --> 00:00:17,820 felt, you know, I don't need another couple months of drama around what the talk is or 4 00:00:17,820 --> 00:00:21,680 what's actually in it. Forget it. I'll just say nothing, have a nice quiet month of July, 5 00:00:21,680 --> 00:00:32,000 be great. Anyway, so, hi, I'm Dan. Not actually a black hat, sorry about that. But this is my 6 00:00:32,000 --> 00:00:37,980 tenth talk here at DEF CON. I do kind of a foundational thing like SSH and DNS and same 7 00:00:37,980 --> 00:00:46,260 origin policy and DNS and pattern recognition and DNS. So there might be a bit of a theme to the 8 00:00:46,260 --> 00:00:51,660 work. This year I'm really kind of looking at authentication. So I'm going to talk a little 9 00:00:51,680 --> 00:00:55,500 bit about that. There's something of a crisis going on right now with authentication. 10 00:00:56,780 --> 00:01:03,120 Vulnerabilities in Oday get all the press, but according to the actual data, 60% of actual 11 00:01:03,120 --> 00:01:10,720 real-world compromises, not vulns, not Oday, but just no passwords, bad passwords, default 12 00:01:10,720 --> 00:01:14,140 passwords, stolen passwords, my passwords. 13 00:01:21,680 --> 00:01:24,480 Yeah, drink does not even begin to describe. 14 00:01:36,720 --> 00:01:43,780 Fail. Oh, dear. So here's the deal. Passwords are used because they scale really well one at a 15 00:01:43,780 --> 00:01:51,580 time. Passwords fail because they really fail to scale once you have them in a large group. So, 16 00:01:51,680 --> 00:01:56,900 passwords over time, passwords over multiple hosts. At the end of the day, the human brain is 17 00:01:56,900 --> 00:02:03,440 only so big and people screw it up, some more than others. So there are two schools of thought 18 00:02:03,440 --> 00:02:07,560 about what to do about this. The first school of thought is, you know, we can totally make 19 00:02:07,560 --> 00:02:12,600 passwords work if we machine generate them and we cycle them fast and we literally use 20 00:02:12,600 --> 00:02:21,540 Leetspeak as a security technology. It doesn't matter what you do because ultimately, as Schneider 21 00:02:21,680 --> 00:02:26,920 noted, you're still vulnerable to a key logger no matter how good your actual password is. So what 22 00:02:26,920 --> 00:02:31,580 a lot of people want to do is they want to eliminate passwords entirely, and if only we could 23 00:02:31,580 --> 00:02:36,160 get humans out of the memory business. You know, we have, like, hardware that has lots of memory, 24 00:02:36,280 --> 00:02:42,520 gigs of memory, computational power. Why can't it do it? And what we're supposed to be using to do 25 00:02:42,520 --> 00:02:51,140 this was public key infrastructure with X509-based technology. We've been hearing this for a while. 26 00:02:52,420 --> 00:02:58,320 The kind of vibe I keep hearing is if only we cared enough, we could stop using passwords. 27 00:02:58,720 --> 00:03:03,540 Everyone would have smart cards. It would be great. Just people need to care. Well, I found on 28 00:03:03,540 --> 00:03:07,840 the Internet the greatest image of all time that explains what's going on here. 29 00:03:14,200 --> 00:03:21,120 The only description I can come up for this photo is if we just had a big enough care bear, we 30 00:03:21,120 --> 00:03:22,840 could totally ride this pony. 31 00:03:30,780 --> 00:03:38,220 No. Look, business has cared enough about PKI to invest in hundreds of millions of dollars in it in 32 00:03:38,220 --> 00:03:44,020 the last decade. It's not working. I have a theory. I think what's not working, it's not the 33 00:03:44,020 --> 00:03:50,800 business guy's fault anymore. It's just we screwed up the engineering. X509 is just not the 34 00:03:50,800 --> 00:03:51,100 appropriate way to do it. It's just not the appropriate way to do it. It's just not the 35 00:03:51,100 --> 00:03:58,240 appropriate technology to solve the problems we need to solve to fix authentication. So I do think 36 00:03:58,240 --> 00:04:01,940 we need to rethink the foundations of Internet security. I want to point out I'm not one of those 37 00:04:01,940 --> 00:04:10,600 guys who says we should build a second Internet. That's unlikely. Yes. I was trying to be kind. 38 00:04:12,420 --> 00:04:16,360 Look, it's like building a city without roads or highways in the middle of a forest saying but 39 00:04:16,360 --> 00:04:20,720 it will have great mass transit does not make up for the fact that it's not going to work. You 40 00:04:20,720 --> 00:04:27,520 have to integrate with existing life. But by the same token, what we're doing now, it's not 41 00:04:27,520 --> 00:04:34,740 working. We should talk about why. So warning is, of course, look, there's a lot of business stuff 42 00:04:34,740 --> 00:04:39,900 going on. The first couple minutes of this talk aren't that leet. So as a preview, I did show up 43 00:04:39,900 --> 00:04:46,980 at DEF CON with a cert for DEF CON. It is real. I can't tell you who issued it. But Jeff knows. You 44 00:04:46,980 --> 00:04:50,700 can bug Alex Soterov as well. And it could actually be a little bit more complicated than that. I'm not 45 00:04:50,700 --> 00:04:55,460 sure. It could be a cert for anything. In fact, it could be a universal wild card certificate as 46 00:04:55,460 --> 00:05:02,180 well. So at the end of the day, we do end up bypassing the system. Now, let me give you the kind of 47 00:05:02,180 --> 00:05:08,360 basic version if you're not that familiar with X509. X509 is basically the digital version of 48 00:05:10,320 --> 00:05:15,400 implementation-wise of passports. Look, you've got a private key, you've got a face. You've got a 49 00:05:15,400 --> 00:05:20,220 public key, it's your passport photo. You have a subject name, your name, a certificate 50 00:05:20,700 --> 00:05:26,000 of authority, which is the country you live in, a certificate, which is a passport. All we're doing 51 00:05:26,000 --> 00:05:31,040 is saying, look, if you have the face that's in the photo and it's on a card issued by your country, 52 00:05:31,240 --> 00:05:38,100 then you have the name of the person on the passport. X509, that's all it's doing. It is the 53 00:05:38,100 --> 00:05:44,700 digital version of allowing someone else to assert your identity via a combination of a difficult to 54 00:05:44,700 --> 00:05:50,680 fake element, your face, and a name that actually can be used as a handle to show that you're a 55 00:05:50,700 --> 00:05:57,200 person. So it pretty much has only one really good success story, that'd be SSL. This is the 56 00:05:57,200 --> 00:06:06,940 technology behind HTTPS or the web. There was a heroic work done in the mid to late 90s when they 57 00:06:06,940 --> 00:06:12,320 said, if you want users to put their credit card number on the Internet, they need to use actual 58 00:06:12,320 --> 00:06:20,520 good cryptography. This was miraculous that this actually happened. It by far has been the greatest 59 00:06:20,700 --> 00:06:26,160 success story for actual strong cryptography. That being said, there's only about a million SSL 60 00:06:26,160 --> 00:06:30,420 endpoints. There are hundreds of millions of nodes on the Internet and most of them have no 61 00:06:30,420 --> 00:06:35,760 encryption. We're actually arguing whether or not cloud-based applications should have to encrypt a 62 00:06:35,760 --> 00:06:41,100 link from the client to the server. So don't think this is a battle that's been won or doesn't need 63 00:06:41,100 --> 00:06:49,360 to be refought. Now, here's how you actually end up acquiring a certificate. This is a basically a 64 00:06:49,360 --> 00:06:50,680 blob of data that is being sent to the server. This is basically a blob of data that is being 65 00:06:50,700 --> 00:06:56,020 sent to the server. It asserts that you are your website, so you have a certificate for a website, 66 00:06:56,240 --> 00:07:02,520 www.defcon.org. This is a cryptographic assertion that you are indeed talking to DEF CON. The first 67 00:07:02,520 --> 00:07:07,220 thing that happens with getting a certificate is you've got to go to DNS. Everyone always forgets 68 00:07:07,220 --> 00:07:12,560 this phase, but at some point, Jeff Maas had to go get a certificate from, or excuse me, had to go 69 00:07:12,560 --> 00:07:19,040 get a domain name of www.defcon.org. And when he did that, he actually registered himself as the 70 00:07:19,040 --> 00:07:20,680 administrative contact for the server. And that's what we're talking about here. So this is a 71 00:07:20,680 --> 00:07:26,420 way for DEF CON. Next step is to generate a public and a private key pair. Mathematical 72 00:07:26,420 --> 00:07:31,900 objects, large prime numbers multiplied, they're the equivalent of web server needs to have a 73 00:07:31,900 --> 00:07:38,060 face, and your web server needs to then take a photo of that face. The public key is provided to 74 00:07:38,060 --> 00:07:42,700 a certificate authority, along with the name of a website registered in DNS. Now, this is done 75 00:07:42,700 --> 00:07:48,480 with what's called a PKCS number 10 certificate signing request, or CSR. The certificate 76 00:07:48,480 --> 00:07:50,660 authority. Okay, it's received a public key, and it's registered in DNS. Now, this is done 77 00:07:50,680 --> 00:07:55,340 with a public key. It's received a name. How does it know it should actually assert an identity? 78 00:07:55,660 --> 00:08:00,420 Why should it go ahead and say that Jeff is DEF CON, or that I am DEF CON, or that Len is DEF CON? 79 00:08:01,880 --> 00:08:09,980 Well, the way this is actually done is they send an email to the address that was in DNS at the 80 00:08:09,980 --> 00:08:16,160 beginning. There's an exception. Hang on for a bit. This is basically them saying, this is 81 00:08:16,160 --> 00:08:19,960 basically them saying, is this passport photo actually you? Well, let's go to DNS and find out. 82 00:08:20,900 --> 00:08:26,520 Next step, click the link provided in the email. So, you get an email at that address. You 83 00:08:26,520 --> 00:08:33,920 click the link, and that asserts a link between what was registered in DNS, and that you are now 84 00:08:33,920 --> 00:08:39,760 able to go ahead and get a certificate for that name. And then you get the cert. Now, I'm 85 00:08:39,760 --> 00:08:44,240 oversimplifying a little. What I just described is called domain validation. There are many 86 00:08:44,240 --> 00:08:48,500 certificate authorities that offer much more stringent validation. They'll do what's called a 87 00:08:48,500 --> 00:08:50,660 DUNS business lookup. They'll do phone calls. They'll do phone calls. They'll do phone calls. 88 00:08:50,680 --> 00:09:01,380 They'll do... There's apparently great news for me. I can go till 8 o'clock. I can relax. 89 00:09:08,440 --> 00:09:17,280 All right. But I have no beer. Can someone... No. 90 00:09:18,800 --> 00:09:19,240 So. 91 00:09:20,680 --> 00:09:25,400 Just described is called domain validation. There are certificate authorities that are much more 92 00:09:25,400 --> 00:09:29,400 paranoid about actually issuing a certificate. Because they're basically vouching for you. 93 00:09:29,500 --> 00:09:34,880 They're saying, yeah, you know, you are DEF CON. You are Yahoo. You are whatever. And we're 94 00:09:34,880 --> 00:09:39,240 going to do serious lookups. We're going to use a DUNS business lookup. We're going to call you. 95 00:09:39,420 --> 00:09:45,740 We're going to send a lawyer to your house to take a blood sample. You know. But it doesn't 96 00:09:45,740 --> 00:09:49,960 matter. X509 has a fundamental... 97 00:09:50,700 --> 00:09:56,560 limitation in that it cannot exclude without great pain. Now, what do I mean by that? There are 98 00:09:56,560 --> 00:10:02,280 dozens and dozens of certificate authorities out there that are trusted by everyone. All of them 99 00:10:02,280 --> 00:10:07,820 can issue names even if someone else... All of them can issue certificates for a name even if 100 00:10:07,820 --> 00:10:13,680 someone... Some other one of them already has. There is no exclusion. So, this is the direct 101 00:10:13,680 --> 00:10:20,260 equivalent of Zimbabwe being able to issue American passports. I'm not saying I have a problem with 102 00:10:20,260 --> 00:10:20,660 Zimbabwe. I'm not saying I have a problem with Zimbabwe. I'm not saying I have a problem with 103 00:10:20,680 --> 00:10:24,460 Zimbabwe. But I'd like America to be the only one who can issue an American passport. I'm just 104 00:10:24,460 --> 00:10:30,280 saying. So, even if your CA runs you through the ringer, that doesn't mean that every other one 105 00:10:30,280 --> 00:10:35,540 will. The security of the whole of any X509-derived system is equal to the security of 106 00:10:35,540 --> 00:10:44,600 the weakest link. Unfortunately, anything more is security theater. So, there are many good, 107 00:10:44,780 --> 00:10:50,360 many responsible, very responsive CAs out there. X509 does not allow the good 108 00:10:50,680 --> 00:10:56,680 CAs to offer a better product than the not so good ones. The technical term, this is a race to the 109 00:10:56,680 --> 00:11:05,620 bottom. But now let's look at DNS. DNS, by complete contrast, is very good at excluding. The 110 00:11:05,620 --> 00:11:14,320 route. First off, there's one route. Not 50, not 100. There's one route. There's a classic quote 111 00:11:14,320 --> 00:11:20,100 about certificate authorities where the CA system is only as secure as the money they refuse to take. 112 00:11:20,980 --> 00:11:26,260 The route will not actually take your money. You can't register something in the route. They are 113 00:11:26,260 --> 00:11:32,320 an adjunct to the state system. And you can't just buy yourself a country. So, that's just the 114 00:11:32,320 --> 00:11:39,020 reality of it. So, the first level, very exclusionary, very good. The second level, the 115 00:11:39,020 --> 00:11:44,840 registries. Yes, you have com, yes you have net, yes you have org. But there is one company who is 116 00:11:44,840 --> 00:11:50,080 responsible for each register, each top-level domain. VeriSign has exclusive control over all of this. 117 00:11:50,080 --> 00:11:55,860 over com. Affiliates has exclusive control over org. When one of the top level domains had a 118 00:11:55,860 --> 00:12:00,820 serious problem with large amounts of malware, this was not a problem that was distributed across 119 00:12:00,820 --> 00:12:04,840 lots and lots of different organizations. This was not a problem where there was no accountability. 120 00:12:05,240 --> 00:12:11,780 No. That registry had to fix their stuff or their product was going to be blocked. And so they 121 00:12:11,780 --> 00:12:27,780 fixed it. That's awesome. The third thing that the DNS system has, which is very elegant, look, we 122 00:12:27,780 --> 00:12:33,080 have these things called registrars. These are the actual companies that you interact with when 123 00:12:33,080 --> 00:12:39,980 you're trying to put something into DNS. If you register, if I register www.doxpera.com through 124 00:12:39,980 --> 00:12:41,620 network solutions, they have a 125 00:12:41,620 --> 00:12:47,140 exclusive control over my domain. If they screw up, if I decide they're not very good, I can go 126 00:12:47,140 --> 00:12:53,180 ahead and move that domain over to enum or over to any of another bunch of companies. And network 127 00:12:53,180 --> 00:12:58,780 solutions, I'm no longer exposed to whatever vulnerabilities they might have. Look, this is the 128 00:12:58,780 --> 00:13:05,780 ability for me to manage my risk. If recently, I think Microsoft had their New Zealand sites hit. 129 00:13:05,940 --> 00:13:11,040 The registrar that controlled them actually got some SQL injection and they had a bunch of hosts 130 00:13:11,040 --> 00:13:11,540 moved over. 131 00:13:12,280 --> 00:13:18,120 Microsoft was in the position of being able to move their domains from the crappy place with SQL injection to 132 00:13:18,120 --> 00:13:25,000 potentially somewhere else and not have to worry about the problem anymore. That is also awesome. We need 133 00:13:25,000 --> 00:13:32,280 the ability to have accountability in the systems that we use. I love X509. I think, excuse me, I love the 134 00:13:32,280 --> 00:13:37,420 CA system. You wouldn't believe it, but they are, it's awesome having a lot of people out there who are 135 00:13:37,420 --> 00:13:41,600 trying very hard to deploy a secure product. But at the end of the day, they're not going to be able to do it. 136 00:13:42,420 --> 00:13:49,300 They can't help me like this. I can't say I only want this CA to be the only CA who can issue names for me. The 137 00:13:49,300 --> 00:13:59,100 underlying technology has a problem. Now, it is actually possible to do exclusion in X509. It is possible to run what, 138 00:13:59,200 --> 00:14:05,260 basically, run your own certificate authority. And this is what every enterprise is told to do. Oh, run your own 139 00:14:05,260 --> 00:14:11,600 enterprise CA and that's how you'll manage your trust in your organization. On its own, it's very expensive. But if you want to 140 00:14:11,620 --> 00:14:16,420 very difficult to maintain and every single time it hits the exact same 141 00:14:16,420 --> 00:14:20,940 failure oh my god there are other people out there on a need to authenticate them 142 00:14:20,940 --> 00:14:26,640 too so how do I deal with all of the other private CAs that are out there how 143 00:14:26,640 --> 00:14:33,120 do I federate the one successful Federation in the world for X 509 is the 144 00:14:33,120 --> 00:14:40,260 federal bridge CA my god it works this is amazing the people behind it who made 145 00:14:40,260 --> 00:14:46,080 it work deserve a medal the rest of us need a system that you don't deserve a 146 00:14:46,080 --> 00:14:55,120 medal if you actually get it to work so interoperability with other organizations 147 00:14:55,120 --> 00:14:59,460 was thought to be an optional thing we won't often need it and it turns out 148 00:14:59,460 --> 00:15:04,500 it's just not true in theory you only need to authenticate your own 149 00:15:04,500 --> 00:15:09,340 organization you're usually your house keys only used for your house reality 150 00:15:09,340 --> 00:15:10,240 cross-examination 151 00:15:10,240 --> 00:15:14,480 cross-organizational authentication is the rule and not actually the exception we 152 00:15:14,480 --> 00:15:17,600 have partnerships with other companies we have interactions with other groups 153 00:15:17,600 --> 00:15:21,620 anyone who thinks a large company is just one large company has never 154 00:15:21,620 --> 00:15:25,760 actually worked in a large company you are dealing with group after group after 155 00:15:25,760 --> 00:15:32,740 group so this is one of the reasons why passwords work as stupid as they are a 156 00:15:32,740 --> 00:15:37,560 string of a string of text is a string of text is a string of text no matter who 157 00:15:37,560 --> 00:15:38,360 you're talking to 158 00:15:38,920 --> 00:15:40,160 this X 509 159 00:15:40,240 --> 00:15:49,780 stuff isn't. So X509 cannot delegate either, at least without great pain. Every time I need a new 160 00:15:49,780 --> 00:15:53,840 certificate for a node in my organization, I have to go ahead and talk to an external CA, 161 00:15:54,060 --> 00:15:59,300 another company, and I have to get a certificate for that particular node. Every single operation 162 00:15:59,300 --> 00:16:03,060 that's completely internal, I need to keep jumping across the fence to some outside company. 163 00:16:03,320 --> 00:16:07,700 This is expensive. This is operationally inconvenient. There are potentially information 164 00:16:07,700 --> 00:16:14,040 disclosure issues, and it interacts very poorly with devices. There are hordes of devices in all 165 00:16:14,040 --> 00:16:20,120 of our organizations. All of them have DNS names. None of them have anything more than self-signed 166 00:16:20,120 --> 00:16:25,480 certificates. So we were supposed to have this thing called name constraints. And what name 167 00:16:25,480 --> 00:16:30,480 constraints were supposed to let you do is they were supposed to let you sign for star.docspara.com 168 00:16:30,480 --> 00:16:35,960 or star.this.com or star.that.com. They were supposed to allow you to get a delegated portion 169 00:16:35,960 --> 00:16:37,560 of the namespace. 170 00:16:37,700 --> 00:16:40,620 And that would be your portion, your tool to work with. 171 00:16:42,720 --> 00:16:49,780 There's very weak support for this in the field. So you can't actually buy it. The technology just 172 00:16:49,780 --> 00:16:55,420 wasn't deployed sufficiently enough to depend on. Now, there's another option you could do. You 173 00:16:55,420 --> 00:17:00,180 could get a wildcard certificate, get one certificate, same certificate for all of 174 00:17:00,180 --> 00:17:06,180 star.docspara.com. And now you put this same crypto key on every device in your organization. 175 00:17:07,080 --> 00:17:07,680 That's not going to work. You're going to have to get a wildcard certificate. 176 00:17:07,700 --> 00:17:11,720 That sucks. That is a technological limitation that has just failed. 177 00:17:13,160 --> 00:17:19,260 DNS delegates fine. The root delegates to VeriSign for com. Com delegates to my service for 178 00:17:19,260 --> 00:17:24,100 docspara.com. I do whatever the hell I want in docspara.com. I don't have to talk to other 179 00:17:24,100 --> 00:17:31,020 organizations. That is why all my devices are in DNS and very few of them are in SSL X509. 180 00:17:31,880 --> 00:17:35,600 Now, it is, in fact, possible to delegate X509. 181 00:17:36,140 --> 00:17:37,200 There is. 182 00:17:37,200 --> 00:17:43,280 There is serious demand. Here is what happens consistently. You have a company. They spend a 183 00:17:43,280 --> 00:17:49,840 couple million dollars or some absurd amount of money on their own internal certificate authority. 184 00:17:50,220 --> 00:17:55,900 And then they find they don't work with anybody else. They say, what do we need to be able to work 185 00:17:55,900 --> 00:18:01,520 with everybody else? And CAs come back and they say, well, you kind of just have to come talk to 186 00:18:01,520 --> 00:18:07,180 our website. The company is like, no. We want our certificate authority to work with other companies. 187 00:18:08,180 --> 00:18:13,080 CAs say, well, that would be really insecure. You would be able to sign certificates for Bank of 188 00:18:13,080 --> 00:18:18,620 America and this and that. And the company says, I don't care. I want it to work. So the CA says, 189 00:18:18,840 --> 00:18:26,340 fine. Sign a contract promising you won't abuse the big magic cert and we'll just give it to you. 190 00:18:28,220 --> 00:18:31,660 I promise is not an acceptable security policy. 191 00:18:35,720 --> 00:18:36,980 I promise is not an acceptable security policy. 192 00:18:41,840 --> 00:18:42,400 Just because it's the only way. 193 00:18:42,400 --> 00:18:51,740 The reality is forget hacking yourself a certificate, you can just buy one. It is not that the companies 194 00:18:51,740 --> 00:18:57,860 don't take security seriously. It is that the underlying technology forces this particular failure 195 00:18:57,860 --> 00:19:05,000 mode. So 2008 was not a good year for this system. Mike Zussman did a whole bunch of work against 196 00:19:05,000 --> 00:19:09,820 production certificate authorities. Bypassed Komodo's security check by claiming that he had 197 00:19:09,820 --> 00:19:17,500 this really cool internal server called www.live.com. Thus it wasn't subject to validation 198 00:19:17,500 --> 00:19:25,240 checks. Also bypassed StartCom's checks with some web bug. I broke it as well. As I told you, 199 00:19:25,340 --> 00:19:32,540 SSL ultimately takes a dependency back on DNS and we know how that ended up. But interestingly 200 00:19:32,540 --> 00:19:38,580 enough, Avi Pilasov actually, he did his whole thing with BGP last year. And so he showed that 201 00:19:38,580 --> 00:19:43,160 he could actually sniff arbitrary traffic from arbitrary locations on the internet if he had 202 00:19:43,160 --> 00:19:50,100 ISP level access. Well, that means he can sniff SSL validation emails as well. So he wins. 203 00:19:51,940 --> 00:19:59,260 But the big hack last year was Steven Soterov versus MD5. And what their trick did was pretty 204 00:19:59,260 --> 00:20:02,340 cool. When a certificate authority or country, 205 00:20:02,540 --> 00:20:08,860 deems you worthy of a certificate or passport, it signs, creates a passport with a hologram, 206 00:20:08,960 --> 00:20:16,120 your public key, your photo. Now, signing requires two steps. First, it requires securely 207 00:20:16,120 --> 00:20:22,540 hashing the certificate. This is summarizing it to a small number of bits. A hash is considered 208 00:20:22,540 --> 00:20:29,740 secure if it's difficult to find two files with the same hash. Secondly, once you have this summary 209 00:20:29,740 --> 00:20:32,520 of bits, that's what you go ahead and sign with your public key. So it's not just a 210 00:20:32,540 --> 00:20:38,200 certificate authority's private key. So it is actually the summary that, you know, like a photo 211 00:20:38,200 --> 00:20:43,240 is a summary of your actual face. That's what the signing is sticking a hologram on top of it. 212 00:20:43,820 --> 00:20:49,680 Now, the problem was that Rapid SSL, one of the CAs out there, was using MD5 as its hashing 213 00:20:49,680 --> 00:20:57,440 algorithm. Now, MD5 is not secure. We've known this since 1996. We're still using it. So 214 00:20:57,440 --> 00:21:02,520 Stevens and Lenstra actually went ahead and created what was called a chosen pre-setting. 215 00:21:02,540 --> 00:21:07,340 It's a pre-fixed collision attack. Now, in this attack, given two different beginnings, they were 216 00:21:07,340 --> 00:21:12,620 able to create a blob that if you attached it to both of these beginnings, which could be anything, 217 00:21:12,840 --> 00:21:19,700 would cause them to unify into the same hash, into the same summary. So the attack was that 218 00:21:19,700 --> 00:21:24,760 they had a certificate authority sign a certificate that looked completely innocent. It was a 219 00:21:24,760 --> 00:21:29,880 completely valid certificate for, you know, some very long domain name that Stevens and Sodorov had. 220 00:21:32,540 --> 00:21:36,840 Sodorov then went ahead and shifted out the innocent content, replaced it with an intermediate 221 00:21:36,840 --> 00:21:43,120 certificate that could sign for anything, replaced it with a god cert, if you will. And because of the 222 00:21:43,120 --> 00:21:50,060 chosen prefix attack, the summary of the innocent version was equal to the summary of the god cert. 223 00:21:50,660 --> 00:21:57,560 Doing this also required some really interesting timing work to get the serial number of the CA also 224 00:21:58,060 --> 00:22:01,740 correctly predicted. Now, there's more where that came from. 225 00:22:02,540 --> 00:22:06,260 Finally, we can actually talk about the actual security data. There's more where this came from. 226 00:22:06,720 --> 00:22:12,240 Turns out X.509 is really, really fragile. At pretty much every depth that it's examined, 227 00:22:12,520 --> 00:22:16,920 pretty serious ambiguities and risks are found. Consider hashing functions. 228 00:22:17,960 --> 00:22:24,060 We all know at this point that MD5 is a valid signing algorithm for X.509 certificates. 229 00:22:25,320 --> 00:22:32,200 What you may not be aware of is that MD2 is also supported. MD2 is a predecessor function to 230 00:22:32,200 --> 00:22:39,900 MD5, now known to be even less secure than MD5. If a certificate happens to be signed with MD2 231 00:22:39,900 --> 00:22:47,060 RSA, everything except the new TLS will accept it. Now, this shouldn't matter. Stevens and 232 00:22:47,060 --> 00:22:52,920 Sodorov required a certificate authority to actively sign specially formed lobs with MD5 RSA 233 00:22:52,920 --> 00:23:00,520 in order to exploit the insecurity of MD5. There's nothing signing with MD2 RSA anymore. 234 00:23:00,680 --> 00:23:02,020 There hasn't been for like eight years. 235 00:23:02,200 --> 00:23:10,320 so everything should be okay, right? Well, I have a theory. I call it the final destination 236 00:23:10,320 --> 00:23:15,320 theory of cryptographic vulnerabilities. Now, here's how it works. Crypto-vulns tend to be 237 00:23:15,320 --> 00:23:20,660 subtle, telegraphed years, maybe even decades in advance. We don't know when they'll burn us. 238 00:23:20,800 --> 00:23:26,240 We don't know how they'll burn us. We're pretty sure we're going to get burned. It'll probably 239 00:23:26,240 --> 00:23:36,240 be epic. Thus, final destination. So, we'll begin by taking a look at this. It turns out one of 240 00:23:36,240 --> 00:23:43,400 VeriSign's core root certificates is actually self-signed with MD2. Really? 241 00:23:54,680 --> 00:23:55,960 It was 242 00:23:55,960 --> 00:23:56,220 1912. 243 00:23:56,240 --> 00:23:58,840 1996. We were young. We needed the bits. 244 00:24:03,140 --> 00:24:05,840 We really didn't do security very well in the 90s. 245 00:24:09,760 --> 00:24:14,480 Let's talk about why this matters, because this is not obviously going to lead to a problem. 246 00:24:15,520 --> 00:24:20,100 This is a self-signature. This is a self-signature in a root certificate. 247 00:24:20,500 --> 00:24:25,920 The signature means nothing, or at least approximately nothing. Len Sassman 248 00:24:25,920 --> 00:24:32,220 and I have an argument about whether it actually means nothing. But here's the deal. In normal X509, 249 00:24:32,340 --> 00:24:38,240 your public key and subject name are signed because by somebody else. This is an assertion by 250 00:24:38,240 --> 00:24:43,920 somebody else that you have a particular identity. When you have a self-signed signature, you're 251 00:24:43,920 --> 00:24:53,500 saying, I am me, and I can prove it because I say I am me. This means nothing. This has no actual 252 00:24:53,500 --> 00:24:54,900 security implication. 253 00:24:54,900 --> 00:25:03,600 The only reason I think this is there is because parsing libraries from the 90s really wanted to see a certificate there. 254 00:25:03,820 --> 00:25:09,780 And so they put one there. Why sign with MD2? 255 00:25:10,620 --> 00:25:13,440 Turns out it was the 90s. 256 00:25:15,360 --> 00:25:20,380 According to Peter Guttman, it may have just been that was the only thing they could get their magic hardware 257 00:25:20,380 --> 00:25:23,300 to do, thus proving the general rule of hardware. Hardware sucks. 258 00:25:23,940 --> 00:25:24,460 Anyway, 259 00:25:24,480 --> 00:25:24,880 uh, 260 00:25:24,880 --> 00:25:31,740 Uh, RC2313 actually says, uh, MD2 is the slowest of the three, and thus the most conservative. 261 00:25:32,100 --> 00:25:37,780 Um, not exactly what it's saying, but it's pretty close to, if it's slow, that means 262 00:25:37,780 --> 00:25:46,080 it must be secure. So, on the subject of insecure hashes, there are many ways a hash can fail. 263 00:25:46,380 --> 00:25:51,180 There's collision attacks, where you can generate two things immediately that have the same 264 00:25:51,180 --> 00:25:56,140 hash. That happened in 2005. This is what Xiaoyun Wang did. There were the chosen prefix 265 00:25:56,140 --> 00:26:02,300 collisions, creating something that, when appended to two things with different hashes, causes 266 00:26:02,300 --> 00:26:07,600 them to have the same hash. This is what Stevenson-Sodorov did, and, uh, worked very well. 267 00:26:08,660 --> 00:26:14,400 There's a third class of attack, and this is called pre-image attacks. Pre-image attacks say, 268 00:26:14,540 --> 00:26:21,160 given a hash, create something new with that hash. In other words, how do you create a hash 269 00:26:21,180 --> 00:26:26,360 by? I've got this summary from 1996. Uh, create something with this exact same summary. 270 00:26:27,120 --> 00:26:31,500 Xiaoyun, you can't do this, at least with no attacks that are being found. MD5, you 271 00:26:31,500 --> 00:26:37,680 can't do this. MD4, you can't do this. MD2 is, uh, starting to be another story. 272 00:26:38,960 --> 00:26:44,320 Here's what you do. This is the actual implicate, implementation of the attack. You generate 273 00:26:44,320 --> 00:26:50,240 the god cert. You generate a new intermediate certificate that can sign for anything. That's 274 00:26:50,240 --> 00:26:51,160 nice. You know, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, it's, 275 00:26:51,160 --> 00:26:55,020 It's something, it's gotta be chained back to a root. Something has to assert it is valid, 276 00:26:55,260 --> 00:26:59,740 or the fact that it's a god's cert means nothing, it's just a pile of bits. There's no meaning 277 00:26:59,740 --> 00:27:04,700 attached. Well, what we're gonna do is we're gonna give our intermediate certificate the 278 00:27:04,700 --> 00:27:14,040 same MD2 hash as the actual root. That means we can take the self-signature on the root, 279 00:27:14,280 --> 00:27:20,180 the self-signature that has at least almost no legitimate reason to be there. And we can 280 00:27:20,180 --> 00:27:21,140 give it a year. 281 00:27:21,140 --> 00:27:25,600 use. We can make it the signature on our faked 282 00:27:25,600 --> 00:27:32,680 intermediate. We can make it better. So now the intermediate 283 00:27:32,680 --> 00:27:35,480 appears to be signed by the root. It has the root signature 284 00:27:35,480 --> 00:27:39,260 across the same MD2 hash. You have two certificates in the row 285 00:27:39,660 --> 00:27:43,880 with the same signature in the same hash. Works very well. Does 286 00:27:43,880 --> 00:27:47,780 depend on there actually being an MD2 preimage attack. Is there 287 00:27:47,780 --> 00:27:53,440 one? There will be. In 2004, the complexity of doing this was 288 00:27:53,440 --> 00:27:57,220 2 to the 104. In 2005, the complexity of doing this was 2 289 00:27:57,220 --> 00:28:01,540 to the 97. In 2008, Soren S. Thompson found an attack with 2 290 00:28:01,540 --> 00:28:06,120 to the 73 complexity. Now, our best computations right now are 291 00:28:06,120 --> 00:28:10,760 around 2 to the 63 complexity. There's a trend going on. I 292 00:28:10,760 --> 00:28:13,320 actually went ahead and visualized the trend. 293 00:28:18,640 --> 00:28:23,320 We have two options. We can wait as we always do in 294 00:28:23,320 --> 00:28:28,760 cryptography until it absolutely blows up in our face. Or we can 295 00:28:28,760 --> 00:28:31,740 actually do something about a cryptographic vulnerability 296 00:28:32,620 --> 00:28:38,560 before it fails on us for the first time in history. Yeah, 297 00:28:38,640 --> 00:28:42,860 we've got it. So went ahead, talked to a bunch of vendors, 298 00:28:42,980 --> 00:28:46,460 and was like, guys, come on. We're all a little embarrassed 299 00:28:46,460 --> 00:28:47,760 about this whole MD4 thing. We're all a little embarrassed 300 00:28:47,780 --> 00:28:49,780 about this whole MD5 still being used thing. How about we at least 301 00:28:49,780 --> 00:28:55,240 kill MD2? I said, okay. So open SSL, it's dead. It's out of 1.0 302 00:28:55,240 --> 00:28:59,760 beta 3 for certificate validation. 098 CVS has it also 303 00:28:59,760 --> 00:29:03,380 disabled. The 098 from August will also have it just 304 00:29:03,380 --> 00:29:07,500 completely out. NSS, the crypto core of Firefox, this is already 305 00:29:07,500 --> 00:29:12,800 dead in Firefox 3.5. It's part of their 3.12.3 library. So 306 00:29:12,800 --> 00:29:17,760 that's good. Firefox 3.0 is getting fixed soon. It's 307 00:29:17,780 --> 00:29:21,240 some point in the next couple months, maybe. Red Hat has 308 00:29:21,240 --> 00:29:23,800 already updated their operating system with the latest NSS as 309 00:29:23,800 --> 00:29:27,260 well. VeriSign, they're on board. They're going ahead and 310 00:29:27,260 --> 00:29:29,920 they're reissuing that certificate with a SHA-1 self 311 00:29:29,920 --> 00:29:33,720 signature. Nothing's using the self signature, but hey, at 312 00:29:33,720 --> 00:29:36,860 least we can get rid of MD2 finally. Opera is waiting on 313 00:29:36,860 --> 00:29:40,360 VeriSign. Apple, Microsoft, they are testing their fixes. Google 314 00:29:40,360 --> 00:29:46,140 has Android disabling MD2. And GNU TLS got rid of MD2 years ago, 315 00:29:46,220 --> 00:29:47,180 so they are just laughing. 316 00:29:49,240 --> 00:29:57,000 Open source, suckers. Now, we get to do some really, really 317 00:29:57,000 --> 00:30:01,080 messy things with this particular compromise. When this 318 00:30:01,080 --> 00:30:05,660 hits, this particular root certificate has the client 319 00:30:05,660 --> 00:30:11,380 authentication extended key use. SSL normally is used to 320 00:30:11,380 --> 00:30:14,420 authenticate a server to a client. But for very high 321 00:30:14,420 --> 00:30:17,760 security applications, SSL can authenticate a client to a 322 00:30:17,760 --> 00:30:23,420 server. This particular root has the capability of being the 323 00:30:23,420 --> 00:30:26,600 trusted root behind such authentication. So what that 324 00:30:26,600 --> 00:30:30,700 means is, is that you can basically say, yeah, my user 325 00:30:30,700 --> 00:30:34,240 name is anyone, and just get in. Just let me in because my fake 326 00:30:34,240 --> 00:30:37,740 root says so. Now, you might say, but Dan, no web server 327 00:30:37,740 --> 00:30:40,060 would ever trust this random VeriSign root for 328 00:30:40,060 --> 00:30:44,720 authentication. Actually, by default, Microsoft IIS trusts 329 00:30:44,720 --> 00:30:47,740 this random root for authentication. And that's a 330 00:30:47,760 --> 00:30:51,460 good thing. You can ask. Go up to IIS, use the open SSL as 331 00:30:51,460 --> 00:30:55,940 client tool, and if it has client authentication enabled, you 332 00:30:55,940 --> 00:31:00,220 will get this dumped at you. This is a list of CAs that are 333 00:31:00,220 --> 00:31:04,280 allowed to assert arbitrary identities. So the class three 334 00:31:04,280 --> 00:31:07,320 public primary certificate authority is actually on this 335 00:31:07,320 --> 00:31:11,760 list. Remember what I said about exclusion? It doesn't matter how 336 00:31:11,760 --> 00:31:16,260 ridiculous your own CAs policies are. It only matters how 337 00:31:16,260 --> 00:31:17,740 ridiculous the weakening of your own CAs policies are. It only 338 00:31:17,760 --> 00:31:19,360 matters how ridiculous the weakest of the CAs are on the 339 00:31:19,360 --> 00:31:23,860 list. Any of this, these CAs can actually do authentication to 340 00:31:23,860 --> 00:31:27,140 this particular host. And if we actually compromise, when we get 341 00:31:27,140 --> 00:31:30,340 our pre-image attack working, this will be part of the list. 342 00:31:31,820 --> 00:31:37,520 This was not a capability we had with the MD5 certificate. Now, 343 00:31:37,540 --> 00:31:42,080 granted, the MD5 certificate actually exists. But, you know, 344 00:31:42,080 --> 00:31:46,680 it actually cannot operate as a client authenticator. Now, I'm 345 00:31:46,680 --> 00:31:47,740 kind of picking on VeriSign. I think it's a little bit more 346 00:31:47,760 --> 00:31:48,980 interesting than VeriSign by pointing out their root 347 00:31:48,980 --> 00:31:52,920 certificate. It is funny to see MD2 in your root store. But 348 00:31:52,920 --> 00:31:57,640 VeriSign was not the only company using MD2 RSA. Lots of 349 00:31:57,640 --> 00:32:02,020 companies were using it up to, like, 2000 or 2001. Now, all the 350 00:32:02,020 --> 00:32:09,680 certificates have expired by now. But that doesn't matter. As 351 00:32:09,680 --> 00:32:12,780 Stevens and Sodorov showed, if you can alter a certificate, you 352 00:32:12,780 --> 00:32:17,320 can change the expiration date. So it works fine. So it doesn't 353 00:32:17,320 --> 00:32:17,560 matter. 354 00:32:17,760 --> 00:32:21,180 They've expired. But it does matter that they're gone. You know, 355 00:32:21,220 --> 00:32:24,200 it's been, like, eight years since anything has actually used this. 356 00:32:24,600 --> 00:32:31,100 There's not many left. There's one MD2 root that I found that is 357 00:32:31,100 --> 00:32:35,920 kind of epic. And most of you are not gonna have any idea why this 358 00:32:35,920 --> 00:32:39,280 is awesome. But those of you that do will know exactly why. 359 00:32:48,260 --> 00:32:53,580 Rubicon. This is not Rubicon. This is not. So there was, a few 360 00:32:53,580 --> 00:32:58,640 years back, one conference. One conference where the attendees, 361 00:32:58,860 --> 00:33:01,320 one hacker conference where the attendees were led out with their 362 00:33:01,320 --> 00:33:05,500 hands behind their back. That conference was Rubicon. It is 363 00:33:05,500 --> 00:33:09,140 rather amusing that that was the only, one of the few MD2 certs 364 00:33:09,140 --> 00:33:12,740 that I found that can still be used. So does this need to be 365 00:33:12,740 --> 00:33:16,200 fixed immediately? No. It needs to be addressed. But we don't need 366 00:33:16,200 --> 00:33:17,740 to panic. I went to talk to Buechner's office. He said, hey, 367 00:33:17,740 --> 00:33:21,580 Bart Pernille over at the University of Leuven. He's Len Sassman's advisor. Len was working 368 00:33:21,580 --> 00:33:24,300 with me at the beginning of this and has been a great support throughout. 369 00:33:26,980 --> 00:33:31,720 So his response was, there's not likely to be a public pre-image attack of less than 370 00:33:31,720 --> 00:33:35,840 two to the 63 complexity within the next six months, even with this knowledge dispersed. 371 00:33:36,440 --> 00:33:41,200 So I said, cool. Told the companies, we don't need to pull the emergency sync button. Relax. 372 00:33:41,440 --> 00:33:45,180 Let's actually fix the bug, but we don't have to fix it in some kind of crazy thing 373 00:33:45,180 --> 00:33:49,700 like we did last year. I guess my friendly request, which would be kind of lame to do, 374 00:33:49,780 --> 00:33:54,220 but I'll do it anyway, please try not to break MD2 completely in the next six months. Is 375 00:33:54,220 --> 00:33:59,920 that even weighing? Please? It is an offline attack, though, so it's not the sort of thing 376 00:33:59,920 --> 00:34:04,800 that would actually lead to a lot of traffic showing up at certificate authorities. It 377 00:34:04,800 --> 00:34:12,980 can be done, you know, stick 20 grad students in a room for six months. So. Do you have 378 00:34:12,980 --> 00:34:13,580 something you need to say? 379 00:34:13,800 --> 00:34:14,040 No. 380 00:34:14,040 --> 00:34:14,500 Oh. 381 00:34:14,620 --> 00:34:17,440 There are SMIME deployments using MD2. 382 00:34:17,560 --> 00:34:18,160 Ah. 383 00:34:18,320 --> 00:34:18,860 . 384 00:34:19,980 --> 00:34:24,180 Apparently there are, MD2 shows up in SMIME email encryption. 385 00:34:24,600 --> 00:34:27,360 The other certificate party was having . 386 00:34:30,500 --> 00:34:36,400 Ouch. Crap. Okay. I'm going to drink for them. 387 00:34:39,340 --> 00:34:40,160 All right. 388 00:34:41,060 --> 00:34:41,740 So. 389 00:34:44,200 --> 00:34:48,980 Manipulating existing certificate authorities. How do we do that? The MD2 attack has no link 390 00:34:48,980 --> 00:34:54,100 to present day certificate authority operations. VeriSign has not done anything operationally 391 00:34:54,100 --> 00:35:00,120 with MD2 for years. Is it possible to bypass protections in present day certificate authority 392 00:35:00,120 --> 00:35:06,600 operations? Well, you got to consider this is the quote that actually spawned this entire 393 00:35:06,600 --> 00:35:12,520 talk. From Meredith L. Patterson. I'm going to go home and figure out the precise grammar 394 00:35:12,520 --> 00:35:14,020 of a certificate and see just what it is. I'm going to go home and figure out the precise 395 00:35:14,020 --> 00:35:18,500 grammar of a certificate and see just what I can put in there. I'm like, that's a very 396 00:35:18,920 --> 00:35:23,480 interesting thing you just said to me, Meredith. Because there are two kinds of parsing vulnerabilities. 397 00:35:24,040 --> 00:35:27,540 There are those that cause the system to misuse memory. Those would be your traditional 398 00:35:27,540 --> 00:35:32,920 exploits. And then there are system, there are bugs that cause a system to parse a different 399 00:35:32,920 --> 00:35:38,080 message than was intended. Those would be what we call semantic exploits. It doesn't crash. 400 00:35:38,380 --> 00:35:44,000 It just reads the wrong thing. Now, you've got to realize there's some semantics going on in this. 401 00:35:44,000 --> 00:35:47,960 I'm going to go back to this one here with a certificate. A certificate authority and a browser 402 00:35:47,960 --> 00:35:54,720 are talking to one another. They are saying, the CA is saying, browser, I tell you that this 403 00:35:54,720 --> 00:36:00,180 public key is linked to that subject name. And the browser has to hear, CA, I hear that this 404 00:36:00,180 --> 00:36:06,940 public key is linked to this subject name, and it has to be the same name. What if it isn't? That 405 00:36:06,940 --> 00:36:11,580 would be bad. That would mean a CA would assert one name and the browser would see another. So 406 00:36:11,580 --> 00:36:16,820 how do we know that what the CA says is what the browser hears? Well, there is a field called 407 00:36:16,820 --> 00:36:21,840 language theoretic security that attempts to explore this sort of semantic question. This is 408 00:36:21,840 --> 00:36:28,320 formalized by the other guys on this talk, Patterson and Sassman. And it describes how to build 409 00:36:28,320 --> 00:36:33,560 parsers that will always parse the same message in the same way. Now, I know you're thinking, 410 00:36:34,280 --> 00:36:40,500 shouldn't we just be able to take this for granted? How much code is different, how much does 411 00:36:40,500 --> 00:36:46,280 code become different in C when you pipe it into different C compilers? Same kind of crap. Same 412 00:36:46,280 --> 00:36:53,300 message, different parse tree, different output. This work was actually first used in 2005. They 413 00:36:53,300 --> 00:36:58,460 actually built a system called Dejector for eliminating or at least dramatically reducing 414 00:36:58,460 --> 00:37:04,360 SQL injection attacks. X509 was developed a long time before such formal validation models. 415 00:37:05,260 --> 00:37:09,580 And it shows. So let's walk through the CA pipeline. 416 00:37:10,500 --> 00:37:17,380 The user generates their public and private key, submits it in the PKCS 10 certificates signing 417 00:37:17,380 --> 00:37:23,080 request. Now, there's lots of crap in this request. There's a country, a state, a city, an 418 00:37:23,080 --> 00:37:28,580 organization, an organizational unit. The only thing the browser cares about is the CN, the 419 00:37:28,580 --> 00:37:35,040 common name. If a CA approves of a common name, it can do one of two things. It can do the more 420 00:37:35,040 --> 00:37:40,040 secure thing where it generates a certificate with only the elements that have actually been 421 00:37:40,040 --> 00:37:46,440 validated. So by actually making the DNS request. This is what's called scrubbing. And that 422 00:37:46,440 --> 00:37:52,580 would be the secure thing to do. The easy thing to do is to just say, okay, everything looks good 423 00:37:52,580 --> 00:37:58,240 and sign the subject name as it sits. This is actually what OpenSSL makes very, very natural. 424 00:37:58,800 --> 00:38:06,300 There are three ways of using OpenSSL to build a CA. You can simply sign whatever request comes in 425 00:38:06,300 --> 00:38:10,020 and then see if you like the output. And they actually, from their command line, they actually 426 00:38:10,040 --> 00:38:15,520 will output a nice string for you to audit. You can dump the request to text and then parse that. 427 00:38:16,060 --> 00:38:21,920 And that goes ahead and has its nice line that you parse with the subject. Or you can go ahead 428 00:38:21,920 --> 00:38:27,900 and dump the generated certificate and then see, you know, here's your CN and see if you like 429 00:38:27,900 --> 00:38:34,720 that. Now, there's a pretty obvious thing you can do straight out, which is, well, there are 430 00:38:34,720 --> 00:38:39,960 strings. We can just inject the appropriate strings to make it look like a new CN is there. 431 00:38:40,040 --> 00:38:45,840 So this is the organization string, organization name, and then we're going to have it have the 432 00:38:45,840 --> 00:38:51,980 printable string bad guy ink slash CN equals www.badguy.com. So now, when the 433 00:38:51,980 --> 00:38:57,960 CA does their dump, what they get is signature okay, subject equals O equals bad guy 434 00:38:57,960 --> 00:39:03,600 ink, and then this injected slash CN equals www.badguy.com. Now, 435 00:39:03,680 --> 00:39:09,960 OpenSSL has four modes for emitting text. It is clearly meant to have its text process 436 00:39:10,040 --> 00:39:14,420 accessed. All of the non-default modes are secure. 437 00:39:23,040 --> 00:39:28,200 So, now, the exploitability depends on how the text auditor is actually handling its 438 00:39:28,200 --> 00:39:33,900 Now, one thing you might notice is that we have a couple CNs here. We have the injected CN, 439 00:39:34,120 --> 00:39:38,060 which came first, and we have this real CN, the bank CN. 440 00:39:40,040 --> 00:39:44,380 This is an interesting question. What does the parser do when there are multiple CNs? 441 00:39:44,440 --> 00:39:50,620 This isn't just a question for what the text parser does. This is a completely valid question 442 00:39:50,620 --> 00:39:56,940 for what happens if you submit a PKCS10 request with multiple common names, and that gets 443 00:39:56,940 --> 00:40:04,900 through to a client. That's a really good question, because literally every possible thing has 444 00:40:04,900 --> 00:40:05,520 been implemented. 445 00:40:08,020 --> 00:40:09,360 OpenSSL will give you the first one. 446 00:40:11,560 --> 00:40:12,680 IE will take them all. 447 00:40:14,540 --> 00:40:16,020 Firefox takes the last one. 448 00:40:17,840 --> 00:40:21,380 First, all inclusive. Last, fail. 449 00:40:23,780 --> 00:40:26,740 So, what, of course, should the correct policy be? 450 00:40:27,020 --> 00:40:33,540 Well, this is wonderful. If you go to the RFCs, and people were scrubbing through the RFCs for, like, weeks, 451 00:40:33,540 --> 00:40:36,900 they finally found one RFC that specified correct behavior. 452 00:40:37,480 --> 00:40:40,700 In parentheses, most specific. 453 00:40:41,380 --> 00:40:45,460 They don't actually define most specific anywhere in the RFCs, 454 00:40:45,460 --> 00:40:47,000 but they do say the words most specific. 455 00:40:48,000 --> 00:40:48,740 So, 456 00:40:49,290 --> 00:40:50,820 I said OpenSSL 457 00:40:51,510 --> 00:40:53,580 usually gives you the first 458 00:40:53,580 --> 00:40:54,100 CN. 459 00:40:55,200 --> 00:40:56,660 It doesn't have to. 460 00:40:56,780 --> 00:40:59,380 The OpenSSL developers realized 461 00:40:59,380 --> 00:41:01,340 the situation, and 462 00:41:01,340 --> 00:41:03,500 they went ahead and made the 463 00:41:03,540 --> 00:41:05,620 API such that you could run it in a loop 464 00:41:05,620 --> 00:41:07,280 in this particular manner, 465 00:41:07,460 --> 00:41:09,160 and it would give you each 466 00:41:09,160 --> 00:41:11,460 common name until it exhausted. 467 00:41:12,160 --> 00:41:12,740 However, 468 00:41:12,960 --> 00:41:14,960 nobody actually uses this API. 469 00:41:15,400 --> 00:41:17,300 Everyone just calls X509 470 00:41:17,940 --> 00:41:18,520 getTextByNid. 471 00:41:18,680 --> 00:41:21,160 You see this in every project that we looked at. 472 00:41:21,320 --> 00:41:23,440 Claws, Open1x, Wget, Bacula, 473 00:41:23,540 --> 00:41:24,500 Neon, OpenLDAP. 474 00:41:24,660 --> 00:41:27,560 Any CA that was based on using X509 475 00:41:27,560 --> 00:41:28,980 name getTextByNid 476 00:41:28,980 --> 00:41:31,000 would only see and would only validate 477 00:41:31,000 --> 00:41:32,320 the first common name. 478 00:41:33,600 --> 00:41:34,900 So what would you do with this? 479 00:41:35,560 --> 00:41:36,000 Well, 480 00:41:36,760 --> 00:41:37,920 we'd want wildcards, 481 00:41:38,180 --> 00:41:41,100 but there's an interesting limitation with wildcards. 482 00:41:42,160 --> 00:41:42,940 Netscape says 483 00:41:42,940 --> 00:41:44,780 if I see a cert with a star, 484 00:41:45,000 --> 00:41:47,400 cool, the certificate is valid for every name 485 00:41:47,400 --> 00:41:47,840 in the world. 486 00:41:48,560 --> 00:41:49,740 Internet Explorer says 487 00:41:50,260 --> 00:41:52,620 I'm pretty sure if I see a certificate with a star, 488 00:41:52,880 --> 00:41:55,400 the certificate authority was probably hacked. 489 00:41:55,520 --> 00:41:57,320 I'm just chicken. I'm not gonna do it. 490 00:41:57,920 --> 00:41:58,400 So, 491 00:41:59,480 --> 00:42:00,440 what you have to, 492 00:42:00,480 --> 00:42:03,080 it will allow a star, but it wants a couple labels first. 493 00:42:03,540 --> 00:42:04,900 You can get star.docspero.com, 494 00:42:05,060 --> 00:42:06,580 but you can't get just star. 495 00:42:07,400 --> 00:42:09,140 So what you would have is you would have a 496 00:42:09,140 --> 00:42:10,980 PKCS10 request with three labels. 497 00:42:11,420 --> 00:42:12,980 The first CN is for 498 00:42:12,980 --> 00:42:14,560 www.attacker.com. 499 00:42:14,780 --> 00:42:16,520 That's for the CA to see and validate. 500 00:42:16,740 --> 00:42:18,620 Because they'll send attacker.com an email 501 00:42:18,620 --> 00:42:20,740 and attacker owns attacker.com. 502 00:42:20,860 --> 00:42:21,200 So it's great. 503 00:42:22,120 --> 00:42:24,540 Second one will be www.bank.com. 504 00:42:24,780 --> 00:42:26,500 Specify a particularly interesting target. 505 00:42:26,720 --> 00:42:28,240 And IE gets to see that. 506 00:42:28,480 --> 00:42:30,060 And the third one will just be the star. 507 00:42:30,060 --> 00:42:31,540 And that will be what Netscape gets. 508 00:42:34,000 --> 00:42:34,560 So, 509 00:42:34,660 --> 00:42:36,400 what is a CN anyway? 510 00:42:38,120 --> 00:42:39,880 X509 is written to a specification 511 00:42:39,880 --> 00:42:41,140 called ASN1, 512 00:42:41,380 --> 00:42:43,300 which I'm pretty sure was designed to make 513 00:42:43,300 --> 00:42:44,120 small puppies cry. 514 00:42:47,740 --> 00:42:50,060 It's designed to be very fast to parse. 515 00:42:50,280 --> 00:42:51,900 It's actually very fast to 516 00:42:51,900 --> 00:42:53,080 crash under fuzzing. 517 00:42:54,800 --> 00:42:55,740 2002, the 518 00:42:55,740 --> 00:42:57,120 ProDos project actually 519 00:42:58,000 --> 00:42:59,600 fuzzed SNMP and 520 00:43:00,060 --> 00:43:01,480 pretty much destroyed every router 521 00:43:01,480 --> 00:43:02,540 on the planet. 522 00:43:03,820 --> 00:43:05,940 Now I will say, every certificate authority 523 00:43:05,940 --> 00:43:08,060 has an ASN1 listener 524 00:43:08,060 --> 00:43:10,280 listening publicly and anonymously 525 00:43:10,280 --> 00:43:11,520 via PKCS10. 526 00:43:12,320 --> 00:43:13,160 Ideally, 527 00:43:13,800 --> 00:43:16,020 they're all built on ASN1 528 00:43:16,020 --> 00:43:17,160 stacks that 529 00:43:17,800 --> 00:43:19,880 got hardened back when 530 00:43:19,880 --> 00:43:20,240 we hardened 531 00:43:20,240 --> 00:43:23,480 back when we dealt with 532 00:43:23,480 --> 00:43:24,760 all the SNMP vulnerabilities. 533 00:43:26,180 --> 00:43:27,020 Ideally. 534 00:43:28,440 --> 00:43:29,820 People have been 535 00:43:30,060 --> 00:43:31,140 warned, but we are a little worried 536 00:43:31,140 --> 00:43:32,520 about just fuzzing against 537 00:43:32,520 --> 00:43:33,880 ASN1 stacks here. 538 00:43:36,100 --> 00:43:36,960 This is cool. 539 00:43:38,440 --> 00:43:39,660 One of the other things 540 00:43:39,660 --> 00:43:41,580 that can, one of the other things 541 00:43:41,580 --> 00:43:43,360 that can happen with any sort of 542 00:43:43,360 --> 00:43:44,260 text injection layer 543 00:43:45,420 --> 00:43:46,720 is SQL injection. 544 00:43:47,120 --> 00:43:49,420 This stuff is put into a database and we work on it. 545 00:43:49,880 --> 00:43:51,700 It turns out the CAs figured 546 00:43:51,700 --> 00:43:52,780 this out a few years ago. 547 00:43:53,320 --> 00:43:55,400 Quite literally, because of little 548 00:43:55,400 --> 00:43:56,360 Bobby Tables, 549 00:43:58,420 --> 00:43:59,380 XKCD actually 550 00:44:00,060 --> 00:44:01,100 secure a bit of the internet. 551 00:44:01,740 --> 00:44:02,280 Awesome. 552 00:44:08,380 --> 00:44:09,960 Apparently after little Bobby 553 00:44:09,960 --> 00:44:11,920 Tables came out, a lot of people were introduced 554 00:44:11,920 --> 00:44:13,700 to SQL injection by that 555 00:44:13,700 --> 00:44:15,380 comic strip and the 556 00:44:15,810 --> 00:44:17,280 certificate authority guys were like, 557 00:44:17,420 --> 00:44:19,920 you know, we could totally get 558 00:44:19,920 --> 00:44:21,360 something with a common name of 559 00:44:21,360 --> 00:44:23,480 drop the entire certificate database. 560 00:44:24,200 --> 00:44:26,020 We should do something about that. 561 00:44:27,980 --> 00:44:29,440 I thought that was kind of cool. 562 00:44:30,060 --> 00:44:30,580 Let's go to XKCD. 563 00:44:32,040 --> 00:44:33,660 Now, this is cool. 564 00:44:33,940 --> 00:44:36,020 In ASN1, common 565 00:44:36,020 --> 00:44:37,840 name, that's the nice 566 00:44:37,840 --> 00:44:39,520 handle, that's what we speak as English 567 00:44:39,520 --> 00:44:41,920 speakers, but language is 568 00:44:41,920 --> 00:44:42,840 hard and 569 00:44:44,180 --> 00:44:45,440 localization is difficult. 570 00:44:45,700 --> 00:44:46,720 Not everyone knows 571 00:44:46,720 --> 00:44:49,680 what common name means if you're a Chinese 572 00:44:49,680 --> 00:44:51,240 speaker, you have no idea. 573 00:44:51,780 --> 00:44:53,800 So what ASN1 does is it 574 00:44:53,800 --> 00:44:55,540 actually has all of these what are called 575 00:44:55,540 --> 00:44:57,460 object identifiers identified 576 00:44:57,460 --> 00:44:59,820 by number. So say, instead of 577 00:45:00,060 --> 00:45:02,360 common name, it's 2.5.4.3. 578 00:45:02,540 --> 00:45:03,880 It's a hierarchical 579 00:45:03,880 --> 00:45:05,940 namespace. Now, what does 580 00:45:05,940 --> 00:45:07,920 this actually look like on the 581 00:45:07,920 --> 00:45:09,540 wire? What are the actual bytes? 582 00:45:10,100 --> 00:45:11,780 Well, there's something called ASN1 583 00:45:11,780 --> 00:45:13,880 BER, basic encoding rules. 584 00:45:14,340 --> 00:45:16,000 And this is a tag length 585 00:45:16,000 --> 00:45:17,900 value file format. Very 586 00:45:17,900 --> 00:45:19,900 simple introduction. You have an OID, 587 00:45:20,100 --> 00:45:21,580 which means your first byte is 6. 588 00:45:22,620 --> 00:45:23,180 And 589 00:45:24,300 --> 00:45:26,020 basically, so if you have 590 00:45:26,020 --> 00:45:27,680 a tag, 591 00:45:27,840 --> 00:45:28,360 6, 592 00:45:30,060 --> 00:45:31,620 length, some number of bytes, 593 00:45:31,840 --> 00:45:34,120 and there are like three different ways of encoding the number of bytes 594 00:45:34,120 --> 00:45:35,660 because it's ASN1 and it hates you. 595 00:45:37,280 --> 00:45:38,140 The actual 596 00:45:38,140 --> 00:45:39,880 numbers are encoded 597 00:45:39,880 --> 00:45:40,740 in base 128. 598 00:45:41,740 --> 00:45:43,020 So this is how it works. 599 00:45:43,480 --> 00:45:45,860 If you have just a 06, that means 600 00:45:45,860 --> 00:45:47,980 the number is 6, and then there's a period after. 601 00:45:48,340 --> 00:45:49,360 If it's 86, 602 00:45:49,780 --> 00:45:51,880 it means the number is still 6, but this is 603 00:45:51,880 --> 00:45:54,160 one digit of a multi-digit 604 00:45:54,160 --> 00:45:55,740 number, with each digit being 605 00:45:55,740 --> 00:45:57,660 in base 128. So 606 00:45:57,660 --> 00:45:59,940 86 is 6, and there's another digit 607 00:46:00,060 --> 00:46:01,820 coming. And it's big endian if you're curious. 608 00:46:02,440 --> 00:46:04,080 So let's look at a simple 609 00:46:04,080 --> 00:46:05,700 OID. 2543 610 00:46:05,700 --> 00:46:08,040 is 6, which is the object identifier. 611 00:46:08,480 --> 00:46:10,000 3, length 3. 612 00:46:10,720 --> 00:46:12,040 25 is encoded as 613 00:46:12,040 --> 00:46:13,980 a 55 because they're trying to save a 614 00:46:13,980 --> 00:46:15,580 byte. And then 615 00:46:15,580 --> 00:46:17,980 4 is just 4, and 3 is 3. 616 00:46:18,240 --> 00:46:19,760 So 6, 3, 617 00:46:19,880 --> 00:46:21,980 55, 4, 3. Very nice, 618 00:46:22,120 --> 00:46:24,080 very simple. Get a little 619 00:46:24,080 --> 00:46:25,780 more complicated. Let's do 128 620 00:46:25,780 --> 00:46:28,080 40 113 549 111. 621 00:46:28,760 --> 00:46:29,920 That'd be RSA encryption. 622 00:46:30,560 --> 00:46:31,920 Okay, well, tag 623 00:46:31,920 --> 00:46:33,800 is 6, length is 9. 624 00:46:34,140 --> 00:46:35,780 Now you have a value of 625 00:46:35,780 --> 00:46:37,440 2a, which is 1.2. 626 00:46:38,380 --> 00:46:39,420 86, 48. 627 00:46:39,900 --> 00:46:41,660 Great summary of what's going on here. 628 00:46:41,940 --> 00:46:43,180 This is 6 times 128, 629 00:46:43,660 --> 00:46:46,020 so 86 minus 630 00:46:46,020 --> 00:46:47,800 80 is 6. So 631 00:46:47,800 --> 00:46:49,200 6 times 128 632 00:46:49,820 --> 00:46:52,080 plus 72 is 840. 633 00:46:52,280 --> 00:46:53,240 And there's the 840. 634 00:46:54,200 --> 00:46:56,080 And then we have the same for the big number, 635 00:46:56,180 --> 00:46:57,240 and we have three ones. 636 00:46:58,040 --> 00:46:59,860 So 06, 09, 2a, 637 00:47:00,060 --> 00:47:01,700 86, 48, 86, F7, OD, 638 00:47:01,820 --> 00:47:02,700 01, 01. 639 00:47:04,760 --> 00:47:05,920 01. I missed 640 00:47:05,920 --> 00:47:06,160 a 1. 641 00:47:08,820 --> 00:47:09,780 Subattacks. Leading 642 00:47:09,780 --> 00:47:11,880 zeros. One can have a 643 00:47:11,880 --> 00:47:13,400 tag of 6, a length of 3, 644 00:47:13,560 --> 00:47:15,440 and then 55, 04, 645 00:47:15,700 --> 00:47:17,400 and then instead of just 646 00:47:17,840 --> 00:47:19,680 3, we have 83, 647 00:47:20,220 --> 00:47:21,740 which is 0 times 648 00:47:21,740 --> 00:47:23,040 128 plus 3. 649 00:47:23,480 --> 00:47:24,920 So it's still 3. 650 00:47:25,800 --> 00:47:27,820 This has been seen before. We saw this in 651 00:47:27,820 --> 00:47:29,720 a few LDAP attacks. But 652 00:47:30,060 --> 00:47:31,740 suppose we actually had 653 00:47:31,740 --> 00:47:34,060 2.5.4.00003 654 00:47:34,760 --> 00:47:35,960 and then had that 655 00:47:35,960 --> 00:47:38,240 equal to www.bank.com. 656 00:47:38,960 --> 00:47:39,880 What would 657 00:47:39,880 --> 00:47:41,780 this actually be seen as 658 00:47:41,780 --> 00:47:42,740 a common name? 659 00:47:44,260 --> 00:47:45,800 OpenSSL tells us to go pound 660 00:47:45,800 --> 00:47:47,600 sand. It still 661 00:47:47,600 --> 00:47:49,540 actually does render out 2543, 662 00:47:49,880 --> 00:47:51,640 but it's a semi-collision. It 663 00:47:51,640 --> 00:47:53,760 does not actually resolve back 664 00:47:53,760 --> 00:47:55,840 to CN. So no text parser 665 00:47:55,840 --> 00:47:57,920 would actually see it as a common name. 666 00:47:59,260 --> 00:47:59,920 Next 667 00:48:00,060 --> 00:48:02,380 do an escape. Also sees 2543. 668 00:48:02,880 --> 00:48:04,660 Object identifier 2543. 669 00:48:05,020 --> 00:48:07,220 But it does not resolve that 670 00:48:07,220 --> 00:48:08,780 back to common name either. 671 00:48:10,380 --> 00:48:12,120 IE just sees the common name. 672 00:48:12,460 --> 00:48:13,020 Cool. 673 00:48:13,260 --> 00:48:15,680 So now we have multiple things that can be 674 00:48:15,680 --> 00:48:17,700 in an X509 common name that are 675 00:48:17,700 --> 00:48:19,560 valid that will be seen as 676 00:48:19,560 --> 00:48:21,620 the certificate authority making an 677 00:48:21,620 --> 00:48:24,140 assertion of browser domain identity. 678 00:48:24,800 --> 00:48:26,040 This is not the only way 679 00:48:26,040 --> 00:48:28,060 we can do this. Another thing we can do 680 00:48:28,060 --> 00:48:29,860 is do what's called a semantic integer 681 00:48:30,060 --> 00:48:31,940 overflow. Now integer 682 00:48:31,940 --> 00:48:34,100 overflows are one of the most common 683 00:48:34,100 --> 00:48:35,800 vulnerabilities in software 684 00:48:35,800 --> 00:48:38,080 today. Programmers tend to forget 685 00:48:38,080 --> 00:48:40,200 that if an arithmetic 686 00:48:40,200 --> 00:48:41,880 operation gets large enough, 687 00:48:42,040 --> 00:48:43,640 it will actually loop back to zero. 688 00:48:43,800 --> 00:48:45,560 Or loop back to the beginning. 689 00:48:46,180 --> 00:48:47,860 This is a common problem for 690 00:48:47,860 --> 00:48:49,980 memory allocation. You have 691 00:48:49,980 --> 00:48:52,040 situations where it's essentially, I need 692 00:48:52,040 --> 00:48:53,760 more memory, I need more memory, I need more memory. 693 00:48:54,000 --> 00:48:56,120 Eh, you know what, I don't actually need 694 00:48:56,120 --> 00:48:57,900 that much memory. And the 695 00:48:57,900 --> 00:48:59,720 rest of the system assumes it has some 696 00:49:00,060 --> 00:49:00,980 oddly amount of memory and 697 00:49:01,960 --> 00:49:02,680 everything fails. 698 00:49:04,300 --> 00:49:04,980 So 699 00:49:05,960 --> 00:49:07,840 we have an arithmetic operation. 700 00:49:08,240 --> 00:49:10,260 This is essentially what ASN1 701 00:49:10,260 --> 00:49:11,360 is doing with base 128. 702 00:49:11,960 --> 00:49:12,980 Multiplies and adds. 703 00:49:13,860 --> 00:49:15,780 What happens if we make it 704 00:49:15,780 --> 00:49:17,760 add past 2 to the 64? 705 00:49:18,140 --> 00:49:19,540 What happens if we have 706 00:49:19,760 --> 00:49:21,080 2.5.4. 707 00:49:22,300 --> 00:49:24,200 2 to the 64 plus 3? 708 00:49:24,820 --> 00:49:25,880 Well, what 709 00:49:25,880 --> 00:49:28,020 happens is OpenSSL 710 00:49:28,020 --> 00:49:29,740 has a big num library. 711 00:49:30,060 --> 00:49:31,540 It deals with it fine. 712 00:49:31,720 --> 00:49:33,720 It actually does not have a boundary 713 00:49:34,960 --> 00:49:36,000 enforced by 714 00:49:36,000 --> 00:49:36,240 hardware. 715 00:49:38,100 --> 00:49:39,140 Netscape overflows. 716 00:49:39,360 --> 00:49:41,700 But it overflows just like it overflowed 717 00:49:41,700 --> 00:49:42,840 with the leading zeros. 718 00:49:43,220 --> 00:49:45,560 It renders to 2.5.4.3, 719 00:49:45,720 --> 00:49:47,840 but it does not actually get rendered back to 720 00:49:47,840 --> 00:49:48,180 a CN. 721 00:49:50,080 --> 00:49:51,140 IE, you just win. 722 00:49:51,280 --> 00:49:53,780 You get another CN. So 2.5.4 723 00:49:53,780 --> 00:49:55,920 to the 64 plus 3 is another way 724 00:49:55,920 --> 00:49:57,060 of expressing common name. 725 00:49:57,060 --> 00:49:58,920 I want to point out one of the 726 00:49:58,920 --> 00:50:00,160 reasons we had 727 00:50:01,060 --> 00:50:03,020 ASN1 do it this way is because 728 00:50:03,020 --> 00:50:05,060 they didn't want to have to worry about canonicalization. 729 00:50:05,440 --> 00:50:06,620 They're like, look, there's 730 00:50:06,620 --> 00:50:09,000 uppercase common name, lowercase common name, 731 00:50:09,160 --> 00:50:10,820 all sorts of spaces and tabs. 732 00:50:11,060 --> 00:50:13,140 Why don't we just have a numeric 733 00:50:13,140 --> 00:50:14,840 representation of a number and that 734 00:50:14,840 --> 00:50:15,940 grammatically will be simple? 735 00:50:16,260 --> 00:50:18,380 Well, this implementation bug tends to 736 00:50:18,380 --> 00:50:19,660 throw that out the water. 737 00:50:20,860 --> 00:50:22,040 Now that being said, 738 00:50:22,540 --> 00:50:24,800 most CAs extract a common name and throw 739 00:50:24,800 --> 00:50:26,220 away the rest. Well, good. 740 00:50:27,060 --> 00:50:28,720 Is there anything malicious that we could get 741 00:50:28,720 --> 00:50:29,980 into a common name? 742 00:50:31,680 --> 00:50:32,940 Can't throw out my 743 00:50:32,940 --> 00:50:34,840 common name because that's actually what they're 744 00:50:34,840 --> 00:50:36,360 validating. Well, 745 00:50:36,860 --> 00:50:38,640 what's in a common name? You have 746 00:50:38,640 --> 00:50:40,740 an object identifier and a printable 747 00:50:40,740 --> 00:50:42,380 string. And strings are simple. 748 00:50:42,520 --> 00:50:44,780 It's a tag, 13, a length, 749 00:50:44,980 --> 00:50:46,960 some number of bytes, and then 750 00:50:46,960 --> 00:50:48,900 just simple ASCII text. 751 00:50:49,200 --> 00:50:50,740 What could be wrong with that? 752 00:50:51,140 --> 00:50:52,880 Well, it turns out 753 00:50:52,880 --> 00:50:54,880 there's 13 different forms of strings 754 00:50:54,880 --> 00:50:56,840 in ASN1, and you can use 755 00:50:57,060 --> 00:50:57,780 the other kinds. 756 00:50:58,940 --> 00:51:00,540 Two of the really interesting ones 757 00:51:00,540 --> 00:51:02,660 are BMP strings, which are 758 00:51:02,660 --> 00:51:04,480 a variant of UTF-16, 759 00:51:04,700 --> 00:51:06,920 a Unicode variant, or then there's 760 00:51:06,920 --> 00:51:09,040 Unicode string, which is 4-byte 761 00:51:09,040 --> 00:51:10,340 Unicode. It's UTF-32. 762 00:51:11,100 --> 00:51:13,200 That means, when I'm saying 2-byte and 4-byte, 763 00:51:13,220 --> 00:51:15,140 I mean saying 2 bytes per character 764 00:51:15,140 --> 00:51:16,320 or 4 bytes per character. 765 00:51:16,620 --> 00:51:19,100 Now, why is this interesting? Well, first off, 766 00:51:19,140 --> 00:51:20,760 there's a trivial readAV in 767 00:51:20,760 --> 00:51:22,760 OpenSSL's PKCS10 parser. 768 00:51:22,880 --> 00:51:24,800 There's nothing more fun than messing around with an 769 00:51:24,800 --> 00:51:27,040 ASN1 editor by hand and then seeing 770 00:51:27,060 --> 00:51:27,880 oh, well, 771 00:51:28,540 --> 00:51:31,120 it just crashed. I wonder if this is exploitable. 772 00:51:31,860 --> 00:51:32,900 Turns out it's not. 773 00:51:33,080 --> 00:51:34,100 But here's what was happening. 774 00:51:34,580 --> 00:51:37,260 They were saying, we are going to advance 775 00:51:37,260 --> 00:51:38,060 through this string 776 00:51:39,720 --> 00:51:40,900 until we hit 777 00:51:40,900 --> 00:51:42,520 the exact byte where 778 00:51:42,860 --> 00:51:44,060 we are at the end of the string. 779 00:51:44,520 --> 00:51:47,440 And then if they had a 4-byte 780 00:51:47,440 --> 00:51:49,020 character, they would advance 781 00:51:49,020 --> 00:51:50,140 4 bytes. 782 00:51:51,180 --> 00:51:53,000 So what this meant is, let's say 783 00:51:53,000 --> 00:51:54,960 your string was not actually a multiple 784 00:51:54,960 --> 00:51:55,700 of 4. 785 00:51:57,060 --> 00:51:58,920 They would want to terminate on the 8th byte, 786 00:51:59,040 --> 00:52:00,480 but there's only, you know, 787 00:52:00,520 --> 00:52:01,580 7 bytes in there. 788 00:52:01,860 --> 00:52:04,040 Or, what is it? 789 00:52:04,180 --> 00:52:05,580 You basically missed the 790 00:52:07,060 --> 00:52:07,960 terminator. Excuse me. 791 00:52:08,020 --> 00:52:09,480 Little tired, need to drink. 792 00:52:13,480 --> 00:52:14,760 It's not actually exploitable. 793 00:52:15,060 --> 00:52:16,920 You miss the terminator, 794 00:52:17,000 --> 00:52:18,800 but you don't actually write any 795 00:52:18,800 --> 00:52:21,100 memory after missing the terminator. 796 00:52:21,180 --> 00:52:22,820 So it just reads off into a guard page 797 00:52:22,820 --> 00:52:23,860 and you have no fun. 798 00:52:26,440 --> 00:52:26,880 Ah. 799 00:52:27,800 --> 00:52:28,280 Now, 800 00:52:28,880 --> 00:52:29,840 fun with printable strings. 801 00:52:30,840 --> 00:52:32,680 There are two ways of ending a string 802 00:52:32,680 --> 00:52:33,140 with text. 803 00:52:34,780 --> 00:52:36,360 You can have an explicit length field, 804 00:52:36,480 --> 00:52:37,700 which ASN1 has. 805 00:52:37,960 --> 00:52:40,500 Or you can have a null terminator. 806 00:52:40,980 --> 00:52:41,460 OXOO. 807 00:52:42,140 --> 00:52:44,560 So-called C-strings use null terminators 808 00:52:44,560 --> 00:52:45,140 at the end of them. 809 00:52:45,920 --> 00:52:48,260 What happens when you put a null terminator 810 00:52:48,260 --> 00:52:49,140 into a common name? 811 00:52:51,280 --> 00:52:52,760 OpenSSL deals with it fine. 812 00:52:52,980 --> 00:52:54,380 It actually converts that null 813 00:52:54,380 --> 00:52:55,940 into backslash XOO. 814 00:52:56,660 --> 00:52:58,120 So you end up with, say, 815 00:52:58,260 --> 00:53:00,380 www.defcon.org 816 00:53:02,120 --> 00:53:02,720 backslash 817 00:53:02,720 --> 00:53:03,740 X00WW 818 00:53:05,120 --> 00:53:06,220 .oxoo.com 819 00:53:06,220 --> 00:53:08,240 As far as the CA 820 00:53:08,240 --> 00:53:10,040 is concerned, this is a host 821 00:53:10,040 --> 00:53:11,800 inside of the OXOO.com domain. 822 00:53:12,020 --> 00:53:13,980 It will do domain validation against 823 00:53:13,980 --> 00:53:16,020 OXOO, which has the attacker 824 00:53:16,020 --> 00:53:16,940 I actually own. 825 00:53:17,580 --> 00:53:19,260 However, the browser 826 00:53:20,380 --> 00:53:21,680 stops at DEF CON. 827 00:53:21,680 --> 00:53:23,760 So you end up with a DEF CON 828 00:53:23,760 --> 00:53:24,080 certificate. 829 00:53:25,140 --> 00:53:27,760 If this is Netscape, and if I was in a particularly 830 00:53:27,760 --> 00:53:29,700 bad mood, or if I was 831 00:53:29,700 --> 00:53:31,620 Moxie Marlinspike who found the exact same 832 00:53:31,620 --> 00:53:32,980 attack, good job, man, 833 00:53:34,640 --> 00:53:35,600 I would have 834 00:53:35,600 --> 00:53:37,060 instead gotten this cert for just 835 00:53:37,060 --> 00:53:39,520 star null dot OXOO 836 00:53:39,520 --> 00:53:41,620 dot com and just had a cert forever 837 00:53:41,620 --> 00:53:42,820 that would be great for every site. 838 00:53:43,420 --> 00:53:45,260 But I actually didn't feel like having 839 00:53:45,260 --> 00:53:46,760 those kind of bits on my hard drive. 840 00:53:48,120 --> 00:53:49,880 Something about my hard drive is getting leaked. 841 00:53:50,980 --> 00:53:51,580 But, uh, 842 00:53:58,840 --> 00:54:00,080 I still owe a beer. 843 00:54:01,020 --> 00:54:01,380 I still owe a beer. 844 00:54:01,380 --> 00:54:03,680 So, we actually have a lot of 845 00:54:03,680 --> 00:54:05,340 progress on getting null and CN fixed. 846 00:54:05,820 --> 00:54:07,460 Moxie was like, wow, you know, this is not 847 00:54:07,460 --> 00:54:09,420 actually vulnerable in Firefox 3.5. 848 00:54:10,100 --> 00:54:11,760 No, we've been dorking on that, dude. 849 00:54:12,780 --> 00:54:13,420 So, um, 850 00:54:13,940 --> 00:54:15,340 actually, I do want to say Moxie 851 00:54:15,340 --> 00:54:17,300 probably has the best 852 00:54:17,300 --> 00:54:18,640 exploit for all of this. 853 00:54:18,820 --> 00:54:21,120 Do you mind if I tell them? All right. 854 00:54:21,680 --> 00:54:23,340 So, you might say, okay, Dan, 855 00:54:23,520 --> 00:54:25,720 you can impersonate a website. What's the big deal? 856 00:54:26,020 --> 00:54:27,240 Well, it turns out Firefox 857 00:54:27,240 --> 00:54:29,680 downloads code updates over SSL. 858 00:54:31,840 --> 00:54:33,520 So, yeah, if you're on 859 00:54:33,520 --> 00:54:35,160 LAN, if you're, you know, 860 00:54:35,180 --> 00:54:37,220 DNS is cache poisoned, if 861 00:54:37,220 --> 00:54:38,720 anything is in path, 862 00:54:39,940 --> 00:54:41,480 you launch Firefox, it 863 00:54:41,480 --> 00:54:43,440 goes to the internet over SSL and says, 864 00:54:43,480 --> 00:54:45,140 hey, is there any new code for me? 865 00:54:45,320 --> 00:54:47,020 It should have worked fine, 866 00:54:47,180 --> 00:54:49,160 but one of these other 867 00:54:49,160 --> 00:54:50,640 certificate authorities has 868 00:54:51,160 --> 00:54:53,220 screwed them. So, even though Mozilla 869 00:54:53,220 --> 00:54:55,140 has a reasonable certificate authority 870 00:54:55,140 --> 00:54:56,580 that would never do anything bad, 871 00:54:57,120 --> 00:54:59,100 whoever Moxie was dealing with actually 872 00:54:59,100 --> 00:55:00,820 was more than happy to issue a certificate 873 00:55:00,820 --> 00:55:03,240 that ultimately was valid 874 00:55:03,240 --> 00:55:04,320 for Mozilla as well. 875 00:55:05,100 --> 00:55:05,580 So, 876 00:55:06,820 --> 00:55:09,000 most CAs should be clean, but 877 00:55:09,000 --> 00:55:10,980 we really do want this stuff, at this 878 00:55:10,980 --> 00:55:13,140 point, but we really do want this fixed client 879 00:55:13,140 --> 00:55:14,640 side. So, the latest NSS 880 00:55:15,060 --> 00:55:16,080 already blocks nulls. 881 00:55:17,480 --> 00:55:18,980 Firefox 3.0 will have it 882 00:55:19,160 --> 00:55:21,100 soon. Opera should be covered 883 00:55:21,100 --> 00:55:23,060 soon, and IE and Safari are 884 00:55:23,060 --> 00:55:24,320 testing their fixes at the moment. 885 00:55:25,900 --> 00:55:27,200 So, at the end of the day, 886 00:55:27,240 --> 00:55:29,100 what am I suggesting? What am 887 00:55:29,100 --> 00:55:29,920 I saying here? 888 00:55:30,860 --> 00:55:33,060 Should we just move everything to DNSSEC and 889 00:55:33,060 --> 00:55:35,020 tell the CAs to go find a new line of business? 890 00:55:35,760 --> 00:55:37,200 No, no, you're not going to believe this. 891 00:55:37,260 --> 00:55:38,240 The suckers are actually useful. 892 00:55:40,980 --> 00:55:43,220 One of the really nasty problems 893 00:55:43,220 --> 00:55:45,020 that people keep trying to define 894 00:55:45,020 --> 00:55:47,040 away, keep trying to decide, isn't 895 00:55:47,040 --> 00:55:48,460 actually a security risk. 896 00:55:49,160 --> 00:55:50,900 Are semantic name collisions. 897 00:55:51,340 --> 00:55:53,020 We have our elite attacks 898 00:55:53,020 --> 00:55:54,960 with null terminators, but you know, 899 00:55:55,120 --> 00:55:58,360 www.bank-of-america.com 900 00:55:58,360 --> 00:55:59,020 works 901 00:55:59,020 --> 00:56:00,360 fine for users. 902 00:56:00,700 --> 00:56:03,060 They don't care. They also 903 00:56:03,060 --> 00:56:05,260 don't care about certificate warnings, by the way. 904 00:56:06,540 --> 00:56:08,960 We have a lot of dreams about, like, users. 905 00:56:09,060 --> 00:56:10,900 Really, we're dreaming about a universe 906 00:56:10,900 --> 00:56:12,480 containing nothing but us. 907 00:56:12,940 --> 00:56:14,960 A universe containing nothing but us is an even 908 00:56:14,960 --> 00:56:15,980 more terrifying concept. 909 00:56:19,800 --> 00:56:20,320 So, 910 00:56:22,700 --> 00:56:23,220 there's 911 00:56:23,220 --> 00:56:24,760 a problem. Somebody 912 00:56:24,760 --> 00:56:26,900 needs to be out there, able to 913 00:56:26,900 --> 00:56:27,860 assert that 914 00:56:27,860 --> 00:56:31,920 www.bank-of-america.com 915 00:56:31,920 --> 00:56:32,320 www.bank-of-america.com 916 00:56:32,320 --> 00:56:34,000 that should not get a certificate. 917 00:56:34,360 --> 00:56:36,580 Someone needs to be in a position to be able to say 918 00:56:36,580 --> 00:56:37,820 this is a collision, 919 00:56:38,560 --> 00:56:40,920 a semantic collision, even though it's different 920 00:56:40,920 --> 00:56:42,980 characters, no human is going to 921 00:56:42,980 --> 00:56:43,560 see the difference. 922 00:56:44,260 --> 00:56:46,880 If you think it's easy, think about other languages, 923 00:56:46,880 --> 00:56:51,980 think about other countries. Think about the equivalent of these dashes in China for one of 924 00:56:51,980 --> 00:56:57,060 China's largest banks. The only people with boots on the ground, with local knowledge, 925 00:56:57,240 --> 00:57:02,500 with actual brand awareness are actually these certificate authority companies. 926 00:57:03,020 --> 00:57:07,140 So they went ahead and they built something called extended validation, where they throw 927 00:57:07,140 --> 00:57:12,540 some really random crap into X509. It doesn't work wonderfully well because it's just not the 928 00:57:12,540 --> 00:57:18,060 right technology for it, but it allows the CA to express their special knowledge that they 929 00:57:18,060 --> 00:57:23,680 actually made sure this name doesn't look like any other name. And in return, the browser changes 930 00:57:24,560 --> 00:57:30,780 the user interface a little. You get a green bar. Now, extended validation has gotten a lot of 931 00:57:30,780 --> 00:57:37,020 flack lately. It's gotten flack because while it is wonderful for defending against phishing attacks, 932 00:57:37,420 --> 00:57:41,640 somebody went off and said that it deals with the fact that a bunch of CAs have crappy issuing 933 00:57:41,640 --> 00:57:42,140 policies. 934 00:57:42,920 --> 00:57:47,820 It doesn't do anything about that. If you have a badly issued certificate, 935 00:57:49,100 --> 00:57:55,000 the badly issued certificate can actually interfere with the extended validation version. 936 00:57:55,320 --> 00:58:03,780 This is by design. It is a pain in the ass to get an EV certificate, and if you needed to go 937 00:58:03,780 --> 00:58:10,760 through that pain in the ass for every ad network, every analytics system, every image server, 938 00:58:11,080 --> 00:58:12,520 it would just, there'd be nothing. 939 00:58:15,080 --> 00:58:21,960 So, the perfect is the enemy of the good. The browsers did not actually design a barrier between EV and DV. 940 00:58:23,440 --> 00:58:30,620 So, people are surprised by this. It was talked about publicly by a couple of guys, by Colin Jackson and Adam Barth two years ago. 941 00:58:31,040 --> 00:58:40,080 It was on my slide deck last year. Some CAs really did get out of sync, though. They ran their mouth. They said, no, no one could ever exploit this. 942 00:58:40,340 --> 00:58:42,440 And so, Mike Zussman and Alexander Sodorov. 943 00:58:42,440 --> 00:58:47,780 actually did some really cool demos with exploiting that lack of a security boundary. But there 944 00:58:47,780 --> 00:58:54,100 is no security boundary. So there can't be. So what do we do? We do need to get the damn 945 00:58:54,100 --> 00:58:59,800 DNS root signed. Sorry, it has to happen. It will spawn a bunch of development where 946 00:58:59,800 --> 00:59:05,740 we can start using the really nice traits of DNS. We can start using the really nice 947 00:59:05,740 --> 00:59:13,920 traits of DNS to exclude insecure suppliers and to delegate authority effectively. We bootstrap 948 00:59:13,920 --> 00:59:20,340 other protocols from SSH to IPsec to PGP to SSL. We put the hash of all of these certificates in 949 00:59:20,340 --> 00:59:28,280 DNS. And now consider, since DNSSEC inherits DNS's exclusivity, you still have a cert. It still 950 00:59:28,280 --> 00:59:35,120 has the X509 GUI. It still gets to say extended validation. But other certificates will not work. 951 00:59:35,200 --> 00:59:35,720 The DNSSEC will not work. It will not work. It will not work. It will not work. It will not 952 00:59:35,720 --> 00:59:40,320 work. The DV certs from every other vendor will actually be excluded. So you will have the best 953 00:59:40,320 --> 00:59:44,860 of both worlds. You will have the certificate authority being able to use the actual useful 954 00:59:44,860 --> 00:59:54,000 content they bring to the table. Or you can the actual useful stuff they bring to the table 955 00:59:54,000 --> 01:00:02,760 while being able to exclude insecure suppliers. So in summary, X509 is messy. Operationally, 956 01:00:02,760 --> 01:00:05,440 its lack of segregation and delegation makes it really expensive. 957 01:00:05,720 --> 01:00:10,580 It forces really painful decisions to be made. Technically, the technology is really fragile. 958 01:00:11,120 --> 01:00:15,160 The orgs are doing the best they can. We got to give them better stuff to work with. That's what 959 01:00:15,160 --> 01:00:19,640 I'm working on with DNSSEC. So that's what I got. And I'm open for questions.