start	end	text
0	6580	This talk was originally going to be at one, but I'm happy, we were happy to bump this talk up
6580	14040	because this is still one of the quintessential topics in security. And without much ado,
14040	18640	my pleasure to introduce you to Travis Palmer and Brian Somers.
23770	28770	Thank you, folks. So, as you said, this is a quintessential topic in security.
28770	32890	We are actually not trying to win any awards for the length of the name of our talk,
32890	37930	but we're pretty sure we might have actually won. And we're going to give you guys not just an update
37930	44330	on kind of the current state of what DNS is, but also go a bit further and actually give you guys
44670	49110	a presentation on an attack that is doable very plausibly against some major resolvers.
49110	53470	From my understanding, Google and some other folks have not really gotten back to us with a firm word
53470	56910	of, yeah, totally, we got this yet. So very plausibly, you could turn around and actually
57370	62470	use this if you were very quick about it. This is a nice stick to poke people to get actually moving.
62470	68770	So without further ado, this is how you become the one in 34 million. So I'm going to go through
68770	71950	basically introduce ourselves. Then we're going to go right into, we have to give some
71950	76230	background on DNS. A lot of people here are new to DEF CON and relatively new to the security
76230	79610	industry. I can't talk about the things that are different if I can't talk about the stuff
79610	82610	that's originally. We're going to talk about fragmentation attacks. There's a bit of a history
82610	88210	for that. And I'm going to talk, trust me, it's not, it's a very important tangent into IPAD
88210	91930	inference and some of the more recent stuff that has come out of University of New Mexico.
92470	96450	And then we'll go right into the attack. I'm not actually affiliated with the folks in University
96450	100750	of New Mexico, but they are very helpful and their white paper was more than enough to get this
100750	105910	attack rolled together. And then Brian, who is actually a proper expert, will be talking about
105910	111670	mitigations. So hello, I'm Travis Trafico Palmer. I'm a security research engineer for Cisco
111670	116670	Systems. I am an OSCP and OSCE if that means anything to you. And as I kind of implied, yeah,
116670	122070	I'm not actually an expert on DNS or DNSSEC. I don't do this on a day-to-day basis.
122070	127110	Brian, I don't think would want to call himself an expert, but he's close enough. And he is a
127110	135930	principal engineer for Cisco System and has had a lot of free time to work on FreeSB and OpenBSD.
135930	140150	So what did we actually do? This is, what we found was a more consistent way to poison the
140150	144270	cache of DNS resolvers without using a man in the middle and using an existing attack
144270	148970	that existed using fragmentation on DNS. We took that attack, reduced it from hundreds of
148970	156550	iterations to very plausibly one on IPv4. And for IPv6, reduced it from millions of iterations
156550	163090	to very plausibly only one. And also because of that, we're basically bypassing all the current
163090	167270	recommendations. So even if you're doing everything right as people are telling you,
167270	173070	yeah, we can probably still screw your domain. So yes, we did disclose responsibly. I'm,
173070	176850	my particular team was discovered this attack during a focus pen test engagement. It was a
176850	180850	couple of weeks, but it's a little bit of an unusual pen test engagement to say the least.
181150	185550	And our team disclosed off to Cisco Umbrella and Umbrella has been disclosing this to other
185550	190090	DNS operators ongoing both before DEF CON and will likely continue to do so after DEF CON as
190090	196690	I'm sure some e-mails might come rolling in. So to start, as I said before, we need to talk
196690	200390	about DNS and what a better place to start than talking about the attacks because we can't really
200390	205170	talk about all of DNS. So in the early DNS, in the way back when, DNS was really only
205170	209670	exploitable in a man in the middle scenario, which it has no protections against. Still
209670	216030	really doesn't have a ton of protections against, but it's getting closer. In any case,
216030	219710	back then, ignoring other protocols, the only thing that was actually keeping a normal DNS
219710	227370	reply from being spoofed, doing things off path, not man in the middle, was the DNS ID
227370	233770	and the styling and the structure of the response itself. It has to answer the query.
234590	240270	DNS queries and responses are very consistent. So really, we're back to only talking about
240270	246270	DNS ID. And again, I said before, ignoring other protocols, there's of course the issue
246270	250390	that this is being sent across the internet and there is this extra level thing called UDP,
250390	252970	which is going to have port numbers and some other things that are going to be very difficult
252970	258090	to guess if you're trying to spoof a DNS reply. And Kaminsky is for original attack basically
258090	261530	determined that a number of implementations of resolvers that were being used were programmed
261530	267890	to query over sequential, very predictable sets of ports. And this took out basically
267890	271130	all of their sources of entropy that were to exist to make it difficult for the attacker.
271130	275730	So again, we're back to the 16 bits of DNS ID. And that's really not enough to stop an attack
275730	281170	once poison records get saved. If you can try over and over and over again and if you succeed,
281170	285390	it gets saved, well, then you're good. You're good to do this off path. You don't need to be
285390	291130	in the middle. What do I mean by off path? Have a diagram. So dotted blue line here is the network
291130	296010	path from DNS request from the target is taking. And we're off path because our attacker boxes,
296010	300690	the red boxes, we're just not on the network path. We can't see anything that's going on there.
300690	306190	We might have some idea of what's going on over there. But we can't see or modify the traffic.
306870	311130	Now, for this particular case, and I'm going to keep this going, this diagram is going to
311130	314430	change a little bit, but it's going to be largely the same. We have our attacker box
314430	318870	off somewhere in the Internet. And then inside of the trust boundary, some corporate network,
318870	324170	something that the resolver is servicing. We have both our target and a puppet. The puppet,
324170	327390	we don't really have to fully control. It could be as simple as just some JavaScript in a web
327390	333770	browser. But what follows is a little less simple. So first the attacker is going to basically
333770	338550	figure out where the external facing IP is for the resolver. This can be as simple as basically
338550	342750	talking to ourselves, making a request for a domain that we control. And as long as our box
342750	347550	is also serving as a name server for our own domain, we get the IP address of the resolver.
347550	352810	The attacker then can just tell their puppet, hey, send a request on my behalf. And since we
352810	357730	know what it's requesting and when it's requesting, we can immediately start sending responses to the
357730	362370	resolver. And since everything else is largely predictable, in the case of the Kominsky attack,
362370	366670	even the, even the destination port on UDP is predictable, we can just start guessing DNS IDs.
366770	371710	Because the resolver is going to make another request on behalf of our puppet. We don't know
371710	377210	what the ID is, but we can sure start guessing. And this might take a little while. It's not
377210	379870	always going to get cached. Sometimes the legitimate response is going to go straight
379870	385810	through the resolver. And so really we do have to find certain types of requests that aren't going
385810	393110	to get cached. At least when not modified. This can, you can do this in a couple of different
393110	399970	cases. You can do this for zero time to live domains or near zero. A lot of it is content
399970	404790	delivery networks, Akamai, CDN, YouTube. A lot of those requests aren't going to live very long
404790	409350	in the cache. Or we can start asking for things like domains that don't exist. Which won't get
409350	414050	cached. Unless, of course, you then proceed to give a response for them where you say that it
414050	418010	is existent. And then you start changing some other things. Like the records for where the
418010	421470	name servers are at and other things. Which will, of course, all end up in the cache as well.
422070	426090	Once it's in the cache, it also comes down to our puppet. But that doesn't really matter.
426110	430530	The important part is that it's saved. So when our poor target machine goes out and asks for it,
430530	435410	it gets a response back that it probably shouldn't have gotten. And starts reaching
435410	439810	out immediately to the internet for whatever it was trying to reach initially. DNS is a protocol
439810	445110	to find other things, ultimately. And reach out to our malicious server. Malicious server goes
445110	450250	ahead and gives them, yeah, totally, those binaries that you wanted, yeah, got them. There you go.
450310	453390	And that person, if that person wasn't paying attention, they get farmed. The program is
453390	457230	reaching out and not checking the TLS certificates. And frankly anything that there's not good
457230	461410	verification in place, they get pwned. The end. Just as disturbing as it was a little bit more
461410	466710	than a decade ago. Of course, the Kominsky attack doesn't work anymore. I'm glad we've made
466710	471430	progress in the past decade. Shortly before that attack was presented, even, various DNS
471430	475390	resolver applications were patched to make the UDP ports unpredictable. Dan Kominsky is a white
475390	479970	hat after all. So he did tell everybody kind of ahead of time. Needless to say, this puts up a
479970	485030	heck of a damper on trying to do this kind of exploit. Because now you have a destination port
485650	492250	to guess as well. That's another 16 bits. That's 30.2 bits total. And although you could exclude
492250	499670	some of the ports, this is about 65,000 times harder. Though the attack is still high profile
499670	505630	and scary, you're not going to be doing this in any kind of feasible scenario. And I'm not
505630	510370	going to pretend Kominsky alone made DNSSEC happen, but this did help along.
513270	520170	So people scared of DNS being spoofed basically are now using DNSSEC. Without going too far
520170	525310	into it, DNSSEC is basically public key infrastructure for domain names. And ICANN,
525310	531470	the highest level of authority, signs for various top level domains like .org, who then in turn
531470	536630	sign the keys used by domains. So for example, DEFCON.org, which then used to sign those keys
536630	542810	for records. Individual records say where WW.DEFCON.org is. Of course it's a little more
542810	548410	complicated than that, but we really can't for sake of time dig into it. A couple of things
548410	553790	that DNSSEC adds that are really important is data origin authentication. Basically the ability
553790	558390	to verify the data that you're receiving is coming from where it's saying it's coming from.
558450	562870	And also trying to make sure that data cannot be modified in transit. Since the records are
562870	566770	signed by the zone owner and the zone's private key, it would be really hard to mess with that
566770	571690	because if it actually gets verified, well, the signatures are not going to line up. That's how
571690	578530	cryptography works. Of course, not everybody is actually deploying DNSSEC. And even if you were
578530	582690	to deploy DNSSEC on your domains, it's not particularly helpful if the resolvers aren't
582690	588570	doing it either. This part, this is really not going too well. And the last report this was
588570	593610	made was in 2016. Unless you're in central Africa and your ISP is using Google DNS for
593610	600230	everything, you might be in a bad bit of luck. In any case, we need to bring up some more bad
600230	606410	news and talk about what DNSSEC doesn't actually do either. Delegation and glue records. Name
606410	611590	server, A records for IP addresses located in the authority and additional sections in DNS are
611590	616550	not signed. Delegations are records that basically relay authority to another server. So
617090	621990	realistically, .com isn't going to know what servers example.com is running. So you have to
621990	626590	delegate that authority down. And I had mentioned glue records. Glue records are largely
626590	631670	fixed to solve an issue of if you have your name server in your domain or there's some concern
631670	635710	about somebody not knowing where your name server is for your domain, you include that at
635710	639830	the absolute end of the request or, pardon me, include that at the absolute very end of the
639830	646290	response. Because otherwise, someone who is looking for some resources in example.com are
646290	650890	going to ask the .com domain, okay, where's example.com? It's going to tell, hey, you need
650890	655070	to look over here for example.com. And okay, where's the name service for that? We don't
655070	660930	know? Okay. Ask .com again. This continues in an infinite loop. So that's why they need to
660930	666090	be this. But somebody, of course, in here hopefully is thinking, why aren't these signed?
666170	671090	Why can't we just figure out a way to sign this? Well, the RFC says so. It's with actually
671090	675590	good reason. It's delegation of duty. Child zones have a private key for authority records
675590	680030	and the parent zone really can't be signing it for them. But there's, again, there's data
680570	684050	origin authentication. If you can trust that parent, you can probably trust the children
684050	688850	as well. And there's, you know, large committees that are rather trustworthy running most of
688850	695070	the system. Of course, there's also the deal with all the signatures. All these signatures
695070	699050	can make responses quite long, especially if there's lots of records. And as a bonus,
699050	704070	name servers can even sign the gaps between valid subdomains and sign nearby names to
704070	709230	prove there's no subdomain in between using NSEC or NSEC 3. But how bad could it be? Someone
709230	715410	might ask. Well, if today you go ahead and ask DefCon.org for a non-existent domain,
715830	723210	they're using NSEC, and so they will respond very verbosely with 1,922 bytes to tell you
723210	730170	something doesn't exist. Seriously? This is our best solution. You can't even send this
730170	734950	across the internet in one piece without expecting it to be fragmented, which is something
734950	743010	we need to talk about. So Hertzberg and Shulman realized that this was kind of a problem.
743010	747490	If the response is getting split up, UDP has no means of dealing with fragmentation. Only
747490	750970	really that's TCP. And everything in DNS is running by UDP by default. So it has to be
750970	758630	fragmented to the IP layer. And that means it gets an IP identifier. And mind you, these
758630	763970	are rather inexact diagrams, but I'm trying to keep it simple. It is IP around UDP around
763970	770150	DNS. And in red is basically all the things that an attacker can't really spoof. And that
770150	774890	IP identifier is an IP layer 3 thing. It's used on both IPv4 and IPv6. In any case, it's
774890	779130	an additional factor source of entropy. We have to guess that it's an attacker. But if
779130	783610	you're noticing, that second fragment's looking a little lonely because all of those QDC signing
783610	787430	bits and the other protocols end up in that first fragment. And the second fragment, the
787430	794010	only thing we have is that IP layer identifier. Now, DNS actually adds even more stuff. But
794010	799990	again, it ends up in the headers or the first couple of things in DNS. Nothing in the second
799990	807430	fragment. And as it turns out, the IP ID for IPv4 is 16 bits. This familiar to anybody?
807910	813070	As a further bonus, many resolvers when this paper was published were using global counters
813070	817610	for IP ID. And it was the default in Windows, default in FreeBSD according to them when
817610	823930	they published in 2012. And there was a lot of resolvers they were able to find right
823930	827630	before they published it that were doing global IP ID. So what does this attack end up looking
827630	831850	like in that particular case? Well, I have to add something to the diagram real quick.
832210	836770	We now have an IP fragment cache on this diagram. It holds up to 64 fragments. That's relatively
836770	841670	the default. It holds them up so they can be reassembled when and if they all get received.
841670	846070	And if nothing else, it drops them after a couple of minutes. In any case, the first thing
846070	851810	we do when performing this attack is ask. Sometimes you only need to ask. As an attacker,
851810	855930	we basically just ask the name server if the response is fragmented or it's IPv4, we get an
855930	859970	IP ID back. So we already know what IP ID the name server is using if it's using global IP
859970	865010	ID. And then we proceed doing what we were doing before. Puppet goes ahead and asks
865010	869710	something on our behalf. And while the name server is still thinking about responding to
869710	874810	that, we start guessing IP IDs. And DNS is relatively well structured, very consistent. If
874810	877630	you ask for something, you're always going to get roughly the same reply, short of maybe
877630	880510	some garbling up in the headers. But again, we don't care about the headers. We're sending
880510	883370	the second fragment over and over and over and over again. And we actually have a good
883370	888390	starting point. We know what the IP ID was before. And so we can go ahead and just send
888390	892850	that sucker along and start guessing everything in front of it. Mind you, it is global, so we
892850	895790	have to do this kind of quickly. Other people could be talking into this name server, and
895790	901090	they probably are, which is going to increase the IP ID. But we can guess 64 times. So at
901090	906670	some point, we're not just going to go through, but we're actually going to be combined with
906670	911070	the first fragment of the original legitimate request, which contains all of the lovely
911070	915690	headers that are signing this thing. And then that's going to go right on up into the cache
915690	919010	and then down to our puppet. But again, the thing we care about most is the cache because
919010	925290	when at a later point, when that poor target machine goes ahead and asks, hey, where's
925290	930250	Defcon.org? They're going to get that assembled, but tampered response. And just like a
930250	935090	Kominsky's detect before, target makes a query for what was, it gets told it lives with the
935090	941710	attacker. It pulls some data from the attacker. It all downhill from there. And pardon me,
941710	950230	my mouth is getting really dry. So there's a lot of stuff you can actually do with this.
950230	954290	Even with DNSSEC, DNSSEC does limit what you can do with these kind of poisoning attacks.
954290	959010	And there's only so much you can really mess with in the cache that isn't directly signed.
959030	962490	But of the four sections, question, answer, authority, and additional, the ones we care
962490	965350	about most with DNSSEC are those last two, the ones that are going to contain the stuff
965350	969730	that's likely to be unsigned. And they're almost always going to make it in that second
969730	976530	fragment. And we get some options. I would love to verbally explain to you all the limitations,
976530	981870	but they made a diagram for me, so I'm going to use the diagram from their paper. So the
981870	987050	main ones you want to look at here, because there's a couple, and that third from bottom
987050	990450	line there is permissive or island. Basically the resolver is not actually doing some good
990450	994150	resolving, not checking anything. Yeah, there's a lot of stuff in this you can do immediately
994150	998830	if the resolver is not checking DNSSEC. But for the other cases when everything is in
998830	1002730	line doing what it's supposed to do, there's other stuff you can still do. So if you're
1002730	1007250	using NSEC 3, and you're using it with an opt-out, that means you're not signing delegations
1007250	1011790	with NSEC 3. And that means that if someone were to say, I don't know, replace one of
1011790	1016750	your NSEC 3 records with an NS record for a subdomain, yeah, that subdomain exists now
1016750	1021830	as far as your resolver is concerned. The other thing you can do is basically something
1021830	1028690	in two phases. You can do NS hijacking, which if you've noticed, doesn't have a lot of requirements,
1028690	1033310	and name server blocking, which again doesn't have a lot of requirements, at the same time.
1033310	1038210	Basically what you do is you poison an NS record that makes it in the cache, and then
1038210	1042970	you start performing server blocking on all the other name servers. And it's actually
1042970	1046650	really easy to do name server blocking, because the only thing you have to do is ruin the
1046650	1051570	responses from all those other name servers. And if you can just ask what their IP ID is,
1051570	1054890	all you have to do is just mess it up. You don't have to poison anything, you don't have
1054890	1058750	to have it even be correctly structured. If it gets reassembled and it's the wrong way,
1058750	1064450	it's not going to be accepted. And for most DNS software, and unbound particularly, two
1064450	1068870	failed queries at a 15 minute interval, that name, that resolver marks that name server
1068870	1074110	as not responsive. All bad news. And if that last slide wasn't concerning enough, there's
1074110	1077190	also the possibility the attacker could cause fragmentation by tricking the name server
1077190	1082130	into believing that it needs to further fragment traffic, which of course helps get a complete
1082130	1086770	record into that second fragment, or as many records as you want into that second fragment.
1086870	1090070	And this does work on IPv6 as well, and there's been a couple of studies done that you can
1090070	1095410	get this stuff well below what should be the minimum transmission unit. Any case, there
1095410	1099370	are some more limitations to this. This, you folks probably would have heard about this
1099370	1103890	if it had not been for some additional limitations. There's a lot of name servers that aren't
1103890	1108150	deploying with global counters anymore. No real surprise there, that's something we generally
1108150	1113030	expect from the network stack of a printer. Windows is still, as far as we know, using
1113210	1117010	a global counter, but FreeBSD is now using a mostly random searchable queue system and
1117010	1121950	Linux still isn't using global counters. Even back in 2012, Linux was using mostly
1121950	1127070	per destination. And we can't query something that gets cached, just kind of like before.
1127070	1130730	A significant portion of the difficulty here is finding the query that returns a predictable
1130730	1134510	fragmented response, and sometimes the options for a given target are pretty slim, and maybe
1134510	1142710	just the response to the any query is enough, but it can be dicey. And there's also the
1142710	1150010	future. IPv6 throws a complete wrench in this. 32 bits in trying to guess with IPv6, that
1150010	1159130	puts you in the territory of 34 million iterations, and that's doing it on average. The actual
1159130	1163450	case for exhausting the entire key space, and this is assuming stuff isn't moving or
1163450	1169070	other people are talking to this name server, is around 67 million. You're not going to
1169070	1173290	do this. This is literal terabytes of traffic you'd have to send. You're not doing this
1173290	1179850	on IPv6. There's no way. But there has been some notice. This is kind of a bit of a thing
1179850	1186010	for IPv4, and prior to our engagement with Umbrella, their implementation was using IPv6
1186010	1190730	whenever possible. Why wouldn't you? And they detect IPv4 fragments and re-query them over
1190730	1198770	TCP or IPv6 if it's, or, ah, pardon me. Read, re-query it over IPv6 where possible and
1198770	1204150	basically re-query over TCP if that still fails or you can't just query over IPv6. There
1204150	1211870	was also a presentation this May at ORC, which wasn't us, actually. Now, please excuse the
1211870	1220110	crayon colors. I am taking directly from their slides. But this is a rather pertinent
1220110	1224730	presentation. I had said before this was what we found had bypassed all recommendations.
1224730	1228190	Yeah, this is kind of the weird case because in an earlier slide in this presentation,
1228190	1232470	they had said drop all fragments, but then here they say, well, the attack's only effective
1232470	1238010	on IPv4 and kind of directly implied IPv6 is safe. I digress. In any case, this is good
1238010	1243850	news. There's interested parties and the people who are the major operators of DNS are generally
1243850	1248930	trying to loose, tie up all the loose ends without any major performance impact. So now
1248930	1252790	we have to have that little tangent I was talking about before, which might make a little
1252790	1258510	more sense now. So the sequential nature of IPID is largely why idle scanning exists.
1258510	1262570	It's what Nmap uses, but as a lot of people here may know, the kind of scan has some requirements
1262570	1269070	for zombies, namely global counters, and also they have to kind of be idle machines. They
1269070	1274470	need to act like a 1990s printer, basically. I won't explain what this particular team
1274470	1279090	found in depth because we really don't have the time, but in a somewhat similar manner
1279090	1283290	to idle scanning, a university of New Mexico research team developed a way to abuse the
1283290	1289210	IP fragment cache in Linux machines to basically determine if something had been sent and much
1289210	1294810	like idle scanning, you could do this to figure out whether or not traffic was being sent
1294810	1300310	on a link that you can neither see nor control. And it works on fully per destination IPID
1300310	1304290	counters, which is what Linux had. And you can measure how many ‑‑ and you can really
1304290	1308090	just do any kind of measurement across the Internet. Needless to say, the Linux folks
1308090	1313390	didn't appreciate this. And they didn't really want every Linux machine on the Internet
1313390	1317970	being used as a zombie for an idle scan. So around the same time as this paper being published,
1318370	1323910	they created some patches. The first that we care about was to directly prevent measuring
1323910	1330090	communication between two machines. And the second was an optimization to IPID, how IPIDs
1330090	1335190	were handled. So the first one, I did say was a direct mitigation. Well, it doesn't
1335190	1341070	actually completely fix it. Because what it's doing is just making it harder. It's
1341070	1348170	basically incrementing the IPID by a random, but normal, between one and the number of
1348170	1352290	kernel ticks since the last sent packet. This kind of requires keeping track of the last
1352290	1355750	kernel tick values as part of per destination counter. And this makes this operation rather
1355750	1360930	extensive, especially if you have a lot of things to talk to. But it does work. And if
1360930	1366170	your interest was trying to do a long-term idle scan or a long-term query as to what was
1366170	1369390	going on between two machines, yeah, this is going to make it real hard for you to do
1369390	1373010	that. Because if you spend more than one kernel tick in between your polling, you have no
1373010	1377450	idea what's actually coming back. It's properly random. The second one was an
1377450	1382910	optimization. Before the network stack was keeping track of all the IPID counters for all
1382910	1386190	destinations individually and storing them in a binary tree. This caused a lot of
1386190	1391470	performance issues for servers that talk to a lot of clients, like name servers. And since
1391470	1396070	every comp sci graduate knows that O of a constant is much better than O of long N, they
1396070	1400590	made a new way based on hashing and binning. So destination addresses, both IPV4 and IPV6
1400590	1405450	are hashed to match it with a bin, which will contain the current IPID counter, which will
1405450	1409970	then be used on the next thing that gets sent out the port. Now, this does mean that some
1409970	1414610	destination addresses are going to have to share an IPID counter. So to prevent an outsider
1414610	1418990	knowing which addresses are sharing a bin, the seed for this hash function, which is doing all
1418990	1423510	the determination, is secret and determined at boot. Perfect. Especially if you have
1423510	1431470	enough bins and hash collisions are rare. That's a low number. Now, if you think this is kind
1431470	1436810	of low, like I think this is kind of low, the researchers at University of New Mexico would
1436810	1440810	agree with you. And so they, of course, immediately then proceeded to make another idle
1440810	1446490	scanning using the Linux network stack. So basically the way they do this is they use
1446490	1451570	IPV6 to legitimately get very large source address spaces. You could use IPV4, but as we
1451570	1455330	know, that address space is a little bit sparse nowadays. And all these sources, they
1455330	1461970	query the IPID counter for their IPID address with a fragmented ICMP6 echo request, which
1461970	1468070	then returns a fragmented response. And they increment the IPID counter for the target by
1468070	1472950	spoofing a SYNAC to the target and then query again. Basically figuring out the hard way
1472950	1477810	whether or not the talking and the spoofing they're doing is in the same bin as what
1477810	1482550	they're able to query on. Their address. And then they just change addresses if it doesn't
1482550	1487630	appear to line up. Now, why fragmented IPV6 echoes? Well, IPV6 is a little weird because
1487630	1491710	it doesn't fragment the IPID counter unless the traffic is sent fragmented. And, well,
1491710	1495900	all of the above requests as an extra stipulation have to arrive within one system tick, one
1495900	1500040	kernel tick of another to force that random perturbation of one to the number of kernel
1500040	1503740	ticks to always be one. It's funny, you know, the difference, random number between one
1503740	1509000	and one is always one. Not the best mitigation. Thankfully for most systems, this timing is
1509000	1515360	actually pretty low. Ever since Jiffy's were invented, that counter is about 10 milliseconds,
1515360	1522460	100 hertz. It could be as low as .66 milliseconds on specialty systems that are running clocks
1522460	1531300	all the way up to 1,500 hertz. But that has to be a very specifically configured OS. Once
1531300	1539440	the collision is found, you can basically just flip this triangle. It's nice. And start
1539440	1543900	doing your idle scan. Basically instead of trying to figure out whether or not you have
1544040	1547660	a collision with a target, you can start sending stuff off to another machine and see whether
1547660	1552360	it responds back to this machine that you're doing the querying for. And they called this
1552360	1562160	not an idle scan. Oh, well. So, there is something that you folks probably have noticed
1562160	1566620	at this point. This is a lot of knowledge that you can get about the IPIDs and the state
1566620	1573040	of IPIDs and the IPIDs for communications to other machines. And, well, hold on now.
1573040	1575740	Why didn't the folks at the University of New Mexico realize that this might have some
1575740	1578880	other implications? Why didn't they realize that this was going to have a huge implication
1578880	1583060	on DNS and fragmentation attacks? Well, they were thinking about idle scanning. I don't
1583060	1587500	blame them. And show of hands, who knew about Hertzberg and Shulman's research before today?
1589120	1596880	No hands. Yeah, you can't blame them. So we get to talk about something new today. So
1596880	1606190	basically this attack, which, mind you, that's what I get for pressing the down arrow. So
1607350	1613470	we start this attack basically the same way as ONUS. And no, for those of you who are
1613470	1618670	about to ask, I am not going to call this ANIS or actually not an idle scan for various
1618670	1622870	reasons. But we're going to start by finding collisions just like with ONUS. And instead
1622870	1626930	of a zombie and a target, we basically have a name server and resolver now. The text is
1627030	1631650	a little bit small, but if you noticed, we're using IPV4 in there. Well, what if they're
1631650	1635450	talking over IPV6? What if we need to find collisions on IPV6 addresses like Umbrella
1635450	1642610	was planning on doing? Well, no problem. We'll make them IPV6 echo frags as well. And
1642610	1647430	what about getting our address space? The entire point of using IPV6 to do this particular
1647430	1657670	attack is it's got to be convenient. How convenient is it, Travco? Well, AWS to the rescue. So
1657670	1662370	even the free tier of AWS VPC, virtual private cloud, you can get some IPV6 address space.
1662370	1667350	But the real question is, of course, you know, is it big enough? I haven't done extensive
1667350	1672550	testing, albeit. But I'm going to say that this is probably enough for those folks that
1672550	1678130	can't count commas as fast as the slide is going to be up. That is 18 and a half quintillion,
1678130	1682510	give or take a couple dozen quadrillion. Mind you, statistically, it only takes about 10,000
1682510	1689090	addresses to get a 99.2% chance of a collision because there's only 2,048 bins. And this is
1689090	1694350	outright better than trying to do global IP name servers, global IP ID for name servers because
1694350	1700710	in this scenario, we get protection. We get that added improvement of all the other bits of
1700710	1707210	binning and if there's a couple of random hosts on the internet, 2,047 of them aren't going to
1707210	1714190	mess with our IP ID. And also, once we find this collision, we can kind of sit on it. And the
1714190	1719990	server selection is like literally any remotely recent Linux kernel. If your Linux kernel is
1719990	1723290	older than 2014, by the way, you should probably patch. There's some stuff that you need to
1723290	1729150	deal with. And as far as like what our target space looks like now, well, there's something
1729150	1735170	that exists a lot more than existed in 2008 or 2012 when some of the other attacks were
1735170	1741210	coming out. And that's these lovely, lovely public resolvers. And they're really trusted. In
1741210	1744990	fact, as I mentioned before, there's entire Central African nations where all the ISPs are
1744990	1748710	going through Google DNS. Sure would be a shame if somebody did something to Google DNS.
1748830	1757010	Yeah. And frankly, don't get me wrong, there's some presuppositions. There's some
1757010	1761590	difficulty in doing this attack. You need to find the right set of targets. But if you
1761590	1767710	poison a resolver, you're attacking everybody who's using these. And as far as getting a puppet
1767710	1772270	downstream, well, you can be the puppet too. You can be both the attack server and the puppet
1772270	1778770	because they're public resolvers. You just enroll yourself. It's free. And as I kind of
1778770	1784410	mentioned before, this whole collision finding bit is completely detached from the attack.
1784990	1789410	Time is on our side as an attacker. And now it's actually really on our side as an
1789410	1796130	attacker. The hardest part and the most legwork to find this is in the collisions. And
1796130	1799870	although they could be found in minutes, we're really in no rush. We can probably stay
1799870	1804270	around for weeks, months or years because that key that is determining the hash doesn't
1804270	1808510	change until the system reboots. And I don't know if any of you know a lot about name
1808510	1817170	servers. They're not going to reboot a lot. That's bad for the internet. And we've got
1817170	1822430	some interesting options as well because we can do a lot of really short duration cache
1822430	1826230	attacks because we have a very good idea of what the IP ID is and we can very plausibly
1826230	1830710	do this in the first hit. And we can also accumulate a ton of matches for multiple name
1830710	1836250	servers, multiple resolvers. Even if Google is running 101 resolvers and we want to poison
1836250	1841210	101 name servers, we can just get the collisions all hooked up for that and then just start
1841210	1845570	poisoning away. And eventually we're going to get poisoned records into every last one
1845570	1851470	of them if we know what the IP IDs are that we need to send. It's kind of a strange work
1851470	1858870	around for load balancing. And because we're doing this in one shot, we may not even need
1859310	1863290	a puppet in the case of non-public resolvers. If you're trying to do this on a corporate
1863290	1868490	network, maybe you don't even need to have something make a request because there's a
1868490	1873290	lot of stuff that happens at midnight and patch Tuesday. If there's a cron job or some
1873290	1876710	automated client that's going to reach up, I don't know if your blue teams are working
1876710	1882590	midnights, but we can. And maybe the puppet can be completely passive. If we see common
1882590	1887330	requests when they're being requested, we know what the time to live is on those records
1887330	1893170	and we can just wait until they go out of cache and have to be requested again by the
1893170	1898050	resolver. And so we can start actually consider poisoning things that are getting cached every
1898050	1902790	single time because we can very plausibly do it the first time. And maybe poison isn't
1902790	1906170	even our purpose. Maybe what we want to do is just DOS the entire world or prevent patch
1906170	1909310	Tuesday from happening. Which would be very bad if we're an attacker in the middle of
1909390	1914690	a corporate network and the Windows updates aren't coming down anymore. If we can do poisoning
1914690	1923370	in one shot, we can really mess up a response in one shot too. So I've said a lot of words
1923370	1930370	up to this point. What does the actual final attack look like? So basically we have to
1930370	1934530	pick our targets. And this is a little difficult to do. We can at least figure out what the
1934530	1940010	resolver is if we're a downstream puppet or we have some kind of way or it's a public
1940010	1944030	resolver. And we also find some domains. Some domains that are likely to send some large
1944030	1948450	responses. And we have to find some servers that are actually running Linux. That shouldn't
1948450	1953870	actually be terribly difficult, but it is an important point. Once we determine the
1953870	1957130	resolver's public IP address for the request, we can just basically evaluate the domain
1957130	1960890	responses to see whether or not we can actually poison anything. And then we do our collision
1960890	1964970	finding, which should be good again until the name server actually finally restarts. And then
1964970	1973140	we wait. Punctual water drinking. Now, right before we do an attack, we can optionally
1973140	1977120	trick the name server into lowering the PMTU and forcing fragmentation to exactly the number
1977120	1984620	we want it to be. Or we could also just not and just request for a non-existent domain on
1984620	1988880	DefCon.org. There's a lot of domains that are using NSEC and NSEC 3. The responses get
1988880	1992700	quite large. And then we just query the name server to get the IP ID because we've already
1992700	1999120	found the collision. And then we do that, yeah, I should say, we do that directly before a
1999120	2004660	known request is about to be sent. We do the query. And then we basically send 64 smooth
2004660	2009380	fragments. We could send only one if we're very confident in ourselves. But, I mean, if we're
2009380	2014380	doing this, we might as well send the full payload that we could possibly send. And we do
2014380	2018000	that based on the known IP ID as described in fragmentation considered poisonous. And I will
2018000	2021440	point you to Hertzberg and Shulman's paper as to what you can do from here because it is all
2021440	2028040	laid out and that paper is nice and old. So, now's a good time to start talking about how do
2028040	2033980	you actually get around this? What's the fix, Trafco? Well, as I said before, I'm not the
2033980	2038420	expert. So I'm going to hand it over to Brian who is closer to an expert and he can talk about
2038420	2039340	some mitigations.
2040440	2050120	Thanks, Travis. I'm Brian Summers. I work on the resolvers at Cisco. So this is a really
2050120	2056460	interesting problem. There are lots of parties involved. There's the zone owner, the person who
2056460	2062520	owns the data. There's the name server. So that's the person that, or that's where the data
2062520	2067460	lives. Sometimes it's the same as the owner. Sometimes it's a registrar. Sometimes it's a
2067460	2074140	third party. And then there's the resolver that almost never lives with the data. So the
2074140	2078540	resolver normally lives closer to the client. And of course, it's the client, the person who
2078540	2082360	actually wants to look up the address. It's usually an address. It's not always an address
2082360	2090760	with DNS, but addresses are the most interesting parts. So really what we're actually trying to
2090760	2096600	avoid here, or what the problem is, is that the attacker is attacking the resolver due to a
2096600	2103500	bug in the name server. And the name server is holding the data on behalf of the zone owner,
2103500	2108940	and the lie is getting propagated to the client. So there's a whole ton of people involved here.
2109440	2118700	And really the attack target is the resolver. So that makes it my problem. IP fragmentation
2118700	2125400	has been an issue for years, like since Kaminsky first observed these issues. So
2125400	2132980	our approach has always been, well, that's easy. We drop fragments. DNS has a mechanism built in
2134480	2139740	where when you actually ask a question of the name server, you can say, and by the way, my
2139740	2146540	maximum payload size is X. So if you set X to something like 1410 and drop all fragments at
2146540	2152580	the resolver, well then the name server is going to respond. If they respond with something that's
2152580	2157960	less than 1410 bytes and it gets fragmented, then we lose it. We don't get the response.
2159960	2165820	And that's never been a problem because really modern day hardware really does have
2165820	2170640	packet sizes of at least 1492 or whatever these numbers are.
2172320	2179400	So that's how we always played it. And then we came to try to support DNSSEC. And DNSSEC RFCs
2179400	2186600	have lots of requirements and those requirements say that we should deal with packet sizes of
2186600	2191440	4K. And that's because DNSSEC payloads are much larger and we don't really want to send
2191440	2195540	everything over TCP. So that seemed like a kind of sensible requirement. So we had to come up
2195540	2200220	with a solution to this fragment problem. We wanted to be able to turn on fragments, but not
2200220	2207640	fall victim to these sorts of attacks. So our first scheme came up with a, as it turns out,
2207660	2217700	a naïve approach. So our naïve approach was to assume that IP IDs were random because, well,
2217700	2222760	that's what the RFCs say they are. They're random, right? And of course, IPv4 has a 16-bit
2222760	2228460	random number. Well, that's easy to attack. And IPv6 has a 32-bit random number. Way, way
2228460	2236460	harder to attack. IPv6 also uses PMTU to discover what the fragment sizes are. So that's much
2236460	2243640	more difficult to attack for the attacker as well. So we naïvely assumed that IPv4 was bad,
2243640	2250940	IPv6 was good, and we implemented something that cleverly marked packets at the firewall. Marked
2250940	2254780	whether or not they used to be fragments and marked whether or not that first fragment was of
2254920	2262000	a reasonable size, 1280 in our case. And if stuff arrived at the resolver and it was marked as a
2262000	2269160	fragment at 1280, then we'd cache all of the data in the first 1280 bytes, say that that's
2269160	2274120	absolutely good, and we'd cache all of the remaining data as, kind of, I'm not too sure about
2274120	2278060	this stuff. And if we ever need to use that data, then we'd actually look it up again. And we'd
2278060	2284460	look it up over either v6 or TCP. That seemed like a great idea until Travis came along and
2284460	2292810	pointed out that that didn't actually work because these IDs aren't actually random. So what do
2292810	2298610	we do? We could try to do the same thing for IPv6, but that's actually really, really difficult
2298610	2305390	because IPv6 fragments are harder to deal with at the firewall there. And in fact, well, actually
2305390	2311150	DNS already has this ability built in. It's the ability that we used to use of limiting the
2311150	2318210	payload size and just expecting things to go over TCP. So we did some experiments and really when
2318210	2326010	you run a, kind of, public facing resolver, we've observed that more or less, slightly less than
2326010	2333150	.1% of our traffic is TCP traffic. So if you look at all the queries, for every thousand queries,
2333150	2340990	there's one TCP query and the other 999 are UDP. And in fact, when you turn on DNSSEC and you
2340990	2349630	start querying all of those big, juicy DNSSEC payloads and you do all of this over UDP, either IPv6
2349630	2361190	or IPv4, actually that .1% goes all the way up to almost .5%. So, in fact, the RFCs that say that
2361190	2370370	this is a requirement to be able to handle large packets in UDP is just not true. So how many
2370370	2379410	people here have heard of DNS Flag Day? So a handful of people, four or five people. So DNS Flag Day
2379410	2387310	is a really big deal. It was a really big deal for me anyway, where the DNS community are basically
2387310	2395090	trying to take some of the awkwardness in DNS, the kind of rule breaking that has been going on for
2395090	2403970	years in the industry and make it not OK anymore. So there was a DNS Flag Day last year and it was
2403970	2411050	all about whether or not name servers versus resolvers supported eDNS. So the way resolvers
2411050	2415750	talk to name servers, they'd say, hey, name server, can you talk eDNS? And it would do this by
2415750	2421370	supplying some eDNS options. And if it got no response from the name server, it would send another
2421370	2426570	packet. And if it still didn't get a response, it would try it without eDNS. And if it got a response,
2426570	2430210	then it would kind of say, OK, this guy doesn't support eDNS and I'm going to continue on.
2430310	2435410	And there was an awful lot of kind of behavior like that going on. And Flag Day is all about kind of
2435410	2440830	saying, OK, well, that behavior is not OK anymore. If you don't behave properly, then things just aren't
2440830	2446010	going to work. So there's going to be another Flag Day in 2020. And this Flag Day is all about
2446010	2454650	fragmentation. I'm not sure the entire DNS community is convinced, but one of my kind of pushes for this
2454650	2460710	Flag Day is going to be fragmentation is not OK. All resolvers and all name servers don't do
2460710	2467310	fragmentation. So resolvers will block fragmentation coming inbound from the name servers and the name
2467310	2473850	servers will just configure their UDP payloads to be a maximum of something smaller than their MTU.
2478240	2483320	Measuring this on a resolver, how do you tell whether you're getting poisoned? Well, you can look for lots of echo
2483320	2489740	responses. You could look for IPv6 echo responses. You could look for IPv4 echo responses. You could graph
2489740	2497300	them. If you think you're getting poisoned, what do you do about it? Like there's limited use in doing any of
2497300	2502360	this sort of stuff, because if somebody attacks you, well, you just have bumps in your graph. If you can't do
2502360	2506720	anything about it, there's no point in worrying about it. You need to worry about it and make it not happen in the
2506720	2518140	first place. So on the name server side, I mean, the name server guys really have almost the same problem, but in
2518140	2531160	reverse. I guess, yeah, I mean, from a name server point of view, really what you want to do is limit your
2531760	2541420	EDNS buffer sizes or your EDNS payload sizes and avoid fragments altogether. You can do some clever things, which
2541420	2553440	aren't, as it turns out, too clever. So with the DNS IP ID 2048 bucket setup, that's all actually hashed using
2553440	2559580	SIP hash. If you reboot your server, you can receive that SIP hash and you can basically give everybody new slots in
2559580	2565060	the array. But, well, how long does it take to reboot your server? And even if you did introduce a way of kind of
2565060	2571340	saying, OK, we seed now, really, what are you going to do? Run that every second? Well, why don't you just choose
2571340	2579320	random numbers in the first place? So again, yeah, the answer for name servers is to do the same. Don't send
2579320	2588840	fragments. And again, you can you can try to avoid them guessing things at the name server. You could tar pit
2588840	2596180	ICOMPS, but really they could do exactly the same attack over DNS. And you'll never be able to notice that because
2596180	2601200	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
2601200	2608920	graph that, you're not even going to see it. And of course, you can go a little bit more hardcore and you can
2608920	2615220	rebuild your kernel. You can make this IBI dense size, which is set to 2048. You can make that a bigger number or
2615220	2623320	you could just change the code and actually make a bigger random number. And for domains, for the domain owner,
2623320	2628520	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
2628520	2635500	know what the resolvers in between are going to do, well, really your only hope is to use DNSSEC. And the big
2635500	2642880	flaw in DNSSEC, as Travis said, is delegations. Delegations are fine if you're delegating to another signed
2642880	2648180	zone. If you're delegating to an unsigned zone, then actually the unsigned zone is very vulnerable because your
2648180	2656400	delegations aren't secured. And remember that DNSSEC, all that tells you is whether or not something is good or
2656400	2663160	not. It doesn't stop denial of services. So it's not the answer to everything, but it's the answer to most things
2663160	2675080	these days. And yeah, of course, if you're using DNSSEC, make sure that you've got reasonable sized keys. Don't go
2675080	2676760	for the lower size keys.
2676760	2680900	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
2680900	2688320	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
2688320	2693600	gets broken, maybe choose a bigger key pair. Just an idea.
2694640	2703100	And I guess one of the more exciting things about DNSSEC that's coming out recently, lately, is that it's moving
2703100	2709980	towards elliptic curve technology. And elliptic curve uses way smaller hash sizes. So the signatures are, well,
2709980	2716380	not hash sizes, but signature sizes. So as a result, the signatures are smaller, and you're less likely to actually
2716380	2722720	bump into fragmentation problems anyway. And yeah, panic.
2725800	2730780	Maybe panic a little. All of the resources are up here if you need to screenshot this. Obviously, the files are
2730780	2736440	probably going to be uploaded somewhere on the DEF CON Media Server at a later point. And I've been Travis,
2736440	2739000	this has been Brian, and this has been the talk.
2746600	2748300	I don't know if there are any questions.
2778950	2784650	So the question was regarding IPID and whether or not we should have released a CVE for it and whether or not
2784650	2788950	this has other implications. Oh, yeah, this totally has other implications. This is actually rather
2788950	2794830	terrifying for certain things like online gaming, which are using a lot of UDP. If you can get in the
2794830	2800230	second fragment of these things, and they're doing all their off in the front, it's bad news. We could
2800230	2805870	release a CVE, but what's the target for the CVE? The Internet? I would have loved to send that to
2805870	2810610	Mitch, but I have a sneaking suspicion it's probably not going to be accepted. But I do appreciate the
2810610	2813770	question. It seems like a bit of a target, yeah.
2816570	2824630	I guess it's worth mentioning as well for IPID that the original RFCs for IP talked about caching
2824630	2832010	fragments for 30 seconds against being able to marry them up with the original and deliver the packet.
2832010	2838750	That's clearly just not a good idea in this day and age. In this day and age, caching them for, say, at
2838750	2845790	most 50 milliseconds would probably be way more appropriate. But I haven't seen any RFCs that
2845790	2851210	suggest that sort of behavior. I mean, this sort of thing could be mitigated a lot more, certainly raw
2851210	2858570	IPID attacks. Sorry, say again?
2863770	2870090	Yes, absolutely. So you cache it for a smaller amount of time and just fling them away way more eagerly
2870090	2875790	and it will stop lots of second fragment attacks where people are dropping multiple second
2875790	2889050	fragments, hoping that they'll marry up on the IPID. OK, thank you very much.
