Once More, With Feeling: URL Shorteners
I got in a quick Twitter discussion last night with @xssedcom, the same guys that run XSSed.com. It came up because a link to LongURL got passed around. LongURL is a service that allows you to paste in links from bit.ly, tr.im or other URL shorteners, and see what the ultimate destination would be. It sounds useful, but there's a few problems with the idea.
I may be preaching to the choir here, but it needs to put in writing. Years from now, you can point to my blog posts and say "This Mike guy, he was a visionary. We really should have listened to him."
First off, LongURL is vulnerable to XSS. If a perfectly innocent-looking bit.ly link can pop an XSS box, it can just as easily rewrite its own page to look like it goes to a completely different location. This is bad, but not as bad as you might think.
Okay, it's as bad as you think, but not for the reasons you expect.
Even assuming that you could reliably see the final destination URL of a website, it would be little-to-no help at all. Sure, you could catch the obvious phishing links, but how many users have the ability to assess the validity of a web page based on its URL? I, and I consider myself a pretty paranoid/savvy web user. URLs don't compromise users. It's the content of the web page. And as has been made abundantly clear time and time again, you cannot trust any web page. Not your own, not your bank's, and certainly not mine.
When people talk about browsing the web safely, they always say something along the lines of "don't browse sketchy sites." No porn, no filesharing, no 4chan. Even if people followed it (and they don't), that advice has been useless for years. Bad guys are delivering malware and XSS attacks through news sites, advertisers, government websites, social networking apps, countless hijacked blogs, forums and ecommerce sites, the list goes on and on.
If you think you can really trust any website at all, you're kidding yourself. If you think that avoiding the shady websites will keep you safe, you're just as naive.
We've been telling users for years now to look in the browser and make sure they're on the right website when they check for the little lock icon. Very few of them do. And the "secure" websites are training them to continue ignoring it. Log in to your online banking. With precious few exceptions, banks are usually outsourcing their online banking to a third party company that's equipped to handle this newfangled web thing. When you log in, you're probably getting 302'ed to a subdomain of some company you've never heard of. Or maybe it's a subdomain of your bank's website, but hosted, managed, and developed by a third party. Even if you did notice, did you ever care? How much attention are you really paying?
And the more important question- how much attention do you think the average user is paying to the website he's on? Most users aren't even looking at that domain name. If they are, they still aren't looking at the rest of the url- the important bits, like where an open framing, open redirect, HTML injection, or flash object poisoning issue is being exploited. They don't have a clue how to evaluate that. Without testing manually, I don't even know for sure what all those bits of the URL do.
But going back to my original point, this isn't all bad, it just takes a shift in approach- a shift that may be already happening. If you assume you can't trust any web site, that means that you absolutely have to trust your web browser. You have to know that no matter where you point it, it will block XSS attacks, prevent CSRF, and pop up a friendly alert box asking your permission before installing malware. If you can't rely on your browser, you're finished.
The good news: browsers are getting crazy good. They get exploited all the time, but new patches often come out within hours. Not weeks. Not months. If you keep them up to date, they're actually some of the best software on your computer. (Yes, there have been some serious failures in the browser industry that would contradict this statement, but they are the exception, and they are getting more rare all the time).
...And the bad news. Currently, your browser does almost nothing to prevent XSS, CSRF, and other client-side web exploits. We're moving in that direction, but you can't rely on it. If you're not browsing with Javascript and Flash disabled, you're not browsing safely.
But you can do better. Echoing on previous themes from this blog, the best thing you can do is prevent Cross-site Requests. If you allow no cross-site requests, you have no problem with cross-site request forgery, no reflected cross-site scripting, no cross-site framing, no cross-site flashing, no open redirects. RequestPolicy. Use it. Remember my post earlier this week about boundaries being the key to security? NoScript is the spermacidal lubricant of the web. RequestPolicy is the condom.
If you're really paranoid enough to check your links with something like LongURL, you should be using RequestPolicy. As a side benefit, it blocks off-site redirects, so when you click that bit.ly link, you'll be presented with a server-generated 302 page saying "click here if you're not automatically redirected." You can then examine the URL (or more likely, ignore it), and click through.
Well would you look at at that... a short-url-expander, built right into your browser. What a novel idea.
Edited on 5/28/2010 to say "no reflected cross-site scripting" in the RequestPolicy paragraph. XSS still works, if it's same-site or permanent XSS, but even they get harder to pull off.
I may be preaching to the choir here, but it needs to put in writing. Years from now, you can point to my blog posts and say "This Mike guy, he was a visionary. We really should have listened to him."
First off, LongURL is vulnerable to XSS. If a perfectly innocent-looking bit.ly link can pop an XSS box, it can just as easily rewrite its own page to look like it goes to a completely different location. This is bad, but not as bad as you might think.
Okay, it's as bad as you think, but not for the reasons you expect.
Even assuming that you could reliably see the final destination URL of a website, it would be little-to-no help at all. Sure, you could catch the obvious phishing links, but how many users have the ability to assess the validity of a web page based on its URL? I, and I consider myself a pretty paranoid/savvy web user. URLs don't compromise users. It's the content of the web page. And as has been made abundantly clear time and time again, you cannot trust any web page. Not your own, not your bank's, and certainly not mine.
When people talk about browsing the web safely, they always say something along the lines of "don't browse sketchy sites." No porn, no filesharing, no 4chan. Even if people followed it (and they don't), that advice has been useless for years. Bad guys are delivering malware and XSS attacks through news sites, advertisers, government websites, social networking apps, countless hijacked blogs, forums and ecommerce sites, the list goes on and on.
If you think you can really trust any website at all, you're kidding yourself. If you think that avoiding the shady websites will keep you safe, you're just as naive.
We've been telling users for years now to look in the browser and make sure they're on the right website when they check for the little lock icon. Very few of them do. And the "secure" websites are training them to continue ignoring it. Log in to your online banking. With precious few exceptions, banks are usually outsourcing their online banking to a third party company that's equipped to handle this newfangled web thing. When you log in, you're probably getting 302'ed to a subdomain of some company you've never heard of. Or maybe it's a subdomain of your bank's website, but hosted, managed, and developed by a third party. Even if you did notice, did you ever care? How much attention are you really paying?
And the more important question- how much attention do you think the average user is paying to the website he's on? Most users aren't even looking at that domain name. If they are, they still aren't looking at the rest of the url- the important bits, like where an open framing, open redirect, HTML injection, or flash object poisoning issue is being exploited. They don't have a clue how to evaluate that. Without testing manually, I don't even know for sure what all those bits of the URL do.
But going back to my original point, this isn't all bad, it just takes a shift in approach- a shift that may be already happening. If you assume you can't trust any web site, that means that you absolutely have to trust your web browser. You have to know that no matter where you point it, it will block XSS attacks, prevent CSRF, and pop up a friendly alert box asking your permission before installing malware. If you can't rely on your browser, you're finished.
The good news: browsers are getting crazy good. They get exploited all the time, but new patches often come out within hours. Not weeks. Not months. If you keep them up to date, they're actually some of the best software on your computer. (Yes, there have been some serious failures in the browser industry that would contradict this statement, but they are the exception, and they are getting more rare all the time).
...And the bad news. Currently, your browser does almost nothing to prevent XSS, CSRF, and other client-side web exploits. We're moving in that direction, but you can't rely on it. If you're not browsing with Javascript and Flash disabled, you're not browsing safely.
But you can do better. Echoing on previous themes from this blog, the best thing you can do is prevent Cross-site Requests. If you allow no cross-site requests, you have no problem with cross-site request forgery, no reflected cross-site scripting, no cross-site framing, no cross-site flashing, no open redirects. RequestPolicy. Use it. Remember my post earlier this week about boundaries being the key to security? NoScript is the spermacidal lubricant of the web. RequestPolicy is the condom.
If you're really paranoid enough to check your links with something like LongURL, you should be using RequestPolicy. As a side benefit, it blocks off-site redirects, so when you click that bit.ly link, you'll be presented with a server-generated 302 page saying "click here if you're not automatically redirected." You can then examine the URL (or more likely, ignore it), and click through.
Well would you look at at that... a short-url-expander, built right into your browser. What a novel idea.
Edited on 5/28/2010 to say "no reflected cross-site scripting" in the RequestPolicy paragraph. XSS still works, if it's same-site or permanent XSS, but even they get harder to pull off.
Labels: URL Shortening

