Skip to content
Open redirect Write-up Intermediate

stefanocoding/csrfjwtredirectleak.md

Client-side JavaScript built a request URL from unvalidated user input, so a crafted path could redirect the request to an attacker's server. The attacker's server then received the victim's CSRF token or JWT in a request header, allowing account actions or data access.

Stefano Vettorazzi Follow

Published on gist.github.com

Clone this repository at <script src="https://gist.github.com/stefanocoding/8cdc8acf5253725992432dedb1c9c781.js"></script> - Save stefanocoding/8cdc8acf5253725992432dedb1c9c781 to your computer and use it in GitHub Desktop.

Stefano Vettorazzi (@stefanohablando), on gist.github.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

Impact

An attacker could steal a victim's CSRF token or JWT and use it to change the victim's profile or read their information from another API.

What the attacker needed

Victim clicks a crafted link; an open redirect exists; victim is logged in

The fix

The application should validate and URI-encode user input before using it in client-side request paths, and the open redirect should be closed.

How it was found

  1. Find an open redirect endpoint on the target.
  2. Craft a URL whose code or path value traverses into the redirect endpoint with the attacker's URL.
  3. Victim loads the crafted URL; the page's JavaScript makes a request with the secret header.
  4. The request follows the redirect to the attacker's server, which captures the header value.
  5. Use the captured CSRF token or JWT to act as 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.

A web page took part of the address bar and used it to build another request without checking it. By putting a redirect address in that part, an attacker made the page send the user's secret token to the attacker's own server. The attacker could then use that token to act as the user.

What is Open redirect?

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.