SameSite=Strict? No Problem — Bypassing It With a Client-Side Redirect
The email-change endpoint lacked a CSRF token and relied on SameSite=Strict cookies, but a comment confirmation page accepted a user-controlled postId that caused a client-side redirect. An attacker could craft a link that redirects the victim's browser to the email-change endpoint, bypassing SameSite and changing the victim's email.
Published on smartpicks4u.medium.com
In my last write-up, I covered a lab similar to this one, but I also explained some fundamental concepts there, so feel free to check that out first.
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
Likely the comment confirmation page used a user-controlled postId to build a client-side redirect without validating the destination, and the email-change endpoint accepted GET requests without a CSRF token.
Impact
An attacker could change a victim's email address without their consent, which could lead to account takeover, though the text only claims the email change and lab completion.
What the attacker needed
Victim clicks a link; victim is logged in; attacker can post a comment
The fix
The email-change endpoint should require a CSRF token and reject GET requests, and the confirmation page should not redirect to user-controlled destinations.
How it was found
- Capture the email-change request and note it has no CSRF token and uses SameSite=Strict cookies.
- Change the request method to GET and confirm it still works.
- Post a comment and observe the redirect to a confirmation page with a postId parameter.
- Change postId to a path-traversal value pointing at the account page and confirm the redirect.
- Append the email-change path and parameters to postId, encoding the ampersand, and confirm it works.
- Deliver a page that sets document.location to the crafted confirmation URL to the victim.
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.
Websites use a cookie setting called SameSite=Strict to stop other sites from making requests with your login cookie. The site had a page that redirected to whatever address was in a parameter, and the author made it redirect to the email-change page instead. Because the redirect happened inside the trusted site, the browser sent the cookie and the email was changed.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.