Skip to content
CSRF Write-up Intermediate

Let’s Bypass CSRF Protection & Password Confirmation to Takeover Victim Accounts :D

The application's anti-CSRF token check could be bypassed by changing the request method from POST to GET and removing the token. Additionally, the password change endpoint did not require the current password, allowing an attacker to chain these issues and change a victim's password via CSRF, leading to account takeover.

Harsh Bothra Follow

Published on medium.com

{{media:0}}

Harsh Bothra, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Cross-Site Request Forgery (CSRF) is rarely seen in applications built on newer frameworks, but as this case shows it is still exploitable. In a CSRF attack an attacker crafts a request and delivers it to a victim; the server accepts the request as if the victim had made it and processes it. Applications defend against this with several mechanisms, and the one at issue here is the anti-CSRF token.

An anti-CSRF token lets the server distinguish who actually requested a resource or action, protecting against CSRF. Weak implementation, however, leaves room for bypasses. The researcher lists the following:

  • Remove Anti-CSRF Token
  • Spoof Anti-CSRF Token by Changing a few bits
  • Using Same Anti-CSRF Token
  • Weak Cryptography to generate Anti-CSRF Token
  • Guessable Anti-CSRF Token
  • Stealing Token with other attacks such as XSS.
  • Converting POST Request to GET Request to bypass the CSRF Token Check.

The last one is the technique used in this write-up. The target is referred to only as target.com, and the features involved are the profile editing endpoint and the password change functionality.

Setup

The report does not describe any accounts, roles, tools or versions beyond the use of Burp Suite to generate a CSRF PoC. The testing was done against the live application at target.com, starting from the profile editing feature and then moving to the password change feature.

Finding it

While exploring the application, the researcher found the /editprofile endpoint. Its request looked like this:

HTTP
POST /editprofile HTTP/1.1Host: target.com<redacted>username=test&description=<some_text>&phone=1231231231&anti_csrf=<token>

The anti_csrf token is present in the body, and the server validates whether the token is missing or forged. A straightforward CSRF attempt against this request therefore fails.

Exploitation

Step 1: Bypass the anti-CSRF token on /editprofile

The researcher changed the request method from POST to GET and removed the anti_csrf parameter. The forged request looked like this:

HTTP
GET /editprofile?username=test&description=<some_text>&phone=1231231231 HTTP/1.1Host: target.com<redacted>

The parameters that were in the POST body are now in the query string, and the token is gone. The server accepted the request, so the CSRF protection was bypassed successfully. On its own this is low severity, because the only thing an attacker can do is change some profile information.

Step 2: Bypass the current password check on /changepassword

Looking for more impact, the researcher examined the password reset functionality. It asked for the Current Password before allowing a password change. The original password change request looked like this:

HTTP
POST /changepassword HTTP/1.1Host: target.com<redacted>current_password=currentpassword&new_password=new_password&confirm_password=new_password&anti_csrf=<token>

The researcher simply removed the current_password field, and the password was reset successfully. Removing the current_password field was enough to reset the password.

At this point there were two separate issues:

  1. A way to bypass the anti-CSRF token, and a working bypass.
  2. A way to bypass the current password requirement on password change.

Step 3: Chain both issues into account takeover

The two issues can be chained to change the password of a victim user through CSRF. The forged request looks like this:

HTTP
GET /changepassword?new_password=new_password&confirm_password=new_password HTTP/1.1Host: target.com<redacted>

This request uses GET instead of POST, carries no anti_csrf token, and omits current_password entirely. The researcher generated a CSRF PoC with Burp Suite (or any other method) and sent it to the victim. Once the victim navigates to the attacker's crafted URL, the victim's password is changed.

The initial severity of Medium became HIGH.

Root cause

When the same parameters were sent as a GET request without the token, the server processed the action, so the protection could be skipped by changing the method. Separately, the password change endpoint did not enforce the presence of the current_password field, so removing it was enough to change the password without knowing the old one. Chained together, the missing token check on GET and the missing current password check allow an attacker to change a victim's password with a single forged request. The report does not describe the server-side implementation, so the exact reason the GET variant skipped the token check is not stated.

Impact

An attacker who can get a victim to visit a crafted URL can change that victim's password without knowing the current password, resulting in full account takeover. The attack requires the victim to navigate to the attacker's crafted URL while the request is accepted by the server. On its own, the profile editing bypass only allows changing some profile information and was rated low severity; the password change chain raised the severity to HIGH.

Fix

Based on the findings, the token check should apply regardless of the HTTP method, so that a GET request carrying the same parameters is validated in the same way as a POST request, and the password change endpoint should require and verify the current_password field rather than treating it as optional.

Variants to test

  • Method switching on token-protected endpoints. Take a POST request that carries an anti-CSRF token and resend the same parameters as a GET request with the token removed. A positive result is the server processing the action without the token.
  • Removing required fields. On sensitive forms such as password change, drop fields like the current password and resend. A positive result is the action succeeding without the field.
  • Chaining low-severity bypasses. Combine a token bypass with a missing authorisation or confirmation check to see whether the combined impact is higher than either issue alone.
  • Token reuse and manipulation. Reuse a token from another session, or alter a few bits of a valid token, and observe whether the server still accepts the request.
  • Token removal. Send the request with the anti-CSRF parameter omitted entirely. A positive result is the action being processed without a token.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A security researcher was testing a website (called target.com in the write-up) to see whether it could be tricked into doing things on behalf of a logged-in user without that user's knowledge. This kind of trick is called Cross-Site Request Forgery, or CSRF for short.

Websites try to stop CSRF with a defence called an anti-CSRF token: a long, random-looking value that the website gives to the user's browser and expects to see again when the user submits a form. The researcher found that sending the same information as a GET request, with the token removed, was accepted by the server. By switching the method, the token check could be skipped.

On its own, that only let an attacker change a few profile details, which is not very serious. But the researcher then found a second weakness: the password change page asked for the user's current password, but the server did not actually insist on receiving it. Removing that field was enough to change the password anyway.

Put the two together and an attacker could send a victim a link. If the victim clicked it while logged in, the victim's password would be changed to one the attacker chose. The attacker could then log in as the victim. That is called account takeover, and it turned a medium-severity finding into a high-severity one.

Background: what CSRF and anti-CSRF tokens are

Before walking through the attack, it helps to understand a few everyday ideas.

A request is what your browser sends to a website when you click a button or submit a form. It is like posting a letter: the browser writes down what you want ("change my description to X") and sends it to the server, which is the computer that runs the website.

A cookie is a small piece of information the website asks your browser to keep and send back with every request. The most important cookie is usually the one that says "this browser is logged in as this user". Because the browser sends it automatically, the server trusts that a request carrying the right cookie really comes from that user.

CSRF abuses that trust. If an attacker can make your browser send a request to the website while you are logged in, the browser will attach your cookie automatically, and the server will treat the request as if you made it yourself. The attacker never sees your password; they just borrow your logged-in browser for a moment.

An anti-CSRF token is the website's countermeasure. It is a secret value that the website puts into each form. When you submit the form, the browser sends the token back. The server checks that the token is present and correct. An attacker who tricks your browser into sending a request will not know the token, so the request is rejected. Think of it as a wax seal on a letter: the recipient checks the seal before acting on the contents.

HTTP methods are the verbs a browser uses when talking to a server. GET is normally used to fetch a page (like reading a web page), and POST is normally used to submit data that changes something (like sending a form). The method is part of the request, and servers can behave differently depending on which one is used.

An endpoint is a specific address on the website that does a particular job, such as /editprofile for changing your profile or /changepassword for changing your password.

Parameters are the pieces of information sent with a request, such as username=test. In a POST request they usually sit in the request body; in a GET request they sit in the URL after a question mark.

Burp Suite is a tool security testers use to look at and modify the requests their browser sends. One of its features can generate a CSRF PoC: a small HTML page that, when opened in a browser, automatically sends a chosen request. The attacker hosts that page and sends the link to the victim.

Why anti-CSRF tokens can fail

The researcher lists several ways an anti-CSRF token can be bypassed when the implementation is weak:

  • Remove Anti-CSRF Token
  • Spoof Anti-CSRF Token by Changing a few bits
  • Using Same Anti-CSRF Token
  • Weak Cryptography to generate Anti-CSRF Token
  • Guessable Anti-CSRF Token
  • Stealing Token with other attacks such as XSS.
  • Converting POST Request to GET Request to bypass the CSRF Token Check.

The last one is the technique used in this write-up. The target is referred to only as target.com, and the features involved are the profile editing endpoint and the password change functionality.

Setting up

The report does not describe any accounts, roles, tools or versions beyond the use of Burp Suite to generate a CSRF PoC. The testing was done against the live application at target.com, starting from the profile editing feature and then moving to the password change feature.

Finding the first weakness

While exploring the application, the researcher found the /editprofile endpoint. Its request looked like this:

HTTP
POST /editprofile HTTP/1.1Host: target.com<redacted>username=test&description=<some_text>&phone=1231231231&anti_csrf=<token>

Line by line, in plain words:

  • POST /editprofile HTTP/1.1 says "I am submitting data to the address /editprofile, using version 1.1 of the HTTP protocol". POST is the method used for sending form data.
  • Host: target.com tells the server which website the request is for. One server can host many websites, so this line says which one is meant.
  • <redacted> stands for other header lines that the report does not show, such as the cookie that identifies the logged-in user.
  • username=test&description=<some_text>&phone=1231231231&anti_csrf=<token> is the body of the request: the actual form data. The & separates the fields. Here the user is called test, the description is some text, the phone number is 1231231231, and anti_csrf carries the secret token.

The anti_csrf token is present in the body, and the server validates whether the token is missing or forged. A straightforward CSRF attempt against this request therefore fails: if an attacker sends the same request without the token, the server refuses it.

Exploiting it

Step 1: Bypass the anti-CSRF token on /editprofile

The researcher changed the request method from POST to GET and removed the anti_csrf parameter. The forged request looked like this:

HTTP
GET /editprofile?username=test&description=<some_text>&phone=1231231231 HTTP/1.1Host: target.com<redacted>

Line by line:

  • GET /editprofile?... now uses the GET method. The same fields that were in the body are now in the URL, after the question mark, separated by &.
  • username=test, description=<some_text> and phone=1231231231 are the same values as before.
  • There is no anti_csrf field at all. The token has been dropped.
  • Host: target.com and <redacted> mean the same as before.

The parameters that were in the POST body are now in the query string, and the token is gone. The server accepted the request, so the CSRF protection was bypassed successfully. The GET request carrying the same data without the token was accepted by the server. On its own this is low severity, because the only thing an attacker can do is change some profile information.

Step 2: Bypass the current password check on /changepassword

Looking for more impact, the researcher examined the password reset functionality. It asked for the Current Password before allowing a password change. The original password change request looked like this:

HTTP
POST /changepassword HTTP/1.1Host: target.com<redacted>current_password=currentpassword&new_password=new_password&confirm_password=new_password&anti_csrf=<token>

Line by line:

  • POST /changepassword HTTP/1.1 submits data to the password change address.
  • Host: target.com and <redacted> are the same as before.
  • current_password=currentpassword is the field where the user types their existing password. The server is supposed to check that this is correct before allowing a change.
  • new_password=new_password is the password the user wants to switch to.
  • confirm_password=new_password repeats the new password so that a typo does not lock the user out.
  • anti_csrf=<token> is the anti-CSRF token again.

The researcher simply removed the current_password field, and the password was reset successfully. Removing the current_password field was enough to reset the password.

At this point there were two separate issues:

  1. A way to bypass the anti-CSRF token, and a working bypass.
  2. A way to bypass the current password requirement on password change.

Step 3: Chain both issues into account takeover

The two issues can be chained to change the password of a victim user through CSRF. The forged request looks like this:

HTTP
GET /changepassword?new_password=new_password&confirm_password=new_password HTTP/1.1Host: target.com<redacted>

Line by line:

  • GET /changepassword?... uses the GET method, so the token check is skipped, just as in Step 1.
  • new_password=new_password sets the new password to the value the attacker chooses.
  • confirm_password=new_password repeats it, satisfying the confirmation field.
  • There is no current_password field, so the server has nothing to check against the real password.
  • There is no anti_csrf field, so the CSRF defence is absent.

This request uses GET instead of POST, carries no anti_csrf token, and omits current_password entirely. The researcher generated a CSRF PoC with Burp Suite (or any other method) and sent it to the victim. Once the victim navigates to the attacker's crafted URL, the victim's password is changed.

The initial severity of Medium became HIGH.

Why it worked

When the same parameters were sent as a GET request without the token, the server processed the action, so the protection could be skipped by changing the method. Separately, the password change endpoint did not enforce the presence of the current_password field, so removing it was enough to change the password without knowing the old one. Chained together, the missing token check on GET and the missing current password check allow an attacker to change a victim's password with a single forged request.

What the impact was

An attacker who can get a victim to visit a crafted URL can change that victim's password without knowing the current password, resulting in full account takeover. The attack requires the victim to navigate to the attacker's crafted URL while the request is accepted by the server. On its own, the profile editing bypass only allows changing some profile information and was rated low severity; the password change chain raised the severity to HIGH.

How to fix it

Based on the findings, the token check should apply regardless of the HTTP method, so that a GET request carrying the same parameters is validated in the same way as a POST request, and the password change endpoint should require and verify the current_password field rather than treating it as optional.

Other things to test

  • Method switching on token-protected endpoints. Take a POST request that carries an anti-CSRF token and resend the same parameters as a GET request with the token removed. A positive result is the server processing the action without the token.
  • Removing required fields. On sensitive forms such as password change, drop fields like the current password and resend. A positive result is the action succeeding without the field.
  • Chaining low-severity bypasses. Combine a token bypass with a missing authorisation or confirmation check to see whether the combined impact is higher than either issue alone.
  • Token reuse and manipulation. Reuse a token from another session, or alter a few bits of a valid token, and observe whether the server still accepts the request.
  • Token removal. Send the request with the anti-CSRF parameter omitted entirely. A positive result is the action being processed without a token.

Glossary

  • Account takeover: when an attacker gains control of someone else's account, for example by changing their password and logging in as them.
  • Anti-CSRF token: a secret value placed in a form so the server can check that the request really came from the website's own page and not from an attacker.
  • Burp Suite: a tool used by security testers to inspect and modify the requests a browser sends.
  • Cookie: a small piece of data a website asks the browser to store and send back with every request, often used to remember that a user is logged in.
  • CSRF (Cross-Site Request Forgery): an attack where a victim's browser is tricked into sending a request to a website the victim is logged in to, so the server treats it as the victim's own action.
  • CSRF PoC: a small HTML page that automatically sends a chosen request when opened, used to demonstrate a CSRF attack.
  • Endpoint: a specific address on a website that performs a particular action, such as /editprofile.
  • GET: an HTTP method normally used to fetch a page; its parameters appear in the URL.
  • HTTP: the language browsers and web servers use to exchange requests and responses.
  • HTTP method: the verb at the start of a request (such as GET or POST) that says what kind of action is intended.
  • Parameter: a named piece of data sent with a request, such as username=test.
  • POST: an HTTP method normally used to submit data that changes something; its parameters usually sit in the request body.
  • Query string: the part of a URL after the question mark that carries parameters in a GET request.
  • Request: the message a browser sends to a server asking it to do something.
  • Request body: the part of a request that carries data, used mainly with POST.
  • Server: the computer that runs a website and answers requests.
  • Severity: a rating of how serious a security issue is, often low, medium or high.
  • XSS (Cross-Site Scripting): a different kind of attack where an attacker gets their own code to run in a victim's browser; it can be used to steal tokens.

More by Harsh Bothra

View all

7 more disclosed reports, best first.

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.