14.8 Lab: CSRF where token is duplicated in cookie
This lab’s email change functionality is vulnerable to CSRF. It attempts to use the insecure “double submit” CSRF prevention technique. 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
Description
This lab’s email change functionality is vulnerable to CSRF. It attempts to use the insecure “double submit” CSRF prevention technique.
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 can log in to your own account using the following credentials: wiener:peter
Solution
- Open 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 and observe that the value of the
csrf
body parameter is simply being validated by comparing it with thecsrf
cookie. - Perform a search, send the resulting request to Burp Repeater, and observe that the search term gets reflected in the Set-Cookie header. Since the search function has no CSRF protection, you can use this to inject cookies into the victim user’s browser.
- Create a URL that uses this vulnerability to inject a fake
csrf
cookie into the victim's browser:/?search=test%0d%0aSet-Cookie:%20csrf=fake%3b%20SameSite=None
- Create and host a proof of concept exploit as described in the solution to the CSRF vulnerability with no defenses lab, ensuring that your CSRF token is set to “fake”. 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 and submit the form:<img src="https://YOUR-LAB-ID.web-security-academy.net/?search=test%0d%0aSet-Cookie:%20csrf=fake%3b%20SameSite=None" onerror="document.forms[0].submit();"/>
- Change the email address in your exploit so that it doesn’t match your own.
- Store the exploit, then click “Deliver to victim” to solve the lab.
A YouTube Channel for Cybersecurity Lab’s Poc and Write-ups
Telegram Channel for Free Ethical Hacking Dumps
Thank you for Reading!
Happy Ethical Hacking ~
Author: Karthikeyan Nagaraj ~ Cyberw1ng
