Saved 10 billion DNS queries per month by disabling DNS Prefetching
pinkbike.com
pinkbike.com
http://www.pinkbike.com/news/search/?q=%3C%2Ftitle%3E%3Cscri...
http://www.pinkbike.com/product/compare/?items=466,%22%3E%3C...
http://www.pinkbike.com/photo/list/?date=all&text=%3C/ti...
http://www.pinkbike.com/buysell/list/?q=%3Cscript%3Ealert%28...
http://www.pinkbike.com/forum/search/?q=%3C/title%3E%3Cscrip...
Edit: I've stopped adding xss's. It's actually harder to find input boxes which don't lead to xss's than ones which do.
But please don't rely on just escaping < and >. You have to worry about double-quotes too, I can end a string and add a "onload" or "onfocus" attribute if it's already in a tag. And sometimes you have to worry about single quotes. In fact, there's a lot to take a look at.
Instead of just fixing the case at hand, try to be proactive about it. Check to make sure you don't have anything else.
Edit: Click the search box, for example. http://www.pinkbike.com/forum/search/?q=%22%20onclick=%22ale...
He is (ab)using subdomains, by giving every user a different subdomain on his site. So a typical page can have links to hundreds of different subdomains on the page.
For a normal site disabling prefetching is not necessary or a good idea.
This article should be renamed: "Why using hundreds of unique subdomains is not a good idea." Besides all the DNS queries, you are also messing with caches.
I don't know anything about his site, but I don't see any reason that every user needs a unique subdomain.
I think the really perplexing about this article is why browsers are so aggressive with DNS prefetching. If there are links on the page to 300 different domains, is there much benefit to precaching ALL of them? It seems clear that very few of the domains are likely to be clicked on. If anything they're probably hurting performance by bombarding the local nameserver with a flood of requests.
It sounds like browsers need a better precaching heuristic.
http://www.davidpashley.com/blog/computing/livejournal-mozil...
It's a tragedy of the commons. Each individual user gains personal performance from DNS prefetching. The gain for each individual user is greater than their loss to their share of the performance penalty imposed on the entire system.
The real super smart answer would be predictive prefetching based on pointer movement. When the browser sees the mouse heading towards a link, start prefetching. Or at least on mouseover.
HttpOnly doesn't really fix the issue though. It prevents evil js from straight-out stealing the cookie, but it can still make HTTP requests that will include the cookies. Therefore the script could still do bad things the user's behalf (add or remove friends, scrape private data, post spam, etc...)
The LJ story is just an example of a general lesson: if you can put user-generated content in a different domain (i.e. browser security context) than your authentication-critical cookies you are in a better position. That way any javascript leakage at evil-user.yourdomain.com can't harm your users any more than if they were viewing it at www.evil-users-domain.com.
http://skeptikal.org/2009/11/cross-subdomain-cookie-attacks....
Consider that publishers often have little control of how many DNS requests they get, so to charge for something out of your control seems utterly bizarre to me. Nice to see in this instance, publisher was able to make a meaningful improvement.
Also keep in mind, I used to run the largest free DNS service in the world so I'm well aware of what I'm talking about and am totally biased on these matters. :-)
More load implies additional cost, and DNS providers are no exception; there is an incremental cost of serving a DNS response. Granted, it's small, but real nonetheless.
One could charge based on bytes transferred instead, but charging for bytes is functionally equivalent to charging for responses.
<meta http-equiv="x-dns-prefetch-control" content="off" />
or, if you're more into HTML5:
<meta http-equiv="x-dns-prefetch-control" content="off">
An example solution at the load balancer level, assuming the use of Varnish:
In vcl_fetch:
if (req.url ~ "\.(htm|html|php)" || req.url ~ "\/(\?.*)?$") {
set beresp.http.disable-dns-prefetch = "1";
}
In vcl_deliver: if (resp.http.disable-dns-prefetch) {
remove resp.http.disable-dns-prefetch;
set resp.http.X-DNS-Prefetch-Control = "off";
}Pedantic.
Anybody at an ISP that can fill us in on DNS TTL mangling or cache limiting?
He is creating thousands of unique subdomains, so nobody can cache anything.
Exact numbers may be off, of course; it was a few years ago.
Even a 128MB RAM VPS could comfortably handle a huge number of requests.
about:config
network.dns.disablePrefetch (true)
network.dns.disablePrefetchFromHTTPS (true) <meta http-equiv="x-dns-prefetch-control" content="off" />If the client needs to know foo.example.com they ask the nearest server. That will have the wildcard and will return the correct address. The nearest server is not going to be the root server for that domain, but something (typically) at the ISP. So the ISP DNS server will see more load, but not the root. Yet this article show the root as getting a huge number of hits. The only explanation I see is that they are not serving wildcard responses when they should be...
- wasted a total of 10sec of each user's time per month.
it's all about trade offs