1 00:00:00,000 --> 00:00:12,380 This talk was originally going to be at one, but I'm happy, we were happy to bump this talk up because this is still one of the quintessential topics in security. 2 00:00:12,700 --> 00:00:18,640 And without much ado, my pleasure to introduce you to Travis Palmer and Brian Somers. 3 00:00:23,770 --> 00:00:24,930 Thank you, folks. 4 00:00:25,110 --> 00:00:28,770 So, as you said, this is a quintessential topic in security. 5 00:00:28,770 --> 00:00:35,030 We are actually not trying to win any awards for the length of the name of our talk, but we're pretty sure we might have actually won. 6 00:00:35,590 --> 00:00:49,110 And we're going to give you guys not just an update on kind of the current state of what DNS is, but also go a bit further and actually give you guys a presentation on an attack that is doable very plausibly against some major resolvers. 7 00:00:49,110 --> 00:00:55,110 From my understanding, Google and some other folks have not really gotten back to us with a firm word of, yeah, totally, we got this yet. 8 00:00:55,110 --> 00:00:59,270 So very plausibly, you could turn around and actually use this if you were very quick about it. 9 00:00:59,270 --> 00:01:02,470 This is a nice stick to poke people to get actually moving. 10 00:01:02,470 --> 00:01:06,430 So without further ado, this is how you become the one in 34 million. 11 00:01:07,030 --> 00:01:10,430 So I'm going to go through basically introduce ourselves. 12 00:01:10,430 --> 00:01:12,890 Then we're going to go right into, we have to give some background on DNS. 13 00:01:12,890 --> 00:01:16,890 A lot of people here are new to DEF CON and relatively new to the security industry. 14 00:01:16,910 --> 00:01:20,510 I can't talk about the things that are different if I can't talk about the stuff that's originally. 15 00:01:20,570 --> 00:01:21,970 We're going to talk about fragmentation attacks. 16 00:01:21,970 --> 00:01:23,270 There's a bit of a history for that. 17 00:01:23,270 --> 00:01:31,930 And I'm going to talk, trust me, it's not, it's a very important tangent into IPAD inference and some of the more recent stuff that has come out of University of New Mexico. 18 00:01:32,470 --> 00:01:34,490 And then we'll go right into the attack. 19 00:01:34,510 --> 00:01:41,790 I'm not actually affiliated with the folks in University of New Mexico, but they are very helpful and their white paper was more than enough to get this attack rolled together. 20 00:01:41,850 --> 00:01:46,770 And then Brian, who is actually a proper expert, will be talking about mitigations. 21 00:01:46,910 --> 00:01:49,070 So hello, I'm Travis Trafico Palmer. 22 00:01:50,070 --> 00:01:52,350 I'm a security research engineer for Cisco Systems. 23 00:01:52,350 --> 00:01:54,850 I am an OSCP and OSCE if that means anything to you. 24 00:01:54,850 --> 00:02:00,030 And as I kind of implied, yeah, I'm not actually an expert on DNS or DNSSEC. 25 00:02:00,330 --> 00:02:02,070 I don't do this on a day-to-day basis. 26 00:02:02,070 --> 00:02:06,410 Brian, I don't think would want to call himself an expert, but he's close enough. 27 00:02:06,450 --> 00:02:13,510 And he is a principal engineer for Cisco System and has had a lot of free time to work on FreeSB and OpenBSD. 28 00:02:15,490 --> 00:02:17,390 So what did we actually do? 29 00:02:17,390 --> 00:02:26,610 This is, what we found was a more consistent way to poison the cache of DNS resolvers without using a man in the middle and using an existing attack that existed using fragmentation on DNS. 30 00:02:26,610 --> 00:02:32,930 We took that attack, reduced it from hundreds of iterations to very plausibly one on IPv4. 31 00:02:33,350 --> 00:02:38,130 And for IPv6, reduced it from millions of iterations to very plausibly only one. 32 00:02:38,550 --> 00:02:44,010 And also because of that, we're basically bypassing all the current recommendations. 33 00:02:44,270 --> 00:02:49,830 So even if you're doing everything right as people are telling you, yeah, we can probably still screw your domain. 34 00:02:50,510 --> 00:02:52,470 So yes, we did disclose responsibly. 35 00:02:52,470 --> 00:02:56,390 I'm, my particular team was discovered this attack during a focus pen test engagement. 36 00:02:56,390 --> 00:03:00,850 It was a couple of weeks, but it's a little bit of an unusual pen test engagement to say the least. 37 00:03:01,150 --> 00:03:12,370 And our team disclosed off to Cisco Umbrella and Umbrella has been disclosing this to other DNS operators ongoing both before DEF CON and will likely continue to do so after DEF CON as I'm sure some e-mails might come rolling in. 38 00:03:13,170 --> 00:03:21,730 So to start, as I said before, we need to talk about DNS and what a better place to start than talking about the attacks because we can't really talk about all of DNS. 39 00:03:21,890 --> 00:03:29,390 So in the early DNS, in the way back when, DNS was really only exploitable in a man in the middle scenario, which it has no protections against. 40 00:03:29,390 --> 00:03:34,650 Still really doesn't have a ton of protections against, but it's getting closer. 41 00:03:34,910 --> 00:03:51,410 In any case, back then, ignoring other protocols, the only thing that was actually keeping a normal DNS reply from being spoofed, doing things off path, not man in the middle, was the DNS ID and the styling and the structure of the response itself. 42 00:03:52,110 --> 00:03:53,770 It has to answer the query. 43 00:03:54,590 --> 00:03:57,390 DNS queries and responses are very consistent. 44 00:03:57,550 --> 00:04:01,170 So really, we're back to only talking about DNS ID. 45 00:04:01,650 --> 00:04:15,710 And again, I said before, ignoring other protocols, there's of course the issue that this is being sent across the internet and there is this extra level thing called UDP, which is going to have port numbers and some other things that are going to be very difficult to guess if you're trying to spoof a DNS reply. 46 00:04:15,990 --> 00:04:25,710 And Kaminsky is for original attack basically determined that a number of implementations of resolvers that were being used were programmed to query over sequential, very predictable sets of ports. 47 00:04:26,230 --> 00:04:31,130 And this took out basically all of their sources of entropy that were to exist to make it difficult for the attacker. 48 00:04:31,130 --> 00:04:33,990 So again, we're back to the 16 bits of DNS ID. 49 00:04:34,070 --> 00:04:37,590 And that's really not enough to stop an attack once poison records get saved. 50 00:04:37,690 --> 00:04:44,130 If you can try over and over and over again and if you succeed, it gets saved, well, then you're good. 51 00:04:44,130 --> 00:04:45,130 You're good to do this off path. 52 00:04:45,130 --> 00:04:45,970 You don't need to be in the middle. 53 00:04:45,970 --> 00:04:47,610 What do I mean by off path? 54 00:04:47,610 --> 00:04:48,570 Have a diagram. 55 00:04:48,890 --> 00:04:53,310 So dotted blue line here is the network path from DNS request from the target is taking. 56 00:04:53,770 --> 00:04:59,170 And we're off path because our attacker boxes, the red boxes, we're just not on the network path. 57 00:04:59,170 --> 00:05:00,690 We can't see anything that's going on there. 58 00:05:00,690 --> 00:05:03,510 We might have some idea of what's going on over there. 59 00:05:03,570 --> 00:05:06,190 But we can't see or modify the traffic. 60 00:05:06,870 --> 00:05:13,210 Now, for this particular case, and I'm going to keep this going, this diagram is going to change a little bit, but it's going to be largely the same. 61 00:05:13,210 --> 00:05:15,950 We have our attacker box off somewhere in the Internet. 62 00:05:16,010 --> 00:05:21,250 And then inside of the trust boundary, some corporate network, something that the resolver is servicing. 63 00:05:21,450 --> 00:05:23,510 We have both our target and a puppet. 64 00:05:23,610 --> 00:05:25,490 The puppet, we don't really have to fully control. 65 00:05:25,490 --> 00:05:28,110 It could be as simple as just some JavaScript in a web browser. 66 00:05:29,630 --> 00:05:31,590 But what follows is a little less simple. 67 00:05:31,690 --> 00:05:37,350 So first the attacker is going to basically figure out where the external facing IP is for the resolver. 68 00:05:37,350 --> 00:05:41,750 This can be as simple as basically talking to ourselves, making a request for a domain that we control. 69 00:05:41,750 --> 00:05:47,550 And as long as our box is also serving as a name server for our own domain, we get the IP address of the resolver. 70 00:05:47,550 --> 00:05:52,350 The attacker then can just tell their puppet, hey, send a request on my behalf. 71 00:05:52,450 --> 00:05:58,490 And since we know what it's requesting and when it's requesting, we can immediately start sending responses to the resolver. 72 00:05:59,030 --> 00:06:06,670 And since everything else is largely predictable, in the case of the Kominsky attack, even the, even the destination port on UDP is predictable, we can just start guessing DNS IDs. 73 00:06:06,770 --> 00:06:11,210 Because the resolver is going to make another request on behalf of our puppet. 74 00:06:11,210 --> 00:06:13,970 We don't know what the ID is, but we can sure start guessing. 75 00:06:14,010 --> 00:06:16,050 And this might take a little while. 76 00:06:16,470 --> 00:06:18,290 It's not always going to get cached. 77 00:06:18,290 --> 00:06:21,350 Sometimes the legitimate response is going to go straight through the resolver. 78 00:06:22,270 --> 00:06:26,910 And so really we do have to find certain types of requests that aren't going to get cached. 79 00:06:27,510 --> 00:06:30,230 At least when not modified. 80 00:06:30,510 --> 00:06:33,950 This can, you can do this in a couple of different cases. 81 00:06:34,010 --> 00:06:38,370 You can do this for zero time to live domains or near zero. 82 00:06:38,370 --> 00:06:43,330 A lot of it is content delivery networks, Akamai, CDN, YouTube. 83 00:06:43,470 --> 00:06:45,450 A lot of those requests aren't going to live very long in the cache. 84 00:06:45,490 --> 00:06:48,270 Or we can start asking for things like domains that don't exist. 85 00:06:48,470 --> 00:06:50,010 Which won't get cached. 86 00:06:50,450 --> 00:06:55,730 Unless, of course, you then proceed to give a response for them where you say that it is existent. 87 00:06:55,730 --> 00:06:57,190 And then you start changing some other things. 88 00:06:57,190 --> 00:06:59,430 Like the records for where the name servers are at and other things. 89 00:06:59,430 --> 00:07:01,470 Which will, of course, all end up in the cache as well. 90 00:07:02,070 --> 00:07:05,070 Once it's in the cache, it also comes down to our puppet. 91 00:07:05,070 --> 00:07:06,090 But that doesn't really matter. 92 00:07:06,110 --> 00:07:07,430 The important part is that it's saved. 93 00:07:07,430 --> 00:07:13,790 So when our poor target machine goes out and asks for it, it gets a response back that it probably shouldn't have gotten. 94 00:07:14,090 --> 00:07:18,290 And starts reaching out immediately to the internet for whatever it was trying to reach initially. 95 00:07:18,290 --> 00:07:22,150 DNS is a protocol to find other things, ultimately. 96 00:07:22,530 --> 00:07:24,230 And reach out to our malicious server. 97 00:07:24,230 --> 00:07:29,490 Malicious server goes ahead and gives them, yeah, totally, those binaries that you wanted, yeah, got them. 98 00:07:29,490 --> 00:07:30,250 There you go. 99 00:07:30,310 --> 00:07:32,970 And that person, if that person wasn't paying attention, they get farmed. 100 00:07:32,970 --> 00:07:35,770 The program is reaching out and not checking the TLS certificates. 101 00:07:35,770 --> 00:07:39,150 And frankly anything that there's not good verification in place, they get pwned. 102 00:07:39,150 --> 00:07:39,550 The end. 103 00:07:39,550 --> 00:07:42,430 Just as disturbing as it was a little bit more than a decade ago. 104 00:07:42,950 --> 00:07:45,510 Of course, the Kominsky attack doesn't work anymore. 105 00:07:45,650 --> 00:07:48,150 I'm glad we've made progress in the past decade. 106 00:07:48,710 --> 00:07:54,430 Shortly before that attack was presented, even, various DNS resolver applications were patched to make the UDP ports unpredictable. 107 00:07:54,430 --> 00:07:56,150 Dan Kominsky is a white hat after all. 108 00:07:56,150 --> 00:07:58,270 So he did tell everybody kind of ahead of time. 109 00:07:58,810 --> 00:08:01,930 Needless to say, this puts up a heck of a damper on trying to do this kind of exploit. 110 00:08:01,930 --> 00:08:07,130 Because now you have a destination port to guess as well. 111 00:08:07,170 --> 00:08:08,810 That's another 16 bits. 112 00:08:08,810 --> 00:08:10,450 That's 30.2 bits total. 113 00:08:10,450 --> 00:08:16,770 And although you could exclude some of the ports, this is about 65,000 times harder. 114 00:08:17,410 --> 00:08:24,950 Though the attack is still high profile and scary, you're not going to be doing this in any kind of feasible scenario. 115 00:08:25,050 --> 00:08:30,370 And I'm not going to pretend Kominsky alone made DNSSEC happen, but this did help along. 116 00:08:33,270 --> 00:08:38,950 So people scared of DNS being spoofed basically are now using DNSSEC. 117 00:08:39,090 --> 00:08:43,570 Without going too far into it, DNSSEC is basically public key infrastructure for domain names. 118 00:08:43,570 --> 00:08:52,970 And ICANN, the highest level of authority, signs for various top level domains like .org, who then in turn sign the keys used by domains. 119 00:08:52,970 --> 00:08:57,530 So for example, DEFCON.org, which then used to sign those keys for records. 120 00:08:57,530 --> 00:09:01,470 Individual records say where WW.DEFCON.org is. 121 00:09:01,990 --> 00:09:06,610 Of course it's a little more complicated than that, but we really can't for sake of time dig into it. 122 00:09:07,690 --> 00:09:13,110 A couple of things that DNSSEC adds that are really important is data origin authentication. 123 00:09:13,130 --> 00:09:18,390 Basically the ability to verify the data that you're receiving is coming from where it's saying it's coming from. 124 00:09:18,450 --> 00:09:22,190 And also trying to make sure that data cannot be modified in transit. 125 00:09:22,190 --> 00:09:31,470 Since the records are signed by the zone owner and the zone's private key, it would be really hard to mess with that because if it actually gets verified, well, the signatures are not going to line up. 126 00:09:31,470 --> 00:09:32,830 That's how cryptography works. 127 00:09:33,190 --> 00:09:37,310 Of course, not everybody is actually deploying DNSSEC. 128 00:09:37,330 --> 00:09:43,610 And even if you were to deploy DNSSEC on your domains, it's not particularly helpful if the resolvers aren't doing it either. 129 00:09:45,190 --> 00:09:47,630 This part, this is really not going too well. 130 00:09:47,630 --> 00:09:50,270 And the last report this was made was in 2016. 131 00:09:50,310 --> 00:09:57,750 Unless you're in central Africa and your ISP is using Google DNS for everything, you might be in a bad bit of luck. 132 00:09:57,930 --> 00:10:03,350 In any case, we need to bring up some more bad news and talk about what DNSSEC doesn't actually do either. 133 00:10:04,490 --> 00:10:06,150 Delegation and glue records. 134 00:10:06,230 --> 00:10:12,490 Name server, A records for IP addresses located in the authority and additional sections in DNS are not signed. 135 00:10:12,970 --> 00:10:16,350 Delegations are records that basically relay authority to another server. 136 00:10:16,350 --> 00:10:21,550 So realistically, .com isn't going to know what servers example.com is running. 137 00:10:21,630 --> 00:10:23,510 So you have to delegate that authority down. 138 00:10:23,870 --> 00:10:25,370 And I had mentioned glue records. 139 00:10:25,510 --> 00:10:38,590 Glue records are largely fixed to solve an issue of if you have your name server in your domain or there's some concern about somebody not knowing where your name server is for your domain, you include that at the absolute end of the request or, pardon me, 140 00:10:38,590 --> 00:10:40,690 include that at the absolute very end of the response. 141 00:10:41,290 --> 00:10:49,510 Because otherwise, someone who is looking for some resources in example.com are going to ask the .com domain, okay, where's example.com? 142 00:10:49,850 --> 00:10:52,590 It's going to tell, hey, you need to look over here for example.com. 143 00:10:52,770 --> 00:10:54,870 And okay, where's the name service for that? 144 00:10:54,870 --> 00:10:55,410 We don't know? 145 00:10:55,410 --> 00:10:55,750 Okay. 146 00:10:55,750 --> 00:10:56,930 Ask .com again. 147 00:10:57,530 --> 00:10:58,990 This continues in an infinite loop. 148 00:10:59,710 --> 00:11:01,430 So that's why they need to be this. 149 00:11:01,430 --> 00:11:06,090 But somebody, of course, in here hopefully is thinking, why aren't these signed? 150 00:11:06,170 --> 00:11:08,070 Why can't we just figure out a way to sign this? 151 00:11:08,070 --> 00:11:09,430 Well, the RFC says so. 152 00:11:10,330 --> 00:11:11,850 It's with actually good reason. 153 00:11:11,850 --> 00:11:13,010 It's delegation of duty. 154 00:11:13,210 --> 00:11:18,090 Child zones have a private key for authority records and the parent zone really can't be signing it for them. 155 00:11:18,490 --> 00:11:21,710 But there's, again, there's data origin authentication. 156 00:11:21,710 --> 00:11:24,610 If you can trust that parent, you can probably trust the children as well. 157 00:11:24,610 --> 00:11:29,610 And there's, you know, large committees that are rather trustworthy running most of the system. 158 00:11:29,830 --> 00:11:33,870 Of course, there's also the deal with all the signatures. 159 00:11:34,370 --> 00:11:38,190 All these signatures can make responses quite long, especially if there's lots of records. 160 00:11:38,190 --> 00:11:47,270 And as a bonus, name servers can even sign the gaps between valid subdomains and sign nearby names to prove there's no subdomain in between using NSEC or NSEC 3. 161 00:11:47,430 --> 00:11:48,950 But how bad could it be? 162 00:11:48,950 --> 00:11:49,830 Someone might ask. 163 00:11:49,830 --> 00:12:04,550 Well, if today you go ahead and ask DefCon.org for a non-existent domain, they're using NSEC, and so they will respond very verbosely with 1,922 bytes to tell you something doesn't exist. 164 00:12:04,910 --> 00:12:05,550 Seriously? 165 00:12:06,210 --> 00:12:08,330 This is our best solution. 166 00:12:09,050 --> 00:12:16,190 You can't even send this across the internet in one piece without expecting it to be fragmented, which is something we need to talk about. 167 00:12:17,070 --> 00:12:23,010 So Hertzberg and Shulman realized that this was kind of a problem. 168 00:12:23,010 --> 00:12:27,270 If the response is getting split up, UDP has no means of dealing with fragmentation. 169 00:12:27,270 --> 00:12:28,330 Only really that's TCP. 170 00:12:28,330 --> 00:12:30,390 And everything in DNS is running by UDP by default. 171 00:12:30,390 --> 00:12:32,310 So it has to be fragmented to the IP layer. 172 00:12:32,670 --> 00:12:35,830 And that means it gets an IP identifier. 173 00:12:36,670 --> 00:12:41,930 And mind you, these are rather inexact diagrams, but I'm trying to keep it simple. 174 00:12:41,930 --> 00:12:44,810 It is IP around UDP around DNS. 175 00:12:44,850 --> 00:12:49,110 And in red is basically all the things that an attacker can't really spoof. 176 00:12:49,470 --> 00:12:52,030 And that IP identifier is an IP layer 3 thing. 177 00:12:52,030 --> 00:12:53,970 It's used on both IPv4 and IPv6. 178 00:12:53,970 --> 00:12:56,470 In any case, it's an additional factor source of entropy. 179 00:12:56,470 --> 00:12:58,270 We have to guess that it's an attacker. 180 00:12:58,790 --> 00:13:06,590 But if you're noticing, that second fragment's looking a little lonely because all of those QDC signing bits and the other protocols end up in that first fragment. 181 00:13:06,630 --> 00:13:10,350 And the second fragment, the only thing we have is that IP layer identifier. 182 00:13:11,590 --> 00:13:13,970 Now, DNS actually adds even more stuff. 183 00:13:13,970 --> 00:13:19,070 But again, it ends up in the headers or the first couple of things in DNS. 184 00:13:19,170 --> 00:13:20,770 Nothing in the second fragment. 185 00:13:21,550 --> 00:13:25,690 And as it turns out, the IP ID for IPv4 is 16 bits. 186 00:13:25,950 --> 00:13:27,430 This familiar to anybody? 187 00:13:27,910 --> 00:13:34,010 As a further bonus, many resolvers when this paper was published were using global counters for IP ID. 188 00:13:34,370 --> 00:13:38,750 And it was the default in Windows, default in FreeBSD according to them when they published in 2012. 189 00:13:39,170 --> 00:13:46,250 And there was a lot of resolvers they were able to find right before they published it that were doing global IP ID. 190 00:13:46,250 --> 00:13:49,130 So what does this attack end up looking like in that particular case? 191 00:13:49,210 --> 00:13:51,850 Well, I have to add something to the diagram real quick. 192 00:13:52,210 --> 00:13:54,770 We now have an IP fragment cache on this diagram. 193 00:13:54,950 --> 00:13:56,310 It holds up to 64 fragments. 194 00:13:56,310 --> 00:13:57,570 That's relatively the default. 195 00:13:58,250 --> 00:14:01,670 It holds them up so they can be reassembled when and if they all get received. 196 00:14:01,670 --> 00:14:03,850 And if nothing else, it drops them after a couple of minutes. 197 00:14:04,110 --> 00:14:08,810 In any case, the first thing we do when performing this attack is ask. 198 00:14:09,510 --> 00:14:11,030 Sometimes you only need to ask. 199 00:14:11,190 --> 00:14:16,830 As an attacker, we basically just ask the name server if the response is fragmented or it's IPv4, we get an IP ID back. 200 00:14:16,830 --> 00:14:20,610 So we already know what IP ID the name server is using if it's using global IP ID. 201 00:14:20,690 --> 00:14:23,730 And then we proceed doing what we were doing before. 202 00:14:23,890 --> 00:14:26,770 Puppet goes ahead and asks something on our behalf. 203 00:14:26,950 --> 00:14:31,670 And while the name server is still thinking about responding to that, we start guessing IP IDs. 204 00:14:32,030 --> 00:14:34,730 And DNS is relatively well structured, very consistent. 205 00:14:34,730 --> 00:14:39,190 If you ask for something, you're always going to get roughly the same reply, short of maybe some garbling up in the headers. 206 00:14:39,190 --> 00:14:40,290 But again, we don't care about the headers. 207 00:14:40,290 --> 00:14:42,690 We're sending the second fragment over and over and over and over again. 208 00:14:42,690 --> 00:14:43,970 And we actually have a good starting point. 209 00:14:43,970 --> 00:14:46,890 We know what the IP ID was before. 210 00:14:46,990 --> 00:14:51,450 And so we can go ahead and just send that sucker along and start guessing everything in front of it. 211 00:14:51,570 --> 00:14:53,990 Mind you, it is global, so we have to do this kind of quickly. 212 00:14:53,990 --> 00:14:58,350 Other people could be talking into this name server, and they probably are, which is going to increase the IP ID. 213 00:14:58,350 --> 00:15:00,090 But we can guess 64 times. 214 00:15:00,350 --> 00:15:12,810 So at some point, we're not just going to go through, but we're actually going to be combined with the first fragment of the original legitimate request, which contains all of the lovely headers that are signing this thing. 215 00:15:12,910 --> 00:15:16,590 And then that's going to go right on up into the cache and then down to our puppet. 216 00:15:16,590 --> 00:15:26,270 But again, the thing we care about most is the cache because when at a later point, when that poor target machine goes ahead and asks, hey, where's Defcon.org? 217 00:15:26,910 --> 00:15:29,310 They're going to get that assembled, but tampered response. 218 00:15:29,490 --> 00:15:34,830 And just like a Kominsky's detect before, target makes a query for what was, it gets told it lives with the attacker. 219 00:15:34,830 --> 00:15:36,770 It pulls some data from the attacker. 220 00:15:36,770 --> 00:15:38,250 It all downhill from there. 221 00:15:40,650 --> 00:15:42,630 And pardon me, my mouth is getting really dry. 222 00:15:45,230 --> 00:15:49,230 So there's a lot of stuff you can actually do with this. 223 00:15:49,230 --> 00:15:54,290 Even with DNSSEC , DNSSEC does limit what you can do with these kind of poisoning attacks. 224 00:15:54,290 --> 00:15:59,010 And there's only so much you can really mess with in the cache that isn't directly signed. 225 00:15:59,030 --> 00:16:06,810 But of the four sections, question, answer, authority, and additional, the ones we care about most with DNSSEC are those last two, the ones that are going to contain the stuff that's likely to be unsigned. 226 00:16:07,070 --> 00:16:10,430 And they're almost always going to make it in that second fragment. 227 00:16:10,470 --> 00:16:13,670 And we get some options. 228 00:16:13,870 --> 00:16:19,550 I would love to verbally explain to you all the limitations, but they made a diagram for me, so I'm going to use the diagram from their paper. 229 00:16:20,650 --> 00:16:28,490 So the main ones you want to look at here, because there's a couple, and that third from bottom line there is permissive or island. 230 00:16:28,490 --> 00:16:32,050 Basically the resolver is not actually doing some good resolving, not checking anything. 231 00:16:32,050 --> 00:16:36,570 Yeah, there's a lot of stuff in this you can do immediately if the resolver is not checking DNSSEC. 232 00:16:36,570 --> 00:16:41,590 But for the other cases when everything is in line doing what it's supposed to do, there's other stuff you can still do. 233 00:16:41,590 --> 00:16:48,710 So if you're using NSEC 3, and you're using it with an opt-out, that means you're not signing delegations with NSEC 3. 234 00:16:48,870 --> 00:16:58,470 And that means that if someone were to say, I don't know, replace one of your NSEC 3 records with an NS record for a subdomain, yeah, that subdomain exists now as far as your resolver is concerned. 235 00:16:59,110 --> 00:17:02,630 The other thing you can do is basically something in two phases. 236 00:17:02,630 --> 00:17:13,310 You can do NS hijacking, which if you've noticed, doesn't have a lot of requirements, and name server blocking, which again doesn't have a lot of requirements, at the same time. 237 00:17:13,310 --> 00:17:21,170 Basically what you do is you poison an NS record that makes it in the cache, and then you start performing server blocking on all the other name servers. 238 00:17:22,270 --> 00:17:28,510 And it's actually really easy to do name server blocking, because the only thing you have to do is ruin the responses from all those other name servers. 239 00:17:28,930 --> 00:17:33,130 And if you can just ask what their IP ID is, all you have to do is just mess it up. 240 00:17:33,290 --> 00:17:36,610 You don't have to poison anything, you don't have to have it even be correctly structured. 241 00:17:36,610 --> 00:17:40,310 If it gets reassembled and it's the wrong way, it's not going to be accepted. 242 00:17:40,390 --> 00:17:49,910 And for most DNS software, and unbound particularly, two failed queries at a 15 minute interval, that name, that resolver marks that name server as not responsive. 243 00:17:50,510 --> 00:17:51,630 All bad news. 244 00:17:52,270 --> 00:18:04,030 And if that last slide wasn't concerning enough, there's also the possibility the attacker could cause fragmentation by tricking the name server into believing that it needs to further fragment traffic, which of course helps get a complete record into that second fragment, 245 00:18:04,030 --> 00:18:06,770 or as many records as you want into that second fragment. 246 00:18:06,870 --> 00:18:13,370 And this does work on IPv6 as well, and there's been a couple of studies done that you can get this stuff well below what should be the minimum transmission unit. 247 00:18:13,570 --> 00:18:17,050 Any case, there are some more limitations to this. 248 00:18:17,570 --> 00:18:22,010 This, you folks probably would have heard about this if it had not been for some additional limitations. 249 00:18:22,290 --> 00:18:25,950 There's a lot of name servers that aren't deploying with global counters anymore. 250 00:18:26,070 --> 00:18:29,990 No real surprise there, that's something we generally expect from the network stack of a printer. 251 00:18:31,230 --> 00:18:39,770 Windows is still, as far as we know, using a global counter, but FreeBSD is now using a mostly random searchable queue system and Linux still isn't using global counters. 252 00:18:39,850 --> 00:18:42,990 Even back in 2012, Linux was using mostly per destination. 253 00:18:43,610 --> 00:18:47,070 And we can't query something that gets cached, just kind of like before. 254 00:18:47,070 --> 00:19:02,070 A significant portion of the difficulty here is finding the query that returns a predictable fragmented response, and sometimes the options for a given target are pretty slim, and maybe just the response to the any query is enough, but it can be dicey. 255 00:19:02,070 --> 00:19:03,130 And there's also the future. 256 00:19:03,130 --> 00:19:05,430 IPv6 throws a complete wrench in this. 257 00:19:06,230 --> 00:19:18,550 32 bits in trying to guess with IPv6, that puts you in the territory of 34 million iterations, and that's doing it on average. 258 00:19:18,550 --> 00:19:27,490 The actual case for exhausting the entire key space, and this is assuming stuff isn't moving or other people are talking to this name server, is around 67 million. 259 00:19:27,710 --> 00:19:29,450 You're not going to do this. 260 00:19:29,450 --> 00:19:32,450 This is literal terabytes of traffic you'd have to send. 261 00:19:32,490 --> 00:19:34,110 You're not doing this on IPv6. 262 00:19:34,110 --> 00:19:34,990 There's no way. 263 00:19:36,110 --> 00:19:37,730 But there has been some notice. 264 00:19:37,950 --> 00:19:46,950 This is kind of a bit of a thing for IPv4, and prior to our engagement with Umbrella, their implementation was using IPv6 whenever possible. 265 00:19:47,010 --> 00:19:47,870 Why wouldn't you? 266 00:19:48,190 --> 00:19:54,190 And they detect IPv4 fragments and re-query them over TCP or IPv6 if it's, or, ah, pardon me. 267 00:19:55,410 --> 00:20:03,530 Read, re-query it over IPv6 where possible and basically re-query over TCP if that still fails or you can't just query over IPv6. 268 00:20:03,670 --> 00:20:10,270 There was also a presentation this May at ORC, which wasn't us, actually. 269 00:20:10,810 --> 00:20:12,470 Now, please excuse the crayon colors. 270 00:20:12,470 --> 00:20:14,250 I am taking directly from their slides. 271 00:20:15,930 --> 00:20:21,050 But this is a rather pertinent presentation. 272 00:20:21,050 --> 00:20:24,730 I had said before this was what we found had bypassed all recommendations. 273 00:20:24,730 --> 00:20:36,010 Yeah, this is kind of the weird case because in an earlier slide in this presentation, they had said drop all fragments, but then here they say, well, the attack's only effective on IPv4 and kind of directly implied IPv6 is safe. 274 00:20:36,170 --> 00:20:36,810 I digress. 275 00:20:36,810 --> 00:20:38,490 In any case, this is good news. 276 00:20:38,490 --> 00:20:47,850 There's interested parties and the people who are the major operators of DNS are generally trying to loose, tie up all the loose ends without any major performance impact. 277 00:20:48,350 --> 00:20:53,970 So now we have to have that little tangent I was talking about before, which might make a little more sense now. 278 00:20:54,430 --> 00:20:58,510 So the sequential nature of IPID is largely why idle scanning exists. 279 00:20:58,510 --> 00:21:07,610 It's what Nmap uses, but as a lot of people here may know, the kind of scan has some requirements for zombies, namely global counters, and also they have to kind of be idle machines. 280 00:21:08,590 --> 00:21:11,610 They need to act like a 1990s printer, basically. 281 00:21:11,930 --> 00:21:31,670 I won't explain what this particular team found in depth because we really don't have the time, but in a somewhat similar manner to idle scanning, a university of New Mexico research team developed a way to abuse the IP fragment cache in Linux machines to basically determine if something had been sent and much like idle scanning, 282 00:21:31,670 --> 00:21:36,970 you could do this to figure out whether or not traffic was being sent on a link that you can neither see nor control. 283 00:21:37,550 --> 00:21:41,970 And it works on fully per destination IPID counters, which is what Linux had. 284 00:21:42,170 --> 00:21:46,670 And you can measure how many ‑‑ and you can really just do any kind of measurement across the Internet. 285 00:21:46,750 --> 00:21:49,590 Needless to say, the Linux folks didn't appreciate this. 286 00:21:49,730 --> 00:21:55,750 And they didn't really want every Linux machine on the Internet being used as a zombie for an idle scan. 287 00:21:55,850 --> 00:21:59,830 So around the same time as this paper being published, they created some patches. 288 00:22:00,010 --> 00:22:05,990 The first that we care about was to directly prevent measuring communication between two machines. 289 00:22:06,070 --> 00:22:10,950 And the second was an optimization to IPID, how IPIDs were handled. 290 00:22:11,290 --> 00:22:14,790 So the first one, I did say was a direct mitigation. 291 00:22:14,790 --> 00:22:16,390 Well, it doesn't actually completely fix it. 292 00:22:16,390 --> 00:22:19,470 Because what it's doing is just making it harder. 293 00:22:20,690 --> 00:22:30,130 It's basically incrementing the IPID by a random, but normal, between one and the number of kernel ticks since the last sent packet. 294 00:22:30,130 --> 00:22:34,370 This kind of requires keeping track of the last kernel tick values as part of per destination counter. 295 00:22:34,370 --> 00:22:38,450 And this makes this operation rather extensive, especially if you have a lot of things to talk to. 296 00:22:39,310 --> 00:22:40,630 But it does work. 297 00:22:40,630 --> 00:22:49,670 And if your interest was trying to do a long-term idle scan or a long-term query as to what was going on between two machines, yeah, this is going to make it real hard for you to do that. 298 00:22:49,670 --> 00:22:54,410 Because if you spend more than one kernel tick in between your polling, you have no idea what's actually coming back. 299 00:22:54,410 --> 00:22:55,530 It's properly random. 300 00:22:55,810 --> 00:22:58,350 The second one was an optimization. 301 00:22:58,870 --> 00:23:05,390 Before the network stack was keeping track of all the IPID counters for all destinations individually and storing them in a binary tree. 302 00:23:05,390 --> 00:23:10,110 This caused a lot of performance issues for servers that talk to a lot of clients, like name servers. 303 00:23:10,830 --> 00:23:17,870 And since every comp sci graduate knows that O of a constant is much better than O of long N, they made a new way based on hashing and binning. 304 00:23:18,170 --> 00:23:27,610 So destination addresses, both IPV4 and IPV6 are hashed to match it with a bin, which will contain the current IPID counter, which will then be used on the next thing that gets sent out the port. 305 00:23:27,950 --> 00:23:33,450 Now, this does mean that some destination addresses are going to have to share an IPID counter. 306 00:23:33,450 --> 00:23:41,630 So to prevent an outsider knowing which addresses are sharing a bin, the seed for this hash function, which is doing all the determination, is secret and determined at boot. 307 00:23:41,810 --> 00:23:42,470 Perfect. 308 00:23:42,550 --> 00:23:45,390 Especially if you have enough bins and hash collisions are rare. 309 00:23:46,430 --> 00:23:48,870 That's a low number. 310 00:23:50,390 --> 00:23:57,670 Now, if you think this is kind of low, like I think this is kind of low, the researchers at University of New Mexico would agree with you. 311 00:23:57,890 --> 00:24:03,850 And so they, of course, immediately then proceeded to make another idle scanning using the Linux network stack. 312 00:24:04,510 --> 00:24:09,910 So basically the way they do this is they use IPV6 to legitimately get very large source address spaces. 313 00:24:09,910 --> 00:24:14,090 You could use IPV4, but as we know, that address space is a little bit sparse nowadays. 314 00:24:14,090 --> 00:24:25,250 And all these sources, they query the IPID counter for their IPID address with a fragmented ICMP6 echo request, which then returns a fragmented response. 315 00:24:25,310 --> 00:24:31,010 And they increment the IPID counter for the target by spoofing a SYNAC to the target and then query again. 316 00:24:31,010 --> 00:24:39,650 Basically figuring out the hard way whether or not the talking and the spoofing they're doing is in the same bin as what they're able to query on. 317 00:24:39,650 --> 00:24:40,690 Their address. 318 00:24:40,970 --> 00:24:43,630 And then they just change addresses if it doesn't appear to line up. 319 00:24:44,410 --> 00:24:46,270 Now, why fragmented IPV6 echoes? 320 00:24:46,270 --> 00:24:50,710 Well, IPV6 is a little weird because it doesn't fragment the IPID counter unless the traffic is sent fragmented. 321 00:24:51,050 --> 00:25:01,200 And, well, all of the above requests as an extra stipulation have to arrive within one system tick, one kernel tick of another to force that random perturbation of one to the number of kernel ticks to always be one. 322 00:25:01,200 --> 00:25:04,860 It's funny, you know, the difference, random number between one and one is always one. 323 00:25:05,820 --> 00:25:07,320 Not the best mitigation. 324 00:25:07,580 --> 00:25:10,500 Thankfully for most systems, this timing is actually pretty low. 325 00:25:10,500 --> 00:25:16,260 Ever since Jiffy's were invented, that counter is about 10 milliseconds, 100 hertz. 326 00:25:16,260 --> 00:25:26,060 It could be as low as .66 milliseconds on specialty systems that are running clocks all the way up to 1,500 hertz. 327 00:25:26,120 --> 00:25:29,300 But that has to be a very specifically configured OS. 328 00:25:30,860 --> 00:25:34,860 Once the collision is found, you can basically just flip this triangle. 329 00:25:36,000 --> 00:25:37,060 It's nice. 330 00:25:37,720 --> 00:25:40,740 And start doing your idle scan. 331 00:25:41,120 --> 00:25:50,440 Basically instead of trying to figure out whether or not you have a collision with a target, you can start sending stuff off to another machine and see whether it responds back to this machine that you're doing the querying for. 332 00:25:50,600 --> 00:25:53,560 And they called this not an idle scan. 333 00:25:54,360 --> 00:25:55,020 Oh, well. 334 00:25:57,300 --> 00:26:03,000 So, there is something that you folks probably have noticed at this point. 335 00:26:03,040 --> 00:26:10,220 This is a lot of knowledge that you can get about the IPIDs and the state of IPIDs and the IPIDs for communications to other machines. 336 00:26:11,100 --> 00:26:13,040 And, well, hold on now. 337 00:26:13,040 --> 00:26:16,680 Why didn't the folks at the University of New Mexico realize that this might have some other implications? 338 00:26:16,680 --> 00:26:20,780 Why didn't they realize that this was going to have a huge implication on DNS and fragmentation attacks? 339 00:26:20,860 --> 00:26:22,660 Well, they were thinking about idle scanning. 340 00:26:22,660 --> 00:26:23,740 I don't blame them. 341 00:26:23,740 --> 00:26:27,500 And show of hands, who knew about Hertzberg and Shulman's research before today? 342 00:26:29,120 --> 00:26:30,400 No hands. 343 00:26:31,520 --> 00:26:33,100 Yeah, you can't blame them. 344 00:26:33,800 --> 00:26:35,980 So we get to talk about something new today. 345 00:26:36,660 --> 00:26:45,810 So basically this attack, which, mind you, that's what I get for pressing the down arrow. 346 00:26:45,970 --> 00:26:50,510 So we start this attack basically the same way as ONUS. 347 00:26:50,750 --> 00:26:59,430 And no, for those of you who are about to ask, I am not going to call this ANIS or actually not an idle scan for various reasons. 348 00:26:59,790 --> 00:27:02,630 But we're going to start by finding collisions just like with ONUS. 349 00:27:02,630 --> 00:27:05,810 And instead of a zombie and a target, we basically have a name server and resolver now. 350 00:27:06,170 --> 00:27:11,190 The text is a little bit small, but if you noticed, we're using IPV4 in there. 351 00:27:11,190 --> 00:27:12,710 Well, what if they're talking over IPV6? 352 00:27:12,710 --> 00:27:16,810 What if we need to find collisions on IPV6 addresses like Umbrella was planning on doing? 353 00:27:16,830 --> 00:27:19,170 Well, no problem. 354 00:27:19,170 --> 00:27:21,530 We'll make them IPV6 echo frags as well. 355 00:27:22,090 --> 00:27:24,230 And what about getting our address space? 356 00:27:24,230 --> 00:27:29,870 The entire point of using IPV6 to do this particular attack is it's got to be convenient. 357 00:27:30,550 --> 00:27:32,870 How convenient is it, Travco? 358 00:27:33,150 --> 00:27:36,450 Well, AWS to the rescue. 359 00:27:37,150 --> 00:27:42,370 So even the free tier of AWS VPC, virtual private cloud, you can get some IPV6 address space. 360 00:27:42,370 --> 00:27:45,270 But the real question is, of course, you know, is it big enough? 361 00:27:45,690 --> 00:27:48,870 I haven't done extensive testing, albeit. 362 00:27:49,110 --> 00:27:56,470 But I'm going to say that this is probably enough for those folks that can't count commas as fast as the slide is going to be up. 363 00:27:56,470 --> 00:28:00,130 That is 18 and a half quintillion, give or take a couple dozen quadrillion. 364 00:28:00,310 --> 00:28:07,990 Mind you, statistically, it only takes about 10,000 addresses to get a 99.2% chance of a collision because there's only 2,048 bins. 365 00:28:08,410 --> 00:28:16,590 And this is outright better than trying to do global IP name servers, global IP ID for name servers because in this scenario, we get protection. 366 00:28:18,210 --> 00:28:28,870 We get that added improvement of all the other bits of binning and if there's a couple of random hosts on the internet, 2,047 of them aren't going to mess with our IP ID. 367 00:28:29,510 --> 00:28:33,790 And also, once we find this collision, we can kind of sit on it. 368 00:28:33,790 --> 00:28:38,770 And the server selection is like literally any remotely recent Linux kernel. 369 00:28:38,830 --> 00:28:42,330 If your Linux kernel is older than 2014, by the way, you should probably patch. 370 00:28:42,330 --> 00:28:44,030 There's some stuff that you need to deal with. 371 00:28:45,070 --> 00:28:55,930 And as far as like what our target space looks like now, well, there's something that exists a lot more than existed in 2008 or 2012 when some of the other attacks were coming out. 372 00:28:55,930 --> 00:28:58,250 And that's these lovely, lovely public resolvers. 373 00:28:58,430 --> 00:29:00,650 And they're really trusted. 374 00:29:00,770 --> 00:29:06,230 In fact, as I mentioned before, there's entire Central African nations where all the ISPs are going through Google DNS. 375 00:29:06,230 --> 00:29:08,710 Sure would be a shame if somebody did something to Google DNS. 376 00:29:08,830 --> 00:29:09,410 Yeah. 377 00:29:11,350 --> 00:29:16,710 And frankly, don't get me wrong, there's some presuppositions. 378 00:29:16,710 --> 00:29:18,090 There's some difficulty in doing this attack. 379 00:29:18,090 --> 00:29:19,890 You need to find the right set of targets. 380 00:29:19,890 --> 00:29:26,290 But if you poison a resolver, you're attacking everybody who's using these. 381 00:29:26,290 --> 00:29:29,950 And as far as getting a puppet downstream, well, you can be the puppet too. 382 00:29:29,950 --> 00:29:34,170 You can be both the attack server and the puppet because they're public resolvers. 383 00:29:34,170 --> 00:29:35,170 You just enroll yourself. 384 00:29:35,170 --> 00:29:35,930 It's free. 385 00:29:37,690 --> 00:29:44,410 And as I kind of mentioned before, this whole collision finding bit is completely detached from the attack. 386 00:29:44,990 --> 00:29:47,230 Time is on our side as an attacker. 387 00:29:47,650 --> 00:29:50,090 And now it's actually really on our side as an attacker. 388 00:29:51,990 --> 00:29:55,710 The hardest part and the most legwork to find this is in the collisions. 389 00:29:55,930 --> 00:29:58,730 And although they could be found in minutes, we're really in no rush. 390 00:29:58,730 --> 00:30:06,470 We can probably stay around for weeks, months or years because that key that is determining the hash doesn't change until the system reboots. 391 00:30:06,550 --> 00:30:09,130 And I don't know if any of you know a lot about name servers. 392 00:30:09,130 --> 00:30:10,670 They're not going to reboot a lot. 393 00:30:11,030 --> 00:30:12,510 That's bad for the internet. 394 00:30:14,950 --> 00:30:27,690 And we've got some interesting options as well because we can do a lot of really short duration cache attacks because we have a very good idea of what the IP ID is and we can very plausibly do this in the first hit. 395 00:30:27,830 --> 00:30:31,930 And we can also accumulate a ton of matches for multiple name servers, multiple resolvers. 396 00:30:31,930 --> 00:30:42,270 Even if Google is running 101 resolvers and we want to poison 101 name servers, we can just get the collisions all hooked up for that and then just start poisoning away. 397 00:30:42,290 --> 00:30:48,510 And eventually we're going to get poisoned records into every last one of them if we know what the IP IDs are that we need to send. 398 00:30:49,650 --> 00:30:53,570 It's kind of a strange work around for load balancing. 399 00:30:54,750 --> 00:31:02,210 And because we're doing this in one shot, we may not even need a puppet in the case of non-public resolvers. 400 00:31:02,210 --> 00:31:11,190 If you're trying to do this on a corporate network, maybe you don't even need to have something make a request because there's a lot of stuff that happens at midnight and patch Tuesday. 401 00:31:11,350 --> 00:31:19,030 If there's a cron job or some automated client that's going to reach up, I don't know if your blue teams are working midnights, but we can. 402 00:31:19,590 --> 00:31:21,690 And maybe the puppet can be completely passive. 403 00:31:21,690 --> 00:31:33,910 If we see common requests when they're being requested, we know what the time to live is on those records and we can just wait until they go out of cache and have to be requested again by the resolver. 404 00:31:34,070 --> 00:31:41,610 And so we can start actually consider poisoning things that are getting cached every single time because we can very plausibly do it the first time. 405 00:31:41,750 --> 00:31:43,490 And maybe poison isn't even our purpose. 406 00:31:43,490 --> 00:31:47,370 Maybe what we want to do is just DOS the entire world or prevent patch Tuesday from happening. 407 00:31:47,530 --> 00:31:52,630 Which would be very bad if we're an attacker in the middle of a corporate network and the Windows updates aren't coming down anymore. 408 00:31:52,870 --> 00:31:58,510 If we can do poisoning in one shot, we can really mess up a response in one shot too. 409 00:32:02,110 --> 00:32:04,610 So I've said a lot of words up to this point. 410 00:32:04,770 --> 00:32:07,050 What does the actual final attack look like? 411 00:32:07,810 --> 00:32:11,190 So basically we have to pick our targets. 412 00:32:11,190 --> 00:32:13,410 And this is a little difficult to do. 413 00:32:13,410 --> 00:32:21,090 We can at least figure out what the resolver is if we're a downstream puppet or we have some kind of way or it's a public resolver. 414 00:32:21,110 --> 00:32:22,530 And we also find some domains. 415 00:32:22,530 --> 00:32:24,870 Some domains that are likely to send some large responses. 416 00:32:25,150 --> 00:32:28,130 And we have to find some servers that are actually running Linux. 417 00:32:28,130 --> 00:32:31,870 That shouldn't actually be terribly difficult, but it is an important point. 418 00:32:32,430 --> 00:32:39,610 Once we determine the resolver's public IP address for the request, we can just basically evaluate the domain responses to see whether or not we can actually poison anything. 419 00:32:39,610 --> 00:32:44,830 And then we do our collision finding, which should be good again until the name server actually finally restarts. 420 00:32:44,830 --> 00:32:45,750 And then we wait. 421 00:32:48,260 --> 00:32:49,580 Punctual water drinking. 422 00:32:50,200 --> 00:32:58,140 Now, right before we do an attack, we can optionally trick the name server into lowering the PMTU and forcing fragmentation to exactly the number we want it to be. 423 00:32:58,160 --> 00:33:05,520 Or we could also just not and just request for a non-existent domain on DefCon.org. 424 00:33:05,520 --> 00:33:08,300 There's a lot of domains that are using NSEC and NSEC 3. 425 00:33:08,300 --> 00:33:09,680 The responses get quite large. 426 00:33:10,360 --> 00:33:13,600 And then we just query the name server to get the IP ID because we've already found the collision. 427 00:33:13,900 --> 00:33:20,180 And then we do that, yeah, I should say, we do that directly before a known request is about to be sent. 428 00:33:20,180 --> 00:33:21,180 We do the query. 429 00:33:21,180 --> 00:33:24,820 And then we basically send 64 smooth fragments . 430 00:33:24,820 --> 00:33:28,000 We could send only one if we're very confident in ourselves. 431 00:33:28,000 --> 00:33:31,980 But, I mean, if we're doing this, we might as well send the full payload that we could possibly send. 432 00:33:32,340 --> 00:33:37,780 And we do that based on the known IP ID as described in fragmentation considered poisonous. 433 00:33:37,780 --> 00:33:43,360 And I will point you to Hertzberg and Shulman's paper as to what you can do from here because it is all laid out and that paper is nice and old. 434 00:33:45,380 --> 00:33:49,600 So, now's a good time to start talking about how do you actually get around this? 435 00:33:50,860 --> 00:33:52,500 What's the fix, Trafco? 436 00:33:52,500 --> 00:33:54,420 Well, as I said before, I'm not the expert. 437 00:33:54,420 --> 00:33:59,340 So I'm going to hand it over to Brian who is closer to an expert and he can talk about some mitigations. 438 00:34:00,440 --> 00:34:01,820 Thanks, Travis. 439 00:34:03,940 --> 00:34:05,040 I'm Brian Summers. 440 00:34:05,040 --> 00:34:08,380 I work on the resolvers at Cisco. 441 00:34:09,060 --> 00:34:11,520 So this is a really interesting problem. 442 00:34:12,580 --> 00:34:14,400 There are lots of parties involved. 443 00:34:14,400 --> 00:34:17,500 There's the zone owner, the person who owns the data. 444 00:34:17,500 --> 00:34:19,140 There's the name server. 445 00:34:19,300 --> 00:34:23,340 So that's the person that, or that's where the data lives. 446 00:34:23,340 --> 00:34:24,940 Sometimes it's the same as the owner. 447 00:34:24,940 --> 00:34:26,400 Sometimes it's a registrar. 448 00:34:26,400 --> 00:34:28,420 Sometimes it's a third party. 449 00:34:28,700 --> 00:34:33,020 And then there's the resolver that almost never lives with the data. 450 00:34:33,700 --> 00:34:37,120 So the resolver normally lives closer to the client. 451 00:34:37,120 --> 00:34:40,120 And of course, it's the client, the person who actually wants to look up the address. 452 00:34:40,280 --> 00:34:41,420 It's usually an address. 453 00:34:41,420 --> 00:34:46,200 It's not always an address with DNS, but addresses are the most interesting parts. 454 00:34:46,800 --> 00:34:58,440 So really what we're actually trying to avoid here, or what the problem is, is that the attacker is attacking the resolver due to a bug in the name server. 455 00:34:58,960 --> 00:35:06,780 And the name server is holding the data on behalf of the zone owner, and the lie is getting propagated to the client. 456 00:35:06,780 --> 00:35:08,940 So there's a whole ton of people involved here. 457 00:35:09,440 --> 00:35:12,740 And really the attack target is the resolver. 458 00:35:12,740 --> 00:35:14,700 So that makes it my problem. 459 00:35:17,580 --> 00:35:24,860 IP fragmentation has been an issue for years, like since Kaminsky first observed these issues. 460 00:35:25,140 --> 00:35:29,220 So our approach has always been, well, that's easy. 461 00:35:29,220 --> 00:35:30,380 We drop fragments. 462 00:35:31,040 --> 00:35:41,740 DNS has a mechanism built in where when you actually ask a question of the name server, you can say, and by the way, my maximum payload size is X. 463 00:35:41,740 --> 00:35:50,480 So if you set X to something like 1410 and drop all fragments at the resolver, well then the name server is going to respond. 464 00:35:50,480 --> 00:35:56,580 If they respond with something that's less than 1410 bytes and it gets fragmented, then we lose it. 465 00:35:56,580 --> 00:35:57,960 We don't get the response. 466 00:35:59,960 --> 00:36:10,640 And that's never been a problem because really modern day hardware really does have packet sizes of at least 1492 or whatever these numbers are. 467 00:36:12,320 --> 00:36:14,440 So that's how we always played it. 468 00:36:14,440 --> 00:36:18,100 And then we came to try to support DNSSEC. 469 00:36:18,100 --> 00:36:27,480 And DNSSEC RFCs have lots of requirements and those requirements say that we should deal with packet sizes of 4K. 470 00:36:27,500 --> 00:36:32,480 And that's because DNSSEC payloads are much larger and we don't really want to send everything over TCP. 471 00:36:32,480 --> 00:36:34,820 So that seemed like a kind of sensible requirement. 472 00:36:34,900 --> 00:36:37,700 So we had to come up with a solution to this fragment problem. 473 00:36:37,700 --> 00:36:43,260 We wanted to be able to turn on fragments, but not fall victim to these sorts of attacks. 474 00:36:43,940 --> 00:36:48,940 So our first scheme came up with a, as it turns out, a naïve approach. 475 00:36:50,680 --> 00:36:59,040 So our naïve approach was to assume that IP IDs were random because, well, that's what the RFCs say they are. 476 00:36:59,040 --> 00:37:00,460 They're random, right? 477 00:37:00,660 --> 00:37:03,540 And of course, IPv4 has a 16-bit random number. 478 00:37:03,540 --> 00:37:05,180 Well, that's easy to attack. 479 00:37:05,220 --> 00:37:08,020 And IPv6 has a 32-bit random number. 480 00:37:08,020 --> 00:37:09,660 Way, way harder to attack. 481 00:37:09,660 --> 00:37:15,640 IPv6 also uses PMTU to discover what the fragment sizes are. 482 00:37:15,640 --> 00:37:20,000 So that's much more difficult to attack for the attacker as well. 483 00:37:20,200 --> 00:37:30,480 So we naïvely assumed that IPv4 was bad, IPv6 was good, and we implemented something that cleverly marked packets at the firewall. 484 00:37:30,640 --> 00:37:37,560 Marked whether or not they used to be fragments and marked whether or not that first fragment was of a reasonable size, 1280 in our case. 485 00:37:38,060 --> 00:37:54,800 And if stuff arrived at the resolver and it was marked as a fragment at 1280, then we'd cache all of the data in the first 1280 bytes, say that that's absolutely good, and we'd cache all of the remaining data as, kind of, I'm not too sure about this stuff. 486 00:37:54,800 --> 00:37:57,780 And if we ever need to use that data, then we'd actually look it up again. 487 00:37:57,780 --> 00:38:01,240 And we'd look it up over either v6 or TCP. 488 00:38:01,800 --> 00:38:08,580 That seemed like a great idea until Travis came along and pointed out that that didn't actually work because these IDs aren't actually random. 489 00:38:11,750 --> 00:38:13,390 So what do we do? 490 00:38:13,390 --> 00:38:23,670 We could try to do the same thing for IPv6, but that's actually really, really difficult because IPv6 fragments are harder to deal with at the firewall there. 491 00:38:23,710 --> 00:38:28,050 And in fact, well, actually DNS already has this ability built in. 492 00:38:28,050 --> 00:38:35,410 It's the ability that we used to use of limiting the payload size and just expecting things to go over TCP. 493 00:38:35,410 --> 00:38:49,150 So we did some experiments and really when you run a, kind of, public facing resolver, we've observed that more or less, slightly less than .1% of our traffic is TCP traffic. 494 00:38:49,170 --> 00:38:57,830 So if you look at all the queries, for every thousand queries, there's one TCP query and the other 999 are UDP. 495 00:38:58,150 --> 00:39:17,730 And in fact, when you turn on DNSSEC and you start querying all of those big, juicy DNSSEC payloads and you do all of this over UDP, either IPv6 or IPv4, actually that .1% goes all the way up to almost .5%. 496 00:39:17,730 --> 00:39:28,030 So, in fact, the RFCs that say that this is a requirement to be able to handle large packets in UDP is just not true. 497 00:39:29,190 --> 00:39:33,270 So how many people here have heard of DNS Flag Day? 498 00:39:34,950 --> 00:39:37,830 So a handful of people, four or five people. 499 00:39:37,950 --> 00:39:41,310 So DNS Flag Day is a really big deal. 500 00:39:41,830 --> 00:39:58,570 It was a really big deal for me anyway, where the DNS community are basically trying to take some of the awkwardness in DNS, the kind of rule breaking that has been going on for years in the industry and make it not OK anymore. 501 00:39:58,830 --> 00:40:09,630 So there was a DNS Flag Day last year and it was all about whether or not name servers versus resolvers supported eDNS. 502 00:40:09,650 --> 00:40:14,810 So the way resolvers talk to name servers, they'd say, hey, name server, can you talk eDNS? 503 00:40:14,810 --> 00:40:17,690 And it would do this by supplying some eDNS options. 504 00:40:17,730 --> 00:40:22,010 And if it got no response from the name server, it would send another packet. 505 00:40:22,190 --> 00:40:25,230 And if it still didn't get a response, it would try it without eDNS. 506 00:40:25,410 --> 00:40:30,210 And if it got a response, then it would kind of say, OK, this guy doesn't support eDNS and I'm going to continue on. 507 00:40:30,310 --> 00:40:33,890 And there was an awful lot of kind of behavior like that going on. 508 00:40:33,910 --> 00:40:37,270 And Flag Day is all about kind of saying, OK, well, that behavior is not OK anymore. 509 00:40:37,270 --> 00:40:41,570 If you don't behave properly, then things just aren't going to work. 510 00:40:41,930 --> 00:40:44,270 So there's going to be another Flag Day in 2020. 511 00:40:44,370 --> 00:40:47,070 And this Flag Day is all about fragmentation. 512 00:40:47,290 --> 00:40:58,170 I'm not sure the entire DNS community is convinced, but one of my kind of pushes for this Flag Day is going to be fragmentation is not OK. 513 00:40:58,170 --> 00:41:01,790 All resolvers and all name servers don't do fragmentation. 514 00:41:01,790 --> 00:41:13,850 So resolvers will block fragmentation coming inbound from the name servers and the name servers will just configure their UDP payloads to be a maximum of something smaller than their MTU. 515 00:41:18,240 --> 00:41:21,160 Measuring this on a resolver, how do you tell whether you're getting poisoned? 516 00:41:21,160 --> 00:41:24,160 Well, you can look for lots of echo responses. 517 00:41:24,480 --> 00:41:26,520 You could look for IPv6 echo responses. 518 00:41:26,520 --> 00:41:28,660 You could look for IPv4 echo responses. 519 00:41:29,100 --> 00:41:30,380 You could graph them. 520 00:41:31,340 --> 00:41:33,820 If you think you're getting poisoned, what do you do about it? 521 00:41:33,820 --> 00:41:41,780 Like there's limited use in doing any of this sort of stuff, because if somebody attacks you, well, you just have bumps in your graph. 522 00:41:41,780 --> 00:41:44,580 If you can't do anything about it, there's no point in worrying about it. 523 00:41:44,660 --> 00:41:47,560 You need to worry about it and make it not happen in the first place. 524 00:41:49,120 --> 00:41:58,960 So on the name server side, I mean, the name server guys really have almost the same problem, but in reverse. 525 00:42:01,620 --> 00:42:17,820 I guess, yeah, I mean, from a name server point of view, really what you want to do is limit your EDNS buffer sizes or your EDNS payload sizes and avoid fragments altogether. 526 00:42:18,300 --> 00:42:23,500 You can do some clever things, which aren't, as it turns out, too clever. 527 00:42:23,540 --> 00:42:34,500 So with the DNS IP ID 2048 bucket setup, that's all actually hashed using SIP hash. 528 00:42:34,500 --> 00:42:40,720 If you reboot your server, you can receive that SIP hash and you can basically give everybody new slots in the array. 529 00:42:41,060 --> 00:42:43,080 But, well, how long does it take to reboot your server? 530 00:42:43,080 --> 00:42:48,520 And even if you did introduce a way of kind of saying, OK, we seed now, really, what are you going to do? 531 00:42:48,600 --> 00:42:49,860 Run that every second? 532 00:42:49,860 --> 00:42:52,940 Well, why don't you just choose random numbers in the first place? 533 00:42:55,580 --> 00:42:58,840 So again, yeah, the answer for name servers is to do the same. 534 00:42:58,840 --> 00:43:00,080 Don't send fragments. 535 00:43:01,900 --> 00:43:07,620 And again, you can you can try to avoid them guessing things at the name server. 536 00:43:07,620 --> 00:43:13,860 You could tar pit ICOMPS, but really they could do exactly the same attack over DNS. 537 00:43:14,140 --> 00:43:20,360 And you'll never be able to notice that because it'll be a drop in the ocean in terms of the number of queries that you're actually getting. 538 00:43:20,360 --> 00:43:23,020 So like even if you graph that, you're not even going to see it. 539 00:43:25,900 --> 00:43:29,760 And of course, you can go a little bit more hardcore and you can rebuild your kernel. 540 00:43:29,760 --> 00:43:33,260 You can make this IBI dense size, which is set to 2048. 541 00:43:33,260 --> 00:43:38,260 You can make that a bigger number or you could just change the code and actually make a bigger random number. 542 00:43:40,640 --> 00:43:54,040 And for domains, for the domain owner, like if you're a domain owner and you don't really know what your name server is going to do and you don't really know what the resolvers in between are going to do, well, really your only hope is to use DNSSEC. 543 00:43:54,040 --> 00:43:59,180 And the big flaw in DNSSEC, as Travis said, is delegations. 544 00:43:59,480 --> 00:44:03,460 Delegations are fine if you're delegating to another signed zone. 545 00:44:03,460 --> 00:44:09,860 If you're delegating to an unsigned zone, then actually the unsigned zone is very vulnerable because your delegations aren't secured. 546 00:44:11,460 --> 00:44:17,200 And remember that DNSSEC, all that tells you is whether or not something is good or not. 547 00:44:17,520 --> 00:44:20,340 It doesn't stop denial of services. 548 00:44:20,380 --> 00:44:24,000 So it's not the answer to everything, but it's the answer to most things these days. 549 00:44:27,020 --> 00:44:34,240 And yeah, of course, if you're using DNSSEC, make sure that you've got reasonable sized keys. 550 00:44:34,260 --> 00:44:36,760 Don't go for the lower size keys. 551 00:44:36,760 --> 00:44:38,060 Yeah, don't go for the lower size keys. 552 00:44:38,060 --> 00:44:47,540 And if VeriSign tells you that a key that's going to be up on the internet for 120 days, a 30-day pre-period, then an active period of 90 days, know that RSAs do get broken. 553 00:44:47,540 --> 00:44:51,860 And if your key gets broken, maybe choose a bigger key pair. 554 00:44:52,020 --> 00:44:53,600 Just an idea. 555 00:44:54,640 --> 00:45:04,760 And I guess one of the more exciting things about DNSSEC that's coming out recently, lately, is that it's moving towards elliptic curve technology. 556 00:45:04,760 --> 00:45:07,500 And elliptic curve uses way smaller hash sizes. 557 00:45:07,500 --> 00:45:12,480 So the signatures are, well, not hash sizes, but signature sizes. 558 00:45:12,480 --> 00:45:18,320 So as a result, the signatures are smaller, and you're less likely to actually bump into fragmentation problems anyway. 559 00:45:20,840 --> 00:45:22,720 And yeah, panic. 560 00:45:25,800 --> 00:45:27,040 Maybe panic a little. 561 00:45:27,700 --> 00:45:30,100 All of the resources are up here if you need to screenshot this. 562 00:45:30,100 --> 00:45:33,500 Obviously, the files are probably going to be uploaded somewhere on the DEF CON Media Server at a later point. 563 00:45:34,040 --> 00:45:39,000 And I've been Travis, this has been Brian, and this has been the talk. 564 00:45:46,600 --> 00:45:48,300 I don't know if there are any questions. 565 00:46:18,950 --> 00:46:25,930 So the question was regarding IPID and whether or not we should have released a CVE for it and whether or not this has other implications. 566 00:46:25,930 --> 00:46:27,990 Oh, yeah, this totally has other implications. 567 00:46:28,190 --> 00:46:32,950 This is actually rather terrifying for certain things like online gaming, which are using a lot of UDP. 568 00:46:33,350 --> 00:46:39,690 If you can get in the second fragment of these things, and they're doing all their off in the front, it's bad news. 569 00:46:39,690 --> 00:46:43,370 We could release a CVE, but what's the target for the CVE? 570 00:46:43,410 --> 00:46:44,350 The Internet? 571 00:46:44,490 --> 00:46:48,910 I would have loved to send that to Mitch, but I have a sneaking suspicion it's probably not going to be accepted. 572 00:46:49,310 --> 00:46:51,410 But I do appreciate the question. 573 00:46:51,810 --> 00:46:53,770 It seems like a bit of a target, yeah. 574 00:46:56,570 --> 00:47:12,010 I guess it's worth mentioning as well for IPID that the original RFCs for IP talked about caching fragments for 30 seconds against being able to marry them up with the original and deliver the packet. 575 00:47:12,010 --> 00:47:15,610 That's clearly just not a good idea in this day and age. 576 00:47:15,610 --> 00:47:22,830 In this day and age, caching them for, say, at most 50 milliseconds would probably be way more appropriate. 577 00:47:23,310 --> 00:47:27,350 But I haven't seen any RFCs that suggest that sort of behavior. 578 00:47:27,350 --> 00:47:33,170 I mean, this sort of thing could be mitigated a lot more, certainly raw IPID attacks. 579 00:47:37,510 --> 00:47:38,570 Sorry, say again? 580 00:47:43,770 --> 00:47:44,950 Yes, absolutely. 581 00:47:44,950 --> 00:47:59,490 So you cache it for a smaller amount of time and just fling them away way more eagerly and it will stop lots of second fragment attacks where people are dropping multiple second fragments, hoping that they'll marry up on the IPID. 582 00:48:07,750 --> 00:48:09,050 OK, thank you very much.