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. And without much ado, my pleasure to introduce you to Travis Palmer and Brian Somers. Thank you, folks. So, as you said, this is a quintessential topic in security. 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. 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. 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. So very plausibly, you could turn around and actually use this if you were very quick about it. This is a nice stick to poke people to get actually moving. So without further ado, this is how you become the one in 34 million. So I'm going to go through basically introduce ourselves. Then we're going to go right into, we have to give some background on DNS. A lot of people here are new to DEF CON and relatively new to the security industry. I can't talk about the things that are different if I can't talk about the stuff that's originally. We're going to talk about fragmentation attacks. There's a bit of a history for that. 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. And then we'll go right into the attack. 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. And then Brian, who is actually a proper expert, will be talking about mitigations. So hello, I'm Travis Trafico Palmer. I'm a security research engineer for Cisco Systems. I am an OSCP and OSCE if that means anything to you. And as I kind of implied, yeah, I'm not actually an expert on DNS or DNSSEC. I don't do this on a day-to-day basis. Brian, I don't think would want to call himself an expert, but he's close enough. And he is a principal engineer for Cisco System and has had a lot of free time to work on FreeSB and OpenBSD. So what did we actually do? 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. We took that attack, reduced it from hundreds of iterations to very plausibly one on IPv4. And for IPv6, reduced it from millions of iterations to very plausibly only one. And also because of that, we're basically bypassing all the current recommendations. So even if you're doing everything right as people are telling you, yeah, we can probably still screw your domain. So yes, we did disclose responsibly. I'm, my particular team was discovered this attack during a focus pen test engagement. It was a couple of weeks, but it's a little bit of an unusual pen test engagement to say the least. 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. 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. 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. Still really doesn't have a ton of protections against, but it's getting closer. 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. It has to answer the query. DNS queries and responses are very consistent. So really, we're back to only talking about DNS ID. 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. 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. And this took out basically all of their sources of entropy that were to exist to make it difficult for the attacker. So again, we're back to the 16 bits of DNS ID. And that's really not enough to stop an attack once poison records get saved. If you can try over and over and over again and if you succeed, it gets saved, well, then you're good. You're good to do this off path. You don't need to be in the middle. What do I mean by off path? Have a diagram. So dotted blue line here is the network path from DNS request from the target is taking. And we're off path because our attacker boxes, the red boxes, we're just not on the network path. We can't see anything that's going on there. We might have some idea of what's going on over there. But we can't see or modify the traffic. 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. We have our attacker box off somewhere in the Internet. And then inside of the trust boundary, some corporate network, something that the resolver is servicing. We have both our target and a puppet. The puppet, we don't really have to fully control. It could be as simple as just some JavaScript in a web browser. But what follows is a little less simple. So first the attacker is going to basically figure out where the external facing IP is for the resolver. This can be as simple as basically talking to ourselves, making a request for a domain that we control. 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. The attacker then can just tell their puppet, hey, send a request on my behalf. And since we know what it's requesting and when it's requesting, we can immediately start sending responses to the resolver. 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. Because the resolver is going to make another request on behalf of our puppet. We don't know what the ID is, but we can sure start guessing. And this might take a little while. It's not always going to get cached. Sometimes the legitimate response is going to go straight through the resolver. And so really we do have to find certain types of requests that aren't going to get cached. At least when not modified. This can, you can do this in a couple of different cases. You can do this for zero time to live domains or near zero. A lot of it is content delivery networks, Akamai, CDN, YouTube. A lot of those requests aren't going to live very long in the cache. Or we can start asking for things like domains that don't exist. Which won't get cached. Unless, of course, you then proceed to give a response for them where you say that it is existent. And then you start changing some other things. Like the records for where the name servers are at and other things. Which will, of course, all end up in the cache as well. Once it's in the cache, it also comes down to our puppet. But that doesn't really matter. The important part is that it's saved. So when our poor target machine goes out and asks for it, it gets a response back that it probably shouldn't have gotten. And starts reaching out immediately to the internet for whatever it was trying to reach initially. DNS is a protocol to find other things, ultimately. And reach out to our malicious server. Malicious server goes ahead and gives them, yeah, totally, those binaries that you wanted, yeah, got them. There you go. And that person, if that person wasn't paying attention, they get farmed. The program is reaching out and not checking the TLS certificates. And frankly anything that there's not good verification in place, they get pwned. The end. Just as disturbing as it was a little bit more than a decade ago. Of course, the Kominsky attack doesn't work anymore. I'm glad we've made progress in the past decade. Shortly before that attack was presented, even, various DNS resolver applications were patched to make the UDP ports unpredictable. Dan Kominsky is a white hat after all. So he did tell everybody kind of ahead of time. Needless to say, this puts up a heck of a damper on trying to do this kind of exploit. Because now you have a destination port to guess as well. That's another 16 bits. That's 30.2 bits total. And although you could exclude some of the ports, this is about 65,000 times harder. Though the attack is still high profile and scary, you're not going to be doing this in any kind of feasible scenario. And I'm not going to pretend Kominsky alone made DNSSEC happen, but this did help along. So people scared of DNS being spoofed basically are now using DNSSEC. Without going too far into it, DNSSEC is basically public key infrastructure for domain names. 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. So for example, DEFCON.org, which then used to sign those keys for records. Individual records say where WW.DEFCON.org is. Of course it's a little more complicated than that, but we really can't for sake of time dig into it. A couple of things that DNSSEC adds that are really important is data origin authentication. Basically the ability to verify the data that you're receiving is coming from where it's saying it's coming from. And also trying to make sure that data cannot be modified in transit. 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. That's how cryptography works. Of course, not everybody is actually deploying DNSSEC. And even if you were to deploy DNSSEC on your domains, it's not particularly helpful if the resolvers aren't doing it either. This part, this is really not going too well. And the last report this was made was in 2016. Unless you're in central Africa and your ISP is using Google DNS for everything, you might be in a bad bit of luck. In any case, we need to bring up some more bad news and talk about what DNSSEC doesn't actually do either. Delegation and glue records. Name server, A records for IP addresses located in the authority and additional sections in DNS are not signed. Delegations are records that basically relay authority to another server. So realistically, .com isn't going to know what servers example.com is running. So you have to delegate that authority down. And I had mentioned glue records. 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, include that at the absolute very end of the response. Because otherwise, someone who is looking for some resources in example.com are going to ask the .com domain, okay, where's example.com? It's going to tell, hey, you need to look over here for example.com. And okay, where's the name service for that? We don't know? Okay. Ask .com again. This continues in an infinite loop. So that's why they need to be this. But somebody, of course, in here hopefully is thinking, why aren't these signed? Why can't we just figure out a way to sign this? Well, the RFC says so. It's with actually good reason. It's delegation of duty. Child zones have a private key for authority records and the parent zone really can't be signing it for them. But there's, again, there's data origin authentication. If you can trust that parent, you can probably trust the children as well. And there's, you know, large committees that are rather trustworthy running most of the system. Of course, there's also the deal with all the signatures. All these signatures can make responses quite long, especially if there's lots of records. 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. But how bad could it be? Someone might ask. 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. Seriously? This is our best solution. 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. So Hertzberg and Shulman realized that this was kind of a problem. If the response is getting split up, UDP has no means of dealing with fragmentation. Only really that's TCP. And everything in DNS is running by UDP by default. So it has to be fragmented to the IP layer. And that means it gets an IP identifier. And mind you, these are rather inexact diagrams, but I'm trying to keep it simple. It is IP around UDP around DNS. And in red is basically all the things that an attacker can't really spoof. And that IP identifier is an IP layer 3 thing. It's used on both IPv4 and IPv6. In any case, it's an additional factor source of entropy. We have to guess that it's an attacker. 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. And the second fragment, the only thing we have is that IP layer identifier. Now, DNS actually adds even more stuff. But again, it ends up in the headers or the first couple of things in DNS. Nothing in the second fragment. And as it turns out, the IP ID for IPv4 is 16 bits. This familiar to anybody? As a further bonus, many resolvers when this paper was published were using global counters for IP ID. And it was the default in Windows, default in FreeBSD according to them when they published in 2012. And there was a lot of resolvers they were able to find right before they published it that were doing global IP ID. So what does this attack end up looking like in that particular case? Well, I have to add something to the diagram real quick. We now have an IP fragment cache on this diagram. It holds up to 64 fragments. That's relatively the default. It holds them up so they can be reassembled when and if they all get received. And if nothing else, it drops them after a couple of minutes. In any case, the first thing we do when performing this attack is ask. Sometimes you only need to ask. 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. So we already know what IP ID the name server is using if it's using global IP ID. And then we proceed doing what we were doing before. Puppet goes ahead and asks something on our behalf. And while the name server is still thinking about responding to that, we start guessing IP IDs. And DNS is relatively well structured, very consistent. If you ask for something, you're always going to get roughly the same reply, short of maybe some garbling up in the headers. But again, we don't care about the headers. We're sending the second fragment over and over and over and over again. And we actually have a good starting point. We know what the IP ID was before. And so we can go ahead and just send that sucker along and start guessing everything in front of it. Mind you, it is global, so we have to do this kind of quickly. Other people could be talking into this name server, and they probably are, which is going to increase the IP ID. But we can guess 64 times. 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. And then that's going to go right on up into the cache and then down to our puppet. 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? They're going to get that assembled, but tampered response. And just like a Kominsky's detect before, target makes a query for what was, it gets told it lives with the attacker. It pulls some data from the attacker. It all downhill from there. And pardon me, my mouth is getting really dry. So there's a lot of stuff you can actually do with this. Even with DNSSEC, DNSSEC does limit what you can do with these kind of poisoning attacks. And there's only so much you can really mess with in the cache that isn't directly signed. 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. And they're almost always going to make it in that second fragment. And we get some options. 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. 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. Basically the resolver is not actually doing some good resolving, not checking anything. Yeah, there's a lot of stuff in this you can do immediately if the resolver is not checking DNSSEC. 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. 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. 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. The other thing you can do is basically something in two phases. 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. 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. 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. And if you can just ask what their IP ID is, all you have to do is just mess it up. You don't have to poison anything, you don't have to have it even be correctly structured. If it gets reassembled and it's the wrong way, it's not going to be accepted. 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. All bad news. 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, or as many records as you want into that second fragment. 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. Any case, there are some more limitations to this. This, you folks probably would have heard about this if it had not been for some additional limitations. There's a lot of name servers that aren't deploying with global counters anymore. No real surprise there, that's something we generally expect from the network stack of a printer. 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. Even back in 2012, Linux was using mostly per destination. And we can't query something that gets cached, just kind of like before. 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. And there's also the future. IPv6 throws a complete wrench in this. 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. 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. You're not going to do this. This is literal terabytes of traffic you'd have to send. You're not doing this on IPv6. There's no way. But there has been some notice. 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. Why wouldn't you? And they detect IPv4 fragments and re-query them over TCP or IPv6 if it's, or, ah, pardon me. 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. There was also a presentation this May at ORC, which wasn't us, actually. Now, please excuse the crayon colors. I am taking directly from their slides. But this is a rather pertinent presentation. I had said before this was what we found had bypassed all recommendations. 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. I digress. In any case, this is good news. 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. So now we have to have that little tangent I was talking about before, which might make a little more sense now. So the sequential nature of IPID is largely why idle scanning exists. 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. They need to act like a 1990s printer, basically. 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, you could do this to figure out whether or not traffic was being sent on a link that you can neither see nor control. And it works on fully per destination IPID counters, which is what Linux had. And you can measure how many ‑‑ and you can really just do any kind of measurement across the Internet. Needless to say, the Linux folks didn't appreciate this. And they didn't really want every Linux machine on the Internet being used as a zombie for an idle scan. So around the same time as this paper being published, they created some patches. The first that we care about was to directly prevent measuring communication between two machines. And the second was an optimization to IPID, how IPIDs were handled. So the first one, I did say was a direct mitigation. Well, it doesn't actually completely fix it. Because what it's doing is just making it harder. It's basically incrementing the IPID by a random, but normal, between one and the number of kernel ticks since the last sent packet. This kind of requires keeping track of the last kernel tick values as part of per destination counter. And this makes this operation rather extensive, especially if you have a lot of things to talk to. But it does work. 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. Because if you spend more than one kernel tick in between your polling, you have no idea what's actually coming back. It's properly random. The second one was an optimization. Before the network stack was keeping track of all the IPID counters for all destinations individually and storing them in a binary tree. This caused a lot of performance issues for servers that talk to a lot of clients, like name servers. 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. 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. Now, this does mean that some destination addresses are going to have to share an IPID counter. 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. Perfect. Especially if you have enough bins and hash collisions are rare. That's a low number. 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. And so they, of course, immediately then proceeded to make another idle scanning using the Linux network stack. So basically the way they do this is they use IPV6 to legitimately get very large source address spaces. You could use IPV4, but as we know, that address space is a little bit sparse nowadays. 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. And they increment the IPID counter for the target by spoofing a SYNAC to the target and then query again. 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. Their address. And then they just change addresses if it doesn't appear to line up. Now, why fragmented IPV6 echoes? Well, IPV6 is a little weird because it doesn't fragment the IPID counter unless the traffic is sent fragmented. 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. It's funny, you know, the difference, random number between one and one is always one. Not the best mitigation. Thankfully for most systems, this timing is actually pretty low. Ever since Jiffy's were invented, that counter is about 10 milliseconds, 100 hertz. It could be as low as .66 milliseconds on specialty systems that are running clocks all the way up to 1,500 hertz. But that has to be a very specifically configured OS. Once the collision is found, you can basically just flip this triangle. It's nice. And start doing your idle scan. 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. And they called this not an idle scan. Oh, well. So, there is something that you folks probably have noticed at this point. 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. And, well, hold on now. Why didn't the folks at the University of New Mexico realize that this might have some other implications? Why didn't they realize that this was going to have a huge implication on DNS and fragmentation attacks? Well, they were thinking about idle scanning. I don't blame them. And show of hands, who knew about Hertzberg and Shulman's research before today? No hands. Yeah, you can't blame them. So we get to talk about something new today. So basically this attack, which, mind you, that's what I get for pressing the down arrow. So we start this attack basically the same way as ONUS. 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. But we're going to start by finding collisions just like with ONUS. And instead of a zombie and a target, we basically have a name server and resolver now. The text is a little bit small, but if you noticed, we're using IPV4 in there. Well, what if they're talking over IPV6? What if we need to find collisions on IPV6 addresses like Umbrella was planning on doing? Well, no problem. We'll make them IPV6 echo frags as well. And what about getting our address space? The entire point of using IPV6 to do this particular attack is it's got to be convenient. How convenient is it, Travco? Well, AWS to the rescue. So even the free tier of AWS VPC, virtual private cloud, you can get some IPV6 address space. But the real question is, of course, you know, is it big enough? I haven't done extensive testing, albeit. 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. That is 18 and a half quintillion, give or take a couple dozen quadrillion. 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. 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. 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. And also, once we find this collision, we can kind of sit on it. And the server selection is like literally any remotely recent Linux kernel. If your Linux kernel is older than 2014, by the way, you should probably patch. There's some stuff that you need to deal with. 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. And that's these lovely, lovely public resolvers. And they're really trusted. In fact, as I mentioned before, there's entire Central African nations where all the ISPs are going through Google DNS. Sure would be a shame if somebody did something to Google DNS. Yeah. And frankly, don't get me wrong, there's some presuppositions. There's some difficulty in doing this attack. You need to find the right set of targets. But if you poison a resolver, you're attacking everybody who's using these. And as far as getting a puppet downstream, well, you can be the puppet too. You can be both the attack server and the puppet because they're public resolvers. You just enroll yourself. It's free. And as I kind of mentioned before, this whole collision finding bit is completely detached from the attack. Time is on our side as an attacker. And now it's actually really on our side as an attacker. The hardest part and the most legwork to find this is in the collisions. And although they could be found in minutes, we're really in no rush. 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. And I don't know if any of you know a lot about name servers. They're not going to reboot a lot. That's bad for the internet. 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. And we can also accumulate a ton of matches for multiple name servers, multiple resolvers. 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. 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. It's kind of a strange work around for load balancing. And because we're doing this in one shot, we may not even need a puppet in the case of non-public resolvers. 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. 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. And maybe the puppet can be completely passive. 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. 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. And maybe poison isn't even our purpose. Maybe what we want to do is just DOS the entire world or prevent patch Tuesday from happening. 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. If we can do poisoning in one shot, we can really mess up a response in one shot too. So I've said a lot of words up to this point. What does the actual final attack look like? So basically we have to pick our targets. And this is a little difficult to do. 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. And we also find some domains. Some domains that are likely to send some large responses. And we have to find some servers that are actually running Linux. That shouldn't actually be terribly difficult, but it is an important point. 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. And then we do our collision finding, which should be good again until the name server actually finally restarts. And then we wait. Punctual water drinking. 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. Or we could also just not and just request for a non-existent domain on DefCon.org. There's a lot of domains that are using NSEC and NSEC 3. The responses get quite large. And then we just query the name server to get the IP ID because we've already found the collision. And then we do that, yeah, I should say, we do that directly before a known request is about to be sent. We do the query. And then we basically send 64 smooth fragments. We could send only one if we're very confident in ourselves. But, I mean, if we're doing this, we might as well send the full payload that we could possibly send. And we do that based on the known IP ID as described in fragmentation considered poisonous. 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. So, now's a good time to start talking about how do you actually get around this? What's the fix, Trafco? Well, as I said before, I'm not the expert. So I'm going to hand it over to Brian who is closer to an expert and he can talk about some mitigations. Thanks, Travis. I'm Brian Summers. I work on the resolvers at Cisco. So this is a really interesting problem. There are lots of parties involved. There's the zone owner, the person who owns the data. There's the name server. So that's the person that, or that's where the data lives. Sometimes it's the same as the owner. Sometimes it's a registrar. Sometimes it's a third party. And then there's the resolver that almost never lives with the data. So the resolver normally lives closer to the client. And of course, it's the client, the person who actually wants to look up the address. It's usually an address. It's not always an address with DNS, but addresses are the most interesting parts. 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. And the name server is holding the data on behalf of the zone owner, and the lie is getting propagated to the client. So there's a whole ton of people involved here. And really the attack target is the resolver. So that makes it my problem. IP fragmentation has been an issue for years, like since Kaminsky first observed these issues. So our approach has always been, well, that's easy. We drop fragments. 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. 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. If they respond with something that's less than 1410 bytes and it gets fragmented, then we lose it. We don't get the response. 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. So that's how we always played it. And then we came to try to support DNSSEC. And DNSSEC RFCs have lots of requirements and those requirements say that we should deal with packet sizes of 4K. And that's because DNSSEC payloads are much larger and we don't really want to send everything over TCP. So that seemed like a kind of sensible requirement. So we had to come up with a solution to this fragment problem. We wanted to be able to turn on fragments, but not fall victim to these sorts of attacks. So our first scheme came up with a, as it turns out, a naïve approach. So our naïve approach was to assume that IP IDs were random because, well, that's what the RFCs say they are. They're random, right? And of course, IPv4 has a 16-bit random number. Well, that's easy to attack. And IPv6 has a 32-bit random number. Way, way harder to attack. IPv6 also uses PMTU to discover what the fragment sizes are. So that's much more difficult to attack for the attacker as well. So we naïvely assumed that IPv4 was bad, IPv6 was good, and we implemented something that cleverly marked packets at the firewall. 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. 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. And if we ever need to use that data, then we'd actually look it up again. And we'd look it up over either v6 or TCP. 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. So what do we do? 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. And in fact, well, actually DNS already has this ability built in. It's the ability that we used to use of limiting the payload size and just expecting things to go over TCP. 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. So if you look at all the queries, for every thousand queries, there's one TCP query and the other 999 are UDP. 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%. 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. So how many people here have heard of DNS Flag Day? So a handful of people, four or five people. So DNS Flag Day is a really big deal. 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. So there was a DNS Flag Day last year and it was all about whether or not name servers versus resolvers supported eDNS. So the way resolvers talk to name servers, they'd say, hey, name server, can you talk eDNS? And it would do this by supplying some eDNS options. And if it got no response from the name server, it would send another packet. And if it still didn't get a response, it would try it without eDNS. 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. And there was an awful lot of kind of behavior like that going on. And Flag Day is all about kind of saying, OK, well, that behavior is not OK anymore. If you don't behave properly, then things just aren't going to work. So there's going to be another Flag Day in 2020. And this Flag Day is all about fragmentation. 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. All resolvers and all name servers don't do fragmentation. 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. Measuring this on a resolver, how do you tell whether you're getting poisoned? Well, you can look for lots of echo responses. You could look for IPv6 echo responses. You could look for IPv4 echo responses. You could graph them. If you think you're getting poisoned, what do you do about it? 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. If you can't do anything about it, there's no point in worrying about it. You need to worry about it and make it not happen in the first place. So on the name server side, I mean, the name server guys really have almost the same problem, but in reverse. 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. You can do some clever things, which aren't, as it turns out, too clever. So with the DNS IP ID 2048 bucket setup, that's all actually hashed using SIP hash. If you reboot your server, you can receive that SIP hash and you can basically give everybody new slots in the array. But, well, how long does it take to reboot your server? And even if you did introduce a way of kind of saying, OK, we seed now, really, what are you going to do? Run that every second? Well, why don't you just choose random numbers in the first place? So again, yeah, the answer for name servers is to do the same. Don't send fragments. And again, you can you can try to avoid them guessing things at the name server. You could tar pit ICOMPS, but really they could do exactly the same attack over DNS. 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. So like even if you graph that, you're not even going to see it. And of course, you can go a little bit more hardcore and you can rebuild your kernel. You can make this IBI dense size, which is set to 2048. You can make that a bigger number or you could just change the code and actually make a bigger random number. 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. And the big flaw in DNSSEC, as Travis said, is delegations. Delegations are fine if you're delegating to another signed zone. If you're delegating to an unsigned zone, then actually the unsigned zone is very vulnerable because your delegations aren't secured. And remember that DNSSEC, all that tells you is whether or not something is good or not. It doesn't stop denial of services. So it's not the answer to everything, but it's the answer to most things these days. And yeah, of course, if you're using DNSSEC, make sure that you've got reasonable sized keys. Don't go for the lower size keys. Yeah, don't go for the lower size keys. 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. And if your key gets broken, maybe choose a bigger key pair. Just an idea. 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. And elliptic curve uses way smaller hash sizes. So the signatures are, well, not hash sizes, but signature sizes. So as a result, the signatures are smaller, and you're less likely to actually bump into fragmentation problems anyway. And yeah, panic. Maybe panic a little. All of the resources are up here if you need to screenshot this. Obviously, the files are probably going to be uploaded somewhere on the DEF CON Media Server at a later point. And I've been Travis, this has been Brian, and this has been the talk. I don't know if there are any questions. 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. Oh, yeah, this totally has other implications. This is actually rather terrifying for certain things like online gaming, which are using a lot of UDP. 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. We could release a CVE, but what's the target for the CVE? The Internet? I would have loved to send that to Mitch, but I have a sneaking suspicion it's probably not going to be accepted. But I do appreciate the question. It seems like a bit of a target, yeah. 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. That's clearly just not a good idea in this day and age. In this day and age, caching them for, say, at most 50 milliseconds would probably be way more appropriate. But I haven't seen any RFCs that suggest that sort of behavior. I mean, this sort of thing could be mitigated a lot more, certainly raw IPID attacks. Sorry, say again? Yes, absolutely. 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. OK, thank you very much.