CWE-601Identity & accessSeverity · High

Loose OAuth redirect matching

The login flow sends authorisation codes to any address that starts like the registered one. An attacker can steal a user's code and take over the account.

At a glance

Controls
CWE-601 · A01:2021 Broken Access Control
Typical severityHigh
ReferenceCWE-601
OWASP Top 10A01:2021 Broken Access Control

What it is

OAuth sends an authorisation code back to a redirect address after a user signs in. The server should only send it to an address registered in advance. Some servers accept a prefix match, a wildcard subdomain or any path under the registered host.

An attacker crafts a login link with a redirect address they control that still passes the loose match. The victim signs in as normal and the code goes to the attacker, who swaps it for a session. AI-assisted attackers generate and test many redirect variants at once, so a loose rule is found quickly.

Where it hides

What a reviewer can look for in the code and in the behaviour, before anyone proves it.

  • The authorisation endpoint of a custom OAuth or OpenID server
  • Client registrations that use wildcards or path prefixes
  • Redirect checks written as starts-with or contains string tests
  • Open redirect pages on an allowed host that pass the code onward

How MATT tests it

The proof runs against the deployed product, on every release, whoever wrote the code.

  1. 01Read the code and client settings to see how redirect addresses are compared.
  2. 02Start a login for a test user with redirect addresses that differ from the registered one by path, subdomain or suffix.
  3. 03Record whether the server issues a code to any address that was never registered.
The rule, in plain English

Authorisation codes must go only to an exactly registered redirect address.

Executable check

GET /oauth/authorize?client_id=app&redirect_uri=https://app.example.com.evil.test/cb expect: error, no code issued GET /oauth/authorize?client_id=app&redirect_uri=https://app.example.com/cb/../other expect: error, no code issued

Every rule MATT holds →

What the fix looks like

  1. 01

    Compare the redirect address to the registered list with an exact string match.

  2. 02

    Remove wildcards and path prefixes from client registrations.

  3. 03

    Require PKCE for every client so a stolen code is useless alone.

  4. 04

    Remove open redirect pages from hosts that receive codes.

A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →

ExploitOps discovery call

Understand where your security loop breaks.

A call with a MATT co-founder to understand your product and whether an ExploitOps Review is worth doing. If there is a real need, we scope one with the research team.

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02