Hacking the <a> tag in 100 characters
bilaw.al
bilaw.al
This is an attack which targets people who are carefully checking the link URL before clicking, but who then ignore the actual content of their URL bar. That has to be a pretty limited group, right? And this is far from the only way to spoof a link in JavaScript, so to really make this impossible would mean disabling swaths of functionality used widely across the web, i.e. not gonna happen.[0]
And it's counterproductive. Since the birth of the web we've been trying to drill into people's skulls not to trust anything except what it says in your URL bar after "https:". We need to avoid anything that would give users any other impression.
That said, there is a useful message here, not "this is a problem with JavaScript" but "this is another reason you must personally validate the domain name before entering any personal information."
[0] On a large scale, that is. Obviously some people here are comfortable with disabling swaths of JavaScript across the web.
There are, most of the time, undisclosed zero day attacks in the wild, for most browsers and plugins.
I should add that I check the URL bar when I enter information, but not always when I browse casually. I always check the target of links, though, and this could trick me.
I wouldn't be surprised if some users never read the URL bar... people who can't tell a browser from a search engine, for example.
Example a link to an article or PDF report of interest is Hijacked via this method (where the hover is correct but actual target is malicious) the user quickly hits the exploit site and is compromised/malware dropped while the exploit site displays a splash page of some sort briefly, it then forwards to the orig. destination.
I don't see the majority of non paranoid users detecting this, even if they are in the right mindset, as they end up at the proper site with nothing more than quick, and now ubiquitous, splash/ad page in between.
EDIT: I'm not necessarily advocating any change, this behavior can be tracked and blocked in a properly secured infrastructure, but this is where I see the potential for harm.
If the bad guys can inject Javascript into your page, it's game over, period. The attack vector is meaningless; there are tons of them. If I can inject my Javascript into your page to hijack your clicks, why would I bother with that rather than just putting an invisible iframe into the page that delivers the payload without any user interaction required? It's going to get me far better results, doesn't rely on undocumented behavior, and isn't contingent on a user failing to notice a splash screen.
To protect yourself against this, you should go into Chrome's about:settings/content and set Plugins to "click-to-play", so that you have to manually allow a plugin to execute, preventing this kind of drive-by attack.
While perhaps this should be true, I don't think it is. I don't recall any internet instruction manual advising people to check the domain and browsers don't exactly emphasize the domain.
False redirections is the principle. I'm not sure how to fully eradicate it in that sense, but I think to bring attention to the possibility is somewhat beneficial rather than sensationalist.
Not that bad, but still kinda sucky.
$("a").click(function(e){
e.preventDefault();
document.location="http://evilsite.paypa1.com";
});
In either case, a right-click to open or copy/paste sidesteps, though that's just a kludge.Thus You cannot just "warn users if the location of a link changes to a different domain after they click on it".
That said, this is probably a "wontfix".
Also, nowadays, the whole purpose of SSL certificates is actually doomed due to the "growth" - that is, rogue business people for profit without actual verification. In the beginning, one needed to fax in whole incorporation certificates and the like. Now, it is just like You pay for it, then maybe They phone You, maybe not.
If a malicious hacker can insert some script in a trusted page, security is pretty much completly broken and you have other worries. The fact that you can make links in this page point to other malicious pages seems like a small problems as most people won't even check the domain before clicking the link.
I would think that some users are most likely to check the address bar after clicking the link. But my dad would probably woudn't see anything.
It may be simple code, but I think the title of the post explained that.
if you had success putting your JS payload on target website you can do anything. Period. From from stealing user's passwords (http://homakov.blogspot.com/2012/11/xss-save-your-password-p...) to executing any authorized request POST /send_money. The last thing attacker will do is to "phish" you.
I'm very happy to reassess if you have an example where you do not control the content of the page, but somehow still control the content of the click. That would be really serious and worth fixing.
-John Jansen Principal Test Lead Internet Explorer
<a onClick="this.href=
['mailto',[['john','doe'].join('.'),
['gmail','com'].join('.')].join('@')].join(':')"
href=#click-to-email>
I don't know how good my solution is in protecting from spammers' scrapers but I'd be happy to hear about any alternatives.Various browsers such as Chrome will warn/block you from visiting known malicious sites, but it comes down to being aware of where you are before entering personal information.
I think a better proposal might be getting browsers to warn users if the url they are visiting is sufficiently different from the original href attribute (i.e. different host). Something like this could easily be done with a browser extension (and could handle more cases such as preventDefault + window.location = ...).
I got sent to the dummy page on Opera 12.13 and Chrome 25. Just updated to Opera 12.14 and I still got sent to the dummy page. Running Windows 7.
You can use JavaScript to swap out all the links for spans like these.
If you're on a site that's using intentionally deceptive JavaScript or getting malicious JavaScript injected, whether or not links go where you think they will is the least of your problems.
I like your suggestion to have behavior changed so the browsers don't allow the href to be changed to another domain without warning the user. Until that happens, maybe opening links in a new tab (or window) is a good practice.
Enjoy!
So, if you do not like the javascript events -> disable javascript interpreter in your browser!
It would make more sense to kill IE, ActiveX, Flash and Java-Plugins...
Google Analytics hooks on links to track clicks and exit pages and so on. Would you really enjoy an alert every time you click on something ? I am amazed how you people come up with crap like this.
Enjoy your 5 minutes of traffic while they last
Might be something worthwhile to provide a solution for (possibly even a valid use case for QR codes - pay with phone on a web site)? But then, not many people will care, I suspect :-/
Do you have scripts disabled? Because it wouldn't work in that case.
Instead of making a big deal out of it (phishing 2.0? really?), why not focus on phishing detection and prevention instead? I do it by using LastPass with randomly generated passwords that I don't actually know. I have to go to LastPass for my login information, and it provides information filtered by the domain I'm on. If I'm on badsite.com rather than paypal.com, LastPass won't offer my PayPal information to fill. Problem solved.
Phishing is an everpresent problem, and does require vigilance from both browser vendors and users, but I really don't think that this contributes to the problem in any significant way, simply because there are completely legitimate browser features that can be used to exactly the same effect, and for which the differences between "benign" and "hostile" use is entirely subjective and undetectable by software. Fixing this would have exactly no impact on the bad guys' ability to conduct a blind redirection.
It took me a few seconds before I realized how stupid that entire line of thought was.
I think anyone who makes single page web apps uses this "hack" on an everyday basis.
The href is leading to bitly, making much less people believe you.
var links = document.links
is a more efficient way to get an array of all of the links on a page. for(var i=0; i < links.length; j++){ // j++ => i++so read this news carefully and be aware for futue...
This is a little like complaining to Guido van Rossum because of a perceived flaw in Django.
There is no use for this security hole other than to deceive people. Period.
There seems to be a misperception that the URL you see on hover is 100% where you'll go if you click it. No. It's just representing the current state of the href. JS owns the DOM and its interactions. If it wants to intercept a click and rewrite an href or do an e.preventDefault() or redirect with window.location, that is its prerogative. That is the power that it is intended to have. It is this power which makes the modern web work.
If we can't teach people to look at the location bar and check domain names and SSL-related colors and icons, we can't help them avoid phishing. Restricting what basic JS can do so that the possibly fictitious group of people who check the status bar on hover but don't check their location bar can be protected is a terrible, terrible idea.
Just do: document.location.href = "http://malware.com;
And you are done.
<meta http-equiv="refresh" content="0; url=http://malware.com />