No CSRF Protection: How a Logged-In User’s Email Can Be Changed
The email change feature lacked CSRF protection, so a malicious page could silently change a logged-in user's email address. An attacker could trick a victim into visiting a page that automatically submits the email change request.
This article explains CSRF Lab 1 from PortSwigger Web Security Academy. If you are new to web security, this lab helps you understand how CSRF attacks work in real life.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The email change endpoint relied only on session cookies for authentication and did not require a CSRF token or special header validation.
Impact
A logged-in user who visits a malicious page could have their email address changed without their knowledge, which could lead to account takeover if the email is used for password resets.
What the attacker needed
Victim is logged in; victim visits attacker page
How it was found
- Log in to the application and go to the My Account page.
- Change the email address to a random value and capture the request in Burp Suite.
- Notice that the request contains no CSRF token and is accepted based only on the session cookie.
- Create a malicious HTML page that automatically sends the same email-change request.
- Store the page on the exploit server and deliver it to the victim.
- The victim's email is changed and the lab is marked solved.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
CSRF (Cross-Site Request Forgery) is when a malicious website makes your browser send a request to another site where you are logged in. Because your browser automatically includes your session cookie, the other site thinks the request came from you. Here, the email change form had no secret token to prove the request was intentional, so any page could trigger it.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.