Skip to content
CSRF Write-up Intermediate

The Un Secret Token How A Client Side Csrf Flaw Breaks A Core Defense

The application generated CSRF tokens via an unauthenticated, stateless API endpoint, allowing anyone to obtain a valid token. An attacker could use such a token to forge requests on behalf of a victim, bypassing CSRF protection.

Imvkale Follow

Published on infosecwriteups.com

As security professionals, we often treat Cross-Site Request Forgery (CSRF) as a solved problem. We implement the Synchronizer Token Pattern, ensure our frameworks have built-in protections, and move on.

Imvkale, on infosecwriteups.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 server generated CSRF tokens via an unauthenticated, stateless API endpoint and validated only that the token was recently issued, not that it was tied to the user's session.

Impact

An attacker could forge requests to perform actions on behalf of a victim, such as changing the account email address, because the CSRF protection was completely ineffective.

What the attacker needed

Victim is authenticated; victim visits attacker's page; attacker can obtain a token

The fix

The fix is to generate CSRF tokens on the server-side, tie them to the user's session, embed them in HTML on the server, and validate that the submitted token matches the one stored in the user's session.

How it was found

  1. Request a fresh CSRF token from the unauthenticated API endpoint.
  2. Capture a legitimate request for a sensitive action (e.g., changing email) using Burp Suite.
  3. Generate a CSRF proof-of-concept HTML form with Burp Suite.
  4. Replace the placeholder token in the form with the freshly obtained token.
  5. Host the proof-of-concept page and open it in a browser authenticated to the vulnerable application.
  6. Verify that the action (email change) was successfully performed.

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 common defence is to include a secret token in each request that only the user's browser and the server know. Here, the token was not secret because anyone could ask the server for one, so the defence failed.

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.