Re: Explain CSRF
Date: July 22, 2012 04:29PM
Hi,
the victim user should be someone who the website "trusts". If the user has an account and is logged in, the website can recognize this particular user, maybe because a cookie has been written - the cookie is there after the login of the user. That is just one possibility. And of course the website must be vulnerable to CSRF for the attack to work.
As an attacker we do not necessarily have an account on the website. We are not among the people which the websites "trusts". But maybe somebody else hotlinks an image from our website inside some forum or guestbook page - and suppose we don't like that and we are nasty - then we could redirect users instead of delivering an image on request. Or we put a link into an email and ask the user to click it (social engineering).
If the website is vulnerable and admits users to perform certain actions through GET requests, like changing the user password, we can use the redirect trick to lock users out of their account. Look at this URL:
http://example.com/forum/change-pass.php?newpasswd=12345
This time the user is not logged out of the website, but his password has been changed to something the attacker knows - but maybe the user doesn't even know this, because he has not visited the "change password" page, filled in "12345" into a form and hit the "change" button to submit the form - this went on behind the scenes. We made him send that request.
Maybe it helps to understand CSRF attacks, if you look at some of the techniques used to defend a website agaist CSRF attacks. For example, if the "log out" link is not just some ordinary link but a form submit button, it could transmit an hidden parameter back to the server, a token, which will tell the server that the request to log out was legitimate - requesting the log out page through the hotlinked image redirect or through a link in an email does not work anymore, the token is missing. An example of a CSRF token is given in this article:
https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet
I like the overview explanation of CSRF from the OWASP website:
"CSRF is an attack which forces an end user to execute unwanted actions on a web application in which he/she is currently authenticated. With a little help of social engineering (like sending a link via email/chat), an attacker may force the users of a web application to execute actions of the attacker's choosing. A successful CSRF exploit can compromise end user data and operation in case of normal user. If the targeted end user is the administrator account, this can compromise the entire web application."
Source: https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)