Skip to content
CSRF Write-up Beginner

Broken CSRF Protection: Bypassing Tokens by Switching from POST to GET

The email change feature validated a CSRF token only on POST requests, so the same action sent as a GET request was accepted without any token check. An attacker could make a logged-in victim's browser send that GET request and silently change the victim's account email.

sudoxploit Follow

Published on medium.com

In this article, we will understand CSRF Lab 2 from the Web Security Academy by PortSwigger.

Istiyak, on medium.com

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 CSRF token was validated only inside the POST handler, leaving the GET route for the same state-changing action unprotected.

Impact

A logged-in victim who loads the attacker's page has their account email changed without consent, which could lead to account takeover through password reset.

What the attacker needed

A free account; victim is logged in; victim visits attacker's page

The fix

The email change should require a valid CSRF token and a non-simple method such as POST, with GET requests never performing state changes.

How it was found

  1. Log in with the given account and open the My Account page.
  2. Change the email address and find the resulting request in the proxy history.
  3. Note that the request uses POST and carries a CSRF token.
  4. Change the request method to GET while keeping the same parameters.
  5. Confirm the server still accepts the request, with or without the token.
  6. Host a page that issues the GET request on the exploit server and deliver it 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 secret token in forms to prove a request really came from their own page, which stops another site from quietly acting as you. Here that check only ran for one kind of request (POST), so switching to the other kind (GET) skipped the check entirely. A page the attacker controls could then trigger the email change in your browser while you are logged in.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.