Cross-Site Request Forgery

Also known as CSRF, exploits the trust a web application has in the user’s browser. Trick a website to perform unwanted actions on a web application where a user is authenticated. This allows to send requests from off the site that the server will consider valid.

We can find a typical example of this vulnerability as follows:

  • A site shows information about actions related to specific users, and whose data should remain confidential

#Imagine we fill out a form to change the actual password of an account
#We change the password to $newpass
#We can see that the site processes the request and shows the data related to the action in the URL
http://$url/?password_new=$newpass&password_conf=$newpass&Change=Change

#As the session remains active even when closing the tab of the site, this will allow changes even from off the site

  • Sometimes, it will not work directly, so we will need to check the source code to see the input conditions

Sometimes a validation could be done via request headers

Example source code
...
if( stripos( $_SERVER[ 'HTTP_REFERER' ] ,$_SERVER[ 'SERVER_NAME' ]) !== false ) {
...

In this case, we can modify our petition to assign the corresponding headers and bypass the validation

Modified pettion
...
Referer: http://$UrlOfProperSite/
...

Last updated