Searching for vulnerable apps:
When we want to look for real world web applications that are vulnerable to Cross Site Request Forgery, exploit-db.com is one great place. Searching exploit-db.com with the filter Forgery provides a long list of applications vulnerable to Cross Site Request Forgery as follows.
As we can notice, the preceding figure shows a long list of applications and products that are vulnerable to Cross Site Request Forgery.
Cross Site Request Forgery case study:
Let us choose the second entry with the title Liman 0.7 – Cross-Site Request Forgery (Change Password) from the list shown in the preceding figure from exploit-db. Open the page and we should notice the following.
We can notice that the affected version is 0.7. A quick look at the application’s GitHub page, shows that it can be run as a docker container. This software can be used for container monitoring.
Setting up Liman 0.7
This setup requires docker to be installed. Once Docker is installed, create a volume named liman using the following command. Next, we can spring up a container using the image available in DockerHub. This can be done using the following command. The preceding command will launch a new container and the liman web interface will be available on port 5000 of the host machine, where the container is started. The following picture shows the initial web page shown when the web interface is accessed.
As we can notice, the application requires the user to set up a username and password. In this case, the following credentials are used in the setup. Once the setup is complete, users can login using these credentials. Login to the application and navigate to settings, which looks as follows.
There are two forms available on this web page:
The first form can be used to update the username and email id of the user. The second form can be used to update the user’s password.
Let us analyze the HTTP Requests and craft CSRF payloads if these forms are vulnerable. Following is the HTTP Request made when the user submits the first form. Content-Length: 36 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 Origin: http://192.168.1.91:5000 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9 Referer: http://192.168.1.91:5000/settings Accept-Encoding: gzip, deflate Accept-Language: en-GB,en;q=0.9 Cookie: liman=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJuYW1lIjoiYWRtaW4iLCJlbWFpbCI6InRlc3RAdGVzdC5jb20iLCJhZG1pbiI6MSwiYXZhdGFyIjoiaHR0cHM6Ly93d3cuZ3JhdmF0YXIuY29tL2F2YXRhci9iNjQyYjQyMTdiMzRiMWU4ZDNiZDkxNWZjNjVjNDQ1MiJ9LCJpYXQiOjE2MDM2MTAxOTAsImV4cCI6MTYwNDIxNDk5MH0.qqsbxFDqimE4OUVZGvZLsBMPhQeQHgBQt1ruRWLbhX__pYv0q0tMwZyibvKXaBDWShUoZaSOFBXTH5SoHmJ-_SKb3ZJS27ofjUPDbQlxzP1QeL-1SOg-XUxULKh7Br6geG1g6pesihbC89bZvcVTXQSlpBpxaWoYEZWCnGuLCAWzSB0no54IXeJnFnwRd2UUZ_wW0lKoFZFAMdS987pAKdIRYTGXLr48E_DlRLXsYEs6VhBC8rzO6HhEB-maubdlmJ_waNGWkkFfBMuOIT_6TkHXd3Lgl1EaJUTYnS2jJtpSxwHIlZnGKn9FOH_hjXWvvYVFelpAbc7DXIJtgBWQ4P8rsq43R4sJw9laPQ0rgdFePm4qO-G5gHkZ8ZPeWR_SVVrZzNV9maNXDkfb7x7UsEQTXcx98Demt__7y_0nr5LwO1WMOGpIbjNvLjyAUM1pLYBnRwA-wW8cv2pmmDE6RK46fSTr9g9fPiXLBHauNbUtYyFjAukU01Xsn4al7yVzEMiStp9AjLZ5V9YQ4NL_khrIJ15HrpPhRPPza2gO9YSnwnqvZE9cMqjgjVvTqeMnP-VbQqQo879o7eBSpXYXhnQ-A_iTZm2UL9gLxJvrP7laUYGuX_dvJlDJ8CoYBzPHriKr_4aZnD3ASMQLgp4RyKFJlvxKEWMY8c8DiZ9luYg Connection: close username=hacked&email=test%40hacked.com If we closely observe, there is no CSRF token being used by the application and thus leaving the application vulnerable to CSRF. We can use the following Proof of Concept code to exploit this vulnerability.