How I Bypassed CSRF Token — 2 Ways
The website's CSRF protection could be bypassed in two ways: by changing the request method from POST to GET and removing the token, or by using another user's or an expired CSRF token. An attacker could perform actions such as changing a user's name without a valid token.
medium.com
Published on medium.com
Pada kesempatan kali ini, saya ingin sharing bagaimana saya bisa membypass pertahanan CSRF pada sebuah website dengan 2 cara berbeda.
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 site only validated the CSRF token for POST requests and did not verify token ownership or expiration, accepting any paired token.
Impact
An attacker could perform state-changing actions such as changing a user's name without a valid CSRF token, by using a GET request or a token from another user or an expired token.
What the attacker needed
Victim logged in; attacker can obtain a valid token; victim visits a malicious page
How it was found
- Change the HTTP request method from POST to GET.
- Remove the CSRF token from the Cookie header and request body.
- Send the request body without the CSRF parameter.
- The request to change the username succeeds without a CSRF token.
- Log in as the attacker and capture the CSRF token from the Cookie header and request body.
- Log out, then log in as the victim and replace the victim's CSRF token with the attacker's token.
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 an attack where a malicious site makes a logged-in user's browser send a request to another site without the user's knowledge. A CSRF token is a secret value added to requests to prove they come from the real site. Here, the site either did not check the token for GET requests or accepted tokens that belonged to other users or had expired, so the protection could be bypassed.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.