In this post, we’re going to be solving the lab: “CSRF vulnerability with no defenses”.

In this case, the lab indicates that there’s a CSRF vulnerability in the email change functionality. To solve the lab, we must create an HTML page that exploits the CSRF to change the email of whoever visits our website. Finally, we’re provided with credentials to access an account.
Knowing all this, we start the lab and navigate to “My account” to log in:


Once we’ve logged in, we’re redirected to our profile:

Here, as the statement mentioned, we find a functionality to change our account’s email, so we prepare Burp Suite to intercept the change request:


With Burp Suite ready, we enter a random email and click on Update email:

As soon as we click, Burp Suite receives the request:

And as we can observe, the only parameter sent in the request body is email. There’s no other parameter whose value is random and impossible to predict, making it possible to create a malicious template that generates a request like the one shown above, keeping in mind that a site’s cookies are included in any request the browser makes to that site.
If we let this request be sent, the email will change without issues:

We now know all the necessary information and everything works as expected, so we disable the proxy and navigate to the exploit server:


Once inside, we have the following fields:

This is where we create the malicious HTML template that will generate the request we saw above when the victim visits the page:

The HTML code is as follows:
<html>
<body>
<form action='<URL where the email change is made>' method='<HTTP METHOD>'>
<input name="email" value="<new value, in this case the email>" type="hidden"/>
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>
If we click to view the exploit, we ourselves will visit the malicious page:

Since we have the session saved in the browser with the cookies, when visiting it, the request is generated correctly and the email is changed, all from just visiting the malicious website:

So, what happened is:
- The malicious website generates a specially crafted request when visited.
- If the user is logged in to the vulnerable website (in this case), the browser will automatically include the session cookie in the request (assuming the
SameSiteattribute of the cookie is not enabled, which is not the case here) - The malicious website will process the request, since it’s impossible to differentiate whether it was made by the victim themselves or not, so it will process it without issues and the email address will be changed.
Since we’ve observed that the exploit works perfectly, we can simply send it to the victim:

And this way, we solve the lab:

