Open redirects: trusted links that send users somewhere else

How redirect parameters after login or logout send users to any site, why that helps phishing and can leak OAuth codes, and how to validate redirect targets with relative paths or an allow-list.

Lesson 26 of 69 · 10 min read · practice only with authorization

Diagram

A trusted domain bouncing elsewhere

Follow the path. One example at a time.

Step 1 of 4

Link

A link on your domain carries a next or return parameter.

Illustration: Link
https://app.example.org/login?next=https://lookalike.example.net/

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Phishing credibility

    What fails
    Users see your domain in the link and trust it.
    Who is affected
    Users who follow the link to a lookalike page.
    What you would notice
    Redirect parameters accepting absolute URLs.
    What you change
    Allow only relative paths after sign-in.
  2. OAuth code leakage

    What fails
    An open redirect on a registered redirect URI can forward authorization codes.
    Who is affected
    Users of the OAuth client.
    What you would notice
    A redirect URI that itself redirects based on a parameter.
    What you change
    Register exact redirect URIs and remove open redirects from them.
  3. Parser tricks

    What fails
    Values like //host, backslashes, and encoded characters fool naive checks.
    Who is affected
    Users, through a check that looks correct.
    What you would notice
    A startswith("/") check that accepts //lookalike.example.
    What you change
    Parse the URL and reject any scheme or host.

Testing

Find parameters named next, return, redirect, url, or continue. With a test account, set each to an outside domain you control and to //yourdomain and see where the browser ends up. Report the parameter and the final destination.

/login?next=/billing                 -> /billing          ok
/login?next=https://canary.example.net -> canary.example.net  finding
/login?next=//canary.example.net       -> canary.example.net  finding

Severity

On its own, an open redirect is usually low severity. Combined with OAuth, token-in-URL flows, or SSRF fetchers that follow redirects, it becomes part of a more serious chain, which is why it is still worth fixing.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Which redirect target should a login page accept?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapHow web applications work: requests, sessions, and where trust is decidedA browser request from DNS to database and back, the parts of an HTTP exchange a tester reads first, and the server-side decisions that most web vulnerabilities come down to.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.

Glossary

  1. CardOpen redirectA trusted domain sends the browser to an attacker-controlled site, which makes phishing links look legitimate.