Hacking Csrf Bypassing Of Csrf Token
The article walks through three PortSwigger labs where CSRF token checks can be bypassed: when validation depends on the request method, when the token is simply omitted, and when a token from one account is accepted for another session. An attacker could craft a page that changes a victim's email address without their consent.
Hey guys welcome to my blog so today we are going to discuss about CSRF protection bypass and in previous I discussed about CSRF attacks and finding CSRF vulnerability so please check out the below article
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 server's CSRF token validation was incomplete: it only checked tokens for one request method, accepted requests with no token at all, or did not bind the token to the user's session.
Impact
An attacker could change a victim's account email address without consent, which may lead to account takeover, though the article only demonstrates this in lab environments.
What the attacker needed
A logged-in victim; victim visits attacker's page; lab environment
The fix
The server should validate the CSRF token on every state-changing request regardless of method, reject requests where the token is missing, and tie each token to the user's session.
How it was found
- Sign up or log in to the lab and find the change email function.
- Capture the email change request and send it to the repeater.
- Change the request method from POST to GET.
- Generate a CSRF proof-of-concept page and remove the token.
- Paste the page into the exploit server, store it and deliver it to the victim.
- The lab is solved once the victim's email changes.
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 is when a malicious website makes your browser send a request to another site where you are already logged in, so the action looks like it came from you. Sites defend against this with a secret token that must accompany each change, but if the site checks that token badly, the defence fails. Here the checks were skipped by changing the request method, by leaving the token out, or by reusing a token from a different account.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.