Skip to content
Open redirect Write-up Beginner

Open Redirect via Base64-Encoded state Parameter in OAuth Flow (returnTo field)

The passwordless login flow carried a base64-encoded state parameter containing a returnTo field that was used as a redirect destination after verification. By decoding the value, changing returnTo to an attacker-controlled domain and re-encoding it, an attacker could send a victim to any site after login.

husseinelturkey Follow

Published on medium.com

Hi there, It is me Hussein, I am a Bug Bounty Hunter (Former Web Developer), I will tell you about an Open Redirect via Base64-Encoded bug I found last month.

Hussein Elturkey, 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 server trusted the client-supplied returnTo value inside the state parameter as a redirect target without validating that it pointed to an allowed domain.

Impact

A victim following a crafted login link could be redirected to an attacker-controlled site after authentication, which could be used for phishing; the report does not show any further impact.

What the attacker needed

Victim clicks a crafted login link; attacker can modify the state value

The fix

The returnTo value should be validated server-side against an allowlist of permitted destinations before any redirect is issued.

How it was found

  1. Log in at the site's login page using an email address.
  2. Receive the magic verification link that contains the state parameter.
  3. Decode the base64 state value to reveal the JSON with the returnTo field.
  4. Change returnTo to an attacker-controlled domain and re-encode the value.
  5. Follow the modified link and observe the redirect to the attacker domain after login.

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.

After you log in with a magic link, the site sends you onward to another page. That destination was stored in a hidden value in the link, and the site trusted it without checking. Because the value was only lightly disguised (base64 is just an encoding, not protection), anyone could swap the destination for their own site and use the login link to send people there.

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.