XSS / CSRF using AJAX
I was reading an archive entry on Chris Shiflett's site which discusses the potential dangers of CSRF attacks when something caught my eye in his comments section:-
So, what happens when that assumption is no longer valid, when there is no longer an inherent limitation?
There is a lot of talk about making XHR cross-domain but isn't that going to open up some big security risks? If XHR can call a url cross-domain then it can spoof any form submission on the target domain: ie it can pretend to be the user and completely mimic their actions (fill in forms, press submit buttons, change account details etc).
I think if XHR goes cross domain then it's going to have to be in a pretty "dumb" capacity, where the target domain only outputs one-way data, rather than allowing some more complex functionality (that could be spoofed by an attacker).
"Would it not be possible to read the token and submit it with the attack?"This is refering to the technique of placing a random token in your forms so as to stop a CSRF attack: the attacker would first have to know the token value before he could trick you into executing some malicious request. Shiflett replied with:-
Whose token are you reading? :-) Keep in mind that for this to be successful, you would have to be able to read someone else's (the victim's) token.So basically Shiflett dismisses the vulnerability based on the limitations of XMLHttpRequest; the attacker must first be able to inject malicious javascript into a page on the same domain as the targeted software via some XSS attack (see Samy is my hero for example).
The only way I know to do this is with XMLHttpRequest - you inject some JavaScript that first requests the page with the form (from the victim's browser), parses the results to find the victim's token, then submits the forged request (valid token included). This attack is limited by the inherent limitations in XMLHttpRequest - only requests from the same domain are allowed, etc. For most, this means that this scenario is impossible, but if you have a XSS vulnerability, that all changes.
So, what happens when that assumption is no longer valid, when there is no longer an inherent limitation?
There is a lot of talk about making XHR cross-domain but isn't that going to open up some big security risks? If XHR can call a url cross-domain then it can spoof any form submission on the target domain: ie it can pretend to be the user and completely mimic their actions (fill in forms, press submit buttons, change account details etc).
I think if XHR goes cross domain then it's going to have to be in a pretty "dumb" capacity, where the target domain only outputs one-way data, rather than allowing some more complex functionality (that could be spoofed by an attacker).


0 Comments:
Post a Comment
<< Home