CSRF in Profile Update Endpoint
The profile update endpoint accepts requests without validating a CSRF token, and the session cookie lacks a proper SameSite setting. An attacker can make a logged-in victim's browser submit a forged form that changes profile details such as the phone number.
medium.com
Published on medium.com
Imagine you are logged in into a website in one tab, let’s say a profile on some platform. Then, in another tab, you opened a link unknowingly.
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 server did not validate the CSRF token and did not check Origin or Referer headers, while the session cookie lacked a strict SameSite setting.
Impact
An attacker could modify a logged-in user's profile details, and may be able to inject HTML or JavaScript into fields if they are not filtered.
What the attacker needed
Victim is logged in; victim visits attacker page
The fix
The site should enforce SameSite=Strict or Lax on session cookies, validate CSRF tokens on all state-changing operations, and check Origin or Referer headers for sensitive POST requests.
How it was found
- Log in to the target site and open the profile page.
- Edit the profile, submit the update, and capture the request.
- Remove the authenticity_token parameter from the captured request.
- Host a CSRF proof-of-concept HTML form that submits similar profile fields.
- Get a logged-in victim to visit the proof-of-concept page.
- Reload the victim's profile to confirm the change.
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.
When you log in, the site gives your browser a cookie so it knows who you are. If another website can make your browser send a request to the site, the site may act on it as if you asked. Here the profile update page did not check that the request really came from its own site, so a page controlled by an attacker could change your profile details.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.