CSRF in web applications:
Cross Site Request Forgery vulnerabilities have a potential to occur wherever the application has features with state changes on the server side. These often occur through features with form submissions. One such For example, submitting a form to change password is a feature, where state change happens. In the next few sections, let us discuss how CSRF vulnerabilities can be discovered and exploited.
Finding Cross Site Request Forgery:
Let us launch Xtreme Vulnerable Web Application (XVWA) and navigate to CSRF. We can also access this challenge directly using the following URL. The page looks as follows. As we can see, a user can change his password using the form. Interestingly, the form is not asking for the user’s current password. Providing the new password twice will update the user’s password. If an attacker can trick the logged in user to submit this form with an attacker controlled password, the victim will change his password without his knowledge. It is needless to mention that the attack will work only if the developers do not implement appropriate protections against CSRF attacks.
Exploiting CSRF vulnerabilities
Let us first login to the application as an attacker using the following credentials. Next, navigate to the vulnerable page and enter the new password twice and intercept the request using Burp Suite. The request looks as follows. User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: close Referer: http://192.168.1.105/xvwa/vulnerabilities/csrf/ Cookie: PHPSESSID=j8f2hcm4gbfj0oa3hkgb4n7f41 Upgrade-Insecure-Requests: 1 As we can notice, clicking the Submit button has resulted in a GET request. Now, an attacker can craft a link to a malicious page with the following proof of concept code.
A chance to win a free iPhone.
I want to participate