The scanner changed redirect_uri and the authorization server returned 302. Where did the code actually go? OAuth redirect_uri validation, state and PKCE as DAST findings: exact, prefix, substring, wildcard, parser and loopback matching, open-redirect chains, the token-endpoint recheck, two kinds of PKCE downgrade, code reuse, and which fixes held

DedSec Security Research ·

Here is a hypothetical. A dynamic scan of a web application that signs users in through OAuth 2.0 returns three results about the authorization flow.

The first is "OAuth redirect_uri not validated", rated high, on GET /oauth/authorize. The scanner replaced redirect_uri with https://evil.example/cb, and the authorization server answered 302 Found with a Location on evil.example. The second is informational, "redirect_uri validated", on a second client registered with the same server: the same foreign URI got a 400 page, and the team records that client as protected. The third is a medium, "PKCE not enforced": an authorization request with no code_challenge still returned a code. The developer replies that the server supports PKCE, and clients that send a challenge are protected.

As elsewhere in this series, each decision rests on the response's appearance, not on what it proves. In our lab, built to reproduce the three shapes, a 302 to evil.example came from a server that had issued no code at all: it sent the user to the unregistered URI with error=invalid_request attached. That is a real finding, but it is an open redirect on the authorization server, not code theft. A validator that answered 400 to https://evil.example/cb delivered working codes to our attacker listener through three other payloads, one of them a backslash that Python's URL parser and a browser's URL parser read as two different hosts. And the server that "supports PKCE" enforced it when a challenge was present, accepted a verifier for a code that had no challenge, and redeemed any code issued without a challenge for whoever held it.

This post is for whoever is holding an OAuth finding from a dynamic scan, or a "validated" result they are about to rely on. It covers:

It belongs to our series on confirming DAST findings; the series guide sets out the evidence classes the series uses. The open redirect post described the OAuth chain from the specifications, and this post measures it. The CSRF post covers the request mechanics state exists to stop, the JWT post covers what happens after a token is issued, and the dangling DNS post covers how an attacker comes to hold a subdomain a wildcard trusts.

How we tested. Everything ran on 21 November 2026 on a virtual machine with two vCPUs, Ubuntu 24.04 and kernel 6.8.0, using Python 3.12.3 and its standard library, with nothing installed. A toy authorization server, a client application and an attacker listener ran as threaded http.server instances on separate loopback addresses (127.0.0.1, 127.0.0.2 and 127.0.0.3), with a second attacker listener on 127.0.0.1 port 18099, standing in for another local process, for the native-app case. The harness mapped the hostnames in our URLs to those addresses and spoke plain HTTP throughout, so a URL's scheme was compared as a string and nothing else.

The harness plays the browser. It follows Location headers, keeps cookies per host, and resolves every URL with the WHATWG URL parser, through the URL class in Node.js 22.22.2, because that is the parser browsers implement. Where a code lands is decided by where a browser would send it. The harness does not run JavaScript, send Referer, or reattach fragments across redirects, so fragment delivery and Referer leakage are described from the specifications here, not measured. The authorization server approves every request automatically for a signed-in test user, so there is no consent screen. Every cell of the OAuth experiments ran three times with the same result each time; the parser comparison, which is deterministic, ran once. The code-lifetime test advanced the server's clock instead of waiting. One JSON file per experiment is archived with the lab, along with one thing we got wrong: in the first full run, the code-reuse loop built each client without its variant settings, so all three reuse variants ran as the same server. The result contradicted the variant's definition, which is how we caught it, and the whole lab was re-run.

The servers are ours, written to be wrong in specific ways. This is not a measurement of any identity provider, OAuth library, browser or scanner, ours included. RFC 6749 (OAuth 2.0), RFC 7636 (PKCE), RFC 8252 (native apps) and RFC 9700 (Best Current Practice for OAuth 2.0 Security, BCP 240, January 2025) were downloaded from rfc-editor.org on 21 November 2026, and every requirement quoted below was read in that text.

What an OAuth finding has to establish

In the authorization code flow, the client sends the browser to the authorization server's /authorize endpoint with its client_id, a redirect_uri, a state value and, with PKCE, a code_challenge. The server authenticates the user and redirects the browser to the redirect_uri with a short-lived code in the query. The client sends the code to /token, with its credentials if it has any and the code_verifier if it sent a challenge, and gets an access token.

An attacker wants one of two things. Either the victim's code or token, delivered somewhere the attacker reads and redeemable; or the reverse, the attacker's own code accepted in the victim's session, so the victim's account at the client is linked to the attacker. A finding has to say which, and how far along the chain its evidence goes.

EvidenceWhat it showsWhat it does not show
A 302 whose Location host is not the registered oneThe server redirected thereThat a code was issued, or that a browser goes there
A 302 carrying code= for an unregistered redirect_uriA code was issued for a value that should be rejectedThat the code leaves the client's host
The code arrives at a listener the tester controlsDelivery, through the hops a browser would takeThat it can be used
/token returns an access token for the testerThe attacker can redeem it directly—
The legitimate client accepts an injected codeInjection works without the client's credentials—
A forged callback links the victim's session to the testerThe callback has no working CSRF protection—

A scanner usually holds evidence from the first or second row. Everything below needs a listener, a second identity and requests to the token endpoint.

What the scanner saw, and what it meant

RFC 6749 section 4.1.2.1 covers the bad case: if the request fails "due to a missing, invalid, or mismatching redirection URI", the server "SHOULD inform the resource owner of the error and MUST NOT automatically redirect the user-agent to the invalid redirection URI."

We sent the 25 payloads to two exact-matching servers that differed only in how they reported a mismatch: one with a 400 page, the other by redirecting to the supplied URI with error=invalid_request, which the RFC forbids.

Error handlingCode issuedRejectedLocation host not the registered oneCodes for unregistered values
400 page1 of 25 (the registered value)24, as 40000
Redirect with error=1 of 2524, as 302120

A check that flags any 302 to a foreign host reports twelve "redirect_uri not validated" findings against the second server, which issued no code to any of them. The finding is real but different: the authorization server is an open redirector, the case RFC 9700 section 4.11.2 covers. Its severity is that of an open redirect, not of code theft. To tell them apart, read the Location query: code= or access_token= means issued, error= means rejected and redirected anyway.

Eleven validators, twenty-five payloads

RFC 6749 section 3.1.2.3 says that when the full redirect URI was registered, the server "MUST compare the two URIs using simple string comparison". RFC 9700 section 2.1 extends it to everyone: "authorization servers MUST utilize exact string matching except for port numbers in localhost redirection URIs of native apps". Section 4.1 says pattern matching "turned out to be more complex to implement and more error-prone to manage", and that attacks on it have been observed in the wild.

We wrote eleven validators of the kinds people write and sent each the same 25 values. The client here is public with no PKCE, so the matrix shows what the validator alone permits; the redemption section adds the other defences back.

ValidatorRegisteredAccepted (of 25)Code reached attacker
Exact stringhttps://client.example/cb10
String prefix, origin registeredhttps://client.example124
String prefix, full callback registeredhttps://client.example/cb71
Substring: contains client.examplehttps://client.example/cb2010
Parsed: scheme, netloc equal, path starts /cbhttps://client.example/cb71
Parsed: hostname equal, nothing elsehttps://client.example/cb133
Wildcard, * as .*https://*.client.example/cb54
Wildcard, * as one DNS labelhttps://*.client.example/cb21
Exact, or exact plus any queryhttps://client.example/cb30
Loopback, any port (RFC 8252 section 7.3)http://127.0.0.1/cb11
Loopback, starts with http://127.0.0.1http://127.0.0.1/cb22

Across 275 cells the servers issued 73 codes. Ten went to the client's own callbacks: nine to the registered value, and one, from the substring validator, to https://app.client.example/cb, a host the client controls. The other 63 went elsewhere: in 27 the code reached an attacker listener, and the attacker redeemed all 27 at the token endpoint; in 19 the browser reached the attacker's host without the code; in 17 the code stayed on the client's host.

String prefix on the origin accepted https://client.example.evil.example/cb, a host the attacker owns, and https://[email protected]/cb, where everything before the @ is userinfo and the host is evil.example. Both delivered, and so did two paths into the client's raw-query redirector, covered below.

String prefix on the full callback closes those: neither string starts with the registered value. Besides the registered value it still accepted six: a query, a fragment, a return_to parameter, and the callback followed by /../out, /%2e%2e/out and /%2e%2e/go. The prefix matches, then the browser removes the dot segments before sending the request (the WHATWG parser treats %2e%2e as a dot segment too) and arrives at the client's redirectors. Through /out the browser reached evil.example and the code did not; through /go the code arrived. The chain section explains the difference.

Substring accepted 20 of 25, including https://evil.example/cb?client.example, and delivered through ten payloads. It has no defensible version.

Parsing first does not help by itself. Python's urlsplit returns the path /cb/%2e%2e/out without normalising it, so path.startswith('/cb') is true while the browser goes to /out. The validator and the browser read the same URL differently, and the attacker is served by the browser's reading. Comparing only urlsplit(uri).hostname was worse: its thirteen accepted values included http:// (the code would cross the network in clear text), port 8443, all three traversals, both redirectors, and https://evil.example\@client.example/cb, which delivered the code to evil.example for the reason the next section shows.

Wildcards. Our naive wildcard reproduces the example in RFC 9700 section 4.1.1, where * is implemented as "any character". It accepted the equivalent of the RFC's example, https://evil.example/.client.example/cb, and versions with ? and a backslash in place of the /, and all three delivered. Limiting * to one DNS label stopped those, and still accepted https://takeover.client.example/cb, which in our lab pointed at the attacker, as it would after a subdomain takeover. RFC 9700 makes the same point: a wildcard implemented correctly still trusts any host an attacker manages to establish under the domain.

Query variation. RFC 6749 section 3.1.2.2 allowed a 2012 fallback: register scheme, authority and path, "allowing the client to dynamically vary only the query component". Nothing our variant accepted delivered a code, because our callback did not forward codes. RFC 9700 section 4.1.2 describes the case that works: a cb?* pattern, a callback that redirects to a parameter, and a token in the fragment, which the browser carries across the redirect. Our harness does not model that.

Loopback. RFC 8252 section 7.3 says the server "MUST allow any port to be specified at the time of the request for loopback IP redirect URIs", and RFC 9700 keeps this as the one exception to exact matching. Our compliant validator sent the code to port 18099, where a separate listener, standing in for any other process on the same machine, was waiting. That is specified behaviour, and it is why RFC 9700 section 2.1.1 says public clients "MUST use PKCE": on loopback, the port is not an identity. The validator rejected http://localhost:18099/cb when 127.0.0.1 was registered (RFC 8252 section 8.3 calls localhost "NOT RECOMMENDED"). The startswith version accepted http://[email protected]/cb and delivered to evil.example.

Where the parsers disagree

A validator parses the URL once and the browser parses it again. If they disagree about the host, the validator approves one host and the browser visits another. We put sixteen strings through Python 3.12.3's urllib.parse.urlsplit and the WHATWG URL class in Node.js 22.22.2, along with two naive string checks. "Allows" means the Python hostname equals good.example or ends with .good.example. Ten of the sixteen:

InputPython hostnamePython checkWHATWG hostname
https://[email protected]/evil.examplerejectsevil.example
https://good.example.evil.example/good.example.evil.examplerejectsgood.example.evil.example
https://evil.example\@good.example/good.exampleallowsevil.example
https://evil.example\.good.example/evil.example\.good.exampleallowsevil.example
https://evil.example\good.example/evil.example\good.examplerejectsevil.example
https://good.example:[email protected]/evil.examplerejectsevil.example
https://good.example%40evil.example/good.example%40evil.examplerejectsparse error
https:/\evil.example/good.examplenonerejectsevil.example
//evil.example/good.exampleevil.examplerejectsparse error (no base)
https://good.example./cbgood.example.rejectsgood.example.

The bold rows are the ones that matter. For special schemes such as https, the URL Standard treats a backslash as a path separator, so the browser's host ends at the backslash. Python treats it as an ordinary character: in the first case it then finds the @ and takes everything after it as the host; in the second it keeps the backslash in the hostname, and a suffix check passes. A naive startswith('https://good.example') rejects both, and a substring check accepts every row in the table.

Our server did not decode or normalise anything before validating, and a real server might. The rule holds regardless: do not validate a URL with a different parser from the one that will follow it. With exact string matching the question never arises.

Accepted, reached, redeemed

Take the 63 unregistered values that got a code, and two checks a scanner might run.

Flagging a 302 whose Location host is not the registered one flagged 19 cells, and all 19 were real deliveries. It missed 8 of the 27. In each of the eight, the authorization server redirected to client.example, as the check expects, and the client's raw-query redirector forwarded the code to evil.example on the next hop. A check that reads only the first Location cannot see a two-hop delivery.

Flagging any value outside the client's own callbacks that gets a code flagged all 63. Sixty-one of them break RFC 9700's exact-matching rule; the two codes sent to loopback port 18099 are the port variation RFC 8252 section 7.3 permits. But in 36 of the 63 no code left the client's host, including 19 where the browser reached the attacker's host without it. The first check undercounts theft; the second reports every validation flaw but cannot rank them. Ranking needs the next hop and the token endpoint.

The open-redirect chain

When a lax validator lets redirect_uri point at a redirector on the client's host, the server attaches the code to the redirector's URL. Whether it reaches the attacker depends on what the redirector does with the rest of the query, and where the code sits. Against the hostname-only validator, our client exposed /out, which parses the query and redirects to the url parameter only, and /go, which redirects to everything after url= in the raw query string. The callback also honoured a return_to parameter, parsed like /out. The browser ended on evil.example in all eight cases.

ResponseRedirectorSecret placed inSecret reached the attacker
code/out (parses)queryno
code/go (raw tail)queryyes
code, response_mode=fragment/gofragmentnot in our harness
token (implicit, fragment by default)/outfragmentnot in our harness
token/gofragmentnot in our harness
token, response_mode=query/goqueryyes
codecallback return_toqueryno
tokencallback return_tofragmentnot in our harness

With /out the server produced https://client.example/out?url=https://evil.example/&code=...; the redirector read url, ignored code, and the user landed on the attacker's page without it. With /go the attacker ended url with ?x=, so the redirect target became https://evil.example/?x=&code=...&state=..., and the code arrived.

A fragment is never sent to a server, so neither redirector saw one or put one in its Location. RFC 9700 section 4.1.2 describes what browsers do next: "user agents reattach fragments to the destination URL of a redirect if the location header does not contain a fragment", citing RFC 9110 section 17.11, and shows an access token carried that way through a client's open redirector. We did not test a browser, so those rows are not measured, not safe. Section 4.1.3 offers a server-side mitigation: put an arbitrary fragment such as #_ on redirect Location headers.

Exact matching and an open redirect elsewhere on the client. With exact matching, the attacker cannot point redirect_uri at /out, so the authorization redirect cannot reach it. The code's remaining way out is the callback page. RFC 9700 section 4.2 describes the authorization response URL, code included, leaking in Referer when that page links to or loads content from another site. How much leaks depends on the referrer policy: browsers that apply the Referrer Policy specification's default, strict-origin-when-cross-origin, send only the origin on cross-origin requests, and a weaker policy sends the whole URL. We did not measure Referer. The RFC's countermeasures are no third-party resources or external links on the callback page, Referrer-Policy: no-referrer, and single-use codes. The open redirect remains a finding, but under exact matching, check the callback page, not the redirect.

Who can redeem a leaked code

For each of the 27 cells where a code reached the attacker, we repeated the flow under eight configurations. "Injected" means the attacker pastes the stolen code into their own session at the legitimate client, which redeems it with its own secret and registered redirect_uri: the code injection attack of RFC 9700 section 4.5. Our harness sent that client's token request.

Client and token endpointRedeemed (of 27)Refused with
Public, no PKCE, attacker redeems27—
Public, PKCE S256, attacker sends no verifier0PKCE failure
Public, PKCE S256, attacker sends their own verifier0PKCE failure
Confidential, attacker has no secret0invalid_client
Confidential, injected; /token compares redirect_uri with the stored value0redirect_uri mismatch
Confidential, injected; /token re-runs the validator27—
Confidential, injected; /token ignores redirect_uri27—
Confidential with PKCE S256, injected, redirect_uri ignored0PKCE failure

A confidential client stops direct redemption, not injection. The legitimate client has the secret and will use it on any code it is handed. RFC 6749 section 10.6 describes exactly this, and puts the defence on the token endpoint: the server "MUST ensure that the redirection URI used to obtain the authorization code is identical to the redirection URI provided when exchanging the authorization code for an access token." Section 4.1.3 makes redirect_uri required at /token whenever it was sent to /authorize, "and their values MUST be identical."

"Re-checked at /token" has to mean compared, not re-validated. The client's registered callback always passes the validator, so the re-validating endpoint redeemed all 27 injections. Only the comparison with the value stored at /authorize refused them. The test sends the registered redirect_uri for a code issued to a different one.

PKCE stopped every case. The stolen code is bound to the victim's challenge, and neither the attacker nor the client session they control has the verifier. RFC 9700 section 4.5.3.1 names PKCE as the countermeasure to code injection. None of this makes the validator acceptable; it changes how severe the validator finding is for a given client.

state, and the CSRF that runs the other way

state protects the client's callback. RFC 6749 section 10.12 describes the attacker getting the victim's browser to the callback with the attacker's code, which "can result in the client using an access token associated with the attacker's protected resources rather than the victim's". In practice that is login CSRF, where the victim ends up signed in as the attacker, or account-linking CSRF, where the attacker's identity is linked to the victim's account and the attacker can then sign in to it. RFC 9700 section 2.1 accepts PKCE (once the client knows the server supports it), the OpenID Connect nonce, or "one-time use CSRF tokens carried in the state parameter that are securely bound to the user agent".

Our client had four ways of handling state. In each run the victim had signed in once; the attacker started a flow in their own browser, stopped before the callback, and had the victim's browser deliver the attacker's code.

Client's state handlingNo stateAttacker's own stateVictim's earlier state
Not sent, not checkedlinked to attackerlinked to attackerlinked to attacker
Checked against every state ever issuedrefusedlinked to attackerlinked to attacker
Bound to the session, not consumedrefusedrefusedlinked to attacker
Bound to the session, consumed on userefusedrefusedrefused

The middle rows are what a quick test misses. A client that checks state is "one of ours" rejects missing and made-up values, but the attacker's own state is one of ours too. A client that binds state to the session but never deletes it accepts the victim's old value, which matters wherever state can leak; RFC 9700 section 4.2.4 says the client SHOULD invalidate state after first use. A scanner sees state only as present and echoed. Confirmation takes two identities and two cookie jars, and the evidence is the identity the victim's session ends up with. As the CSRF post explains, SameSite=Lax does not settle this, because the forged callback is a top-level GET navigation.

PKCE, and two different "downgrades"

The client sends code_challenge (with method S256, the hash of a random code_verifier) to /authorize and the verifier to /token. Six server variants, nine tests each, public client, exact matching:

TestIgnoredOptionalVerifier not enforcedUnboundRequired, plain allowedRequired, S256 only
T1 no challenge, no verifiertokentokentokentokenrefused at /authorizerefused at /authorize
T2 no challenge, a verifier at /tokentokentokentokentokenrefused at /authorizerefused at /authorize
T3 S256 challenge, no verifiertokenrefusedtokenrefusedrefusedrefused
T4 S256, wrong verifiertokenrefusedrefusedrefusedrefusedrefused
T5 S256, right verifiertokentokentokentokentokentoken
T6 plain challenge replayed as verifiertokentokentokentokentokenrefused at /authorize
T7 method omitted, challenge replayedtokentokentokentokentokenrefused at /authorize
T8 victim's code, attacker's verifiertokenrefusedrefusedtokenrefusedrefused
T9 10-character plain verifiertokentokentokentokenrefusedrefused at /authorize

RFC 9700 section 4.8 describes the PKCE downgrade attack, which works when the client does not use or check state correctly. The attacker strips the challenge from their own request, so the code is bound to nothing, and injects it into the victim's session; the client sends its verifier, and a server that sees no challenge does not check it. Section 4.8.2 notes that the server therefore receives a code_verifier for a code issued without a challenge, and says the server "MUST ensure that if there was no code_challenge in the authorization request, a request to the token endpoint containing a code_verifier is rejected." That is T2, and all four variants that issued a code without a challenge accepted it. The two "required" variants passed only by refusing at /authorize, which RFC 9700 notes "implicitly" implements the measure.

The other flaw is a challenge the token endpoint does not enforce. Section 2.1.1: "If a client sends a valid PKCE code_challenge parameter in the authorization request, the authorization server MUST enforce the correct usage of code_verifier at the token endpoint." Our "verifier not enforced" variant checked the verifier only when one was sent, so T3 got a token: the client did everything right, and the protection vanished for anyone who omits one form field.

The rest:

A scanner reporting "PKCE not enforced" because T1 returned a code cannot tell four of these columns apart. T2, T3 and T6 to T8 can.

The authorization code itself

RFC 6749 section 4.1.2: "The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request and SHOULD revoke (when possible) all tokens previously issued based on that authorization code." It recommends "a maximum authorization code lifetime of 10 minutes". Section 4.1.3 requires the server to ensure the code was issued to the authenticated client, or for a public client, to the client_id in the request.

VariantTestResult
Reuse allowedRedeem the same code twiceTwo tokens; the first still worked
Single use, no revocationRedeem twiceSecond refused; first token still worked
Single use, revoke on reuseRedeem twiceSecond refused; first token then returned 401
600-second lifetimeRedeem at 660 seconds (clock advanced)Refused, expired
No expiryRedeem at 660 secondsToken
Client binding checkedClient A's code redeemed as public client B, and as confidential client C with C's secretBoth refused
Client binding not checkedSameBoth redeemed

Revocation is what turns reuse into a detection: if the attacker redeems first, refusing the second redemption only refuses the legitimate client, while revoking the first token cuts the attacker off. Without the client binding check, even a confidential client authenticating correctly as itself redeemed another client's code, because the server checked that the client was genuine, not that the code was the client's.

The implicit flow and response modes

RFC 9700 section 2.1.2 says clients "SHOULD NOT use the implicit grant (response type token) or other response types issuing access tokens in the authorization response" unless leakage and injection are dealt with. In the chain table, the query-mode token went through the raw redirector like a code, but needed no redemption, secret or verifier once it arrived. To test, send response_type=token, with and without response_mode=query, for a client meant to use only the code flow. An error such as unsupported_response_type is a refusal; a Location carrying access_token= is the finding.

How to confirm, without harming anyone

  1. Use your own identities: two test accounts, two cookie jars, a listener on a host you control. Never send a modified authorization link to a real user.
  2. Parse the first response. code= or access_token= in Location is issued; error= is rejected-and-redirected, an open redirect on the authorization server; a 400 page is rejected.
  3. Follow the hops as a browser would, resolving each Location with a WHATWG-conformant parser, and note whether the code is in the request that reaches your listener.
  4. Try the parser and traversal forms: userinfo, your domain under the registered host as prefix, backslash before @ and before a dot, plain and encoded dot segments into every redirector on the client host, port, scheme, query and fragment. For a wildcard, list every name it covers.
  5. Redeem as each party could: as the attacker, without the secret and with no or a wrong verifier; as the client, with its registered redirect_uri for a code issued to another.
  6. Probe the token endpoint directly: T2, T3, a second redemption, a code from one client redeemed as another.
  7. Test state with two sessions, and record whose identity the victim's session ends up with.
  8. Check the callback page for third-party content, external links and Referrer-Policy.
  9. Revoke every token and grant the test created.

Fixes that held, and fixes that did not

ChangeHeld againstDid not hold against
Exact string match on the full URIall 24 unregistered values—
String prefix, full callbackhost, userinfo and scheme trickstraversal into the raw redirector
Parse, then compare the hostnamesubstring and prefix-domain tricksbackslash parser disagreement, traversal, redirectors, http://
Wildcard limited to one DNS labelthe RFC 9700 example and variantsa subdomain the attacker holds
Error page on mismatchthe authorization server as an open redirector—
Confidential clientdirect redemptioninjection, unless /token compares redirect_uri
/token compares redirect_uri with the stored valueall 27 injections—
/token re-validates redirect_urinothing we triedall 27 injections
PKCE S256 required, verifier mandatory with a challenge and refused without onetheft, injection, T2, T3, T6 to T9— in our tests
PKCE optionala client that sends an S256 challengeT1, T2, and plain or method-less challenges (T6, T7, T9)
Single use with revocation on reusea second redemption and the first tokenuse of the token before the client's redemption attempt (follows from the design; not tested)
state bound to the session and consumedall three forged callbacks—

What the held rows share:

The static side

Much of this is visible in code. In an authorization server, find the redirect_uri comparison and look for startswith, in, contains, indexOf, a regular expression built from a pattern, or a parse that keeps only the hostname. In the token handler, check whether redirect_uri is read at all, and compared with a stored value or passed to the same validator; whether the PKCE check is guarded by "if a verifier was sent"; how a missing method is treated; whether codes are marked used in the same transaction that issues the token; and whether the code's client_id is compared with the authenticated client. In client registrations, look for wildcards and origin-only URIs. In the client, look for callbacks that redirect to a parameter, raw query forwarding, and state looked up in a global store rather than the session. Static analysis finds the places; dynamic confirmation shows whether the deployment uses them.

A triage checklist

QuestionIf the answer is no or unknown
Did the response carry code= or access_token=, not error=?Twelve foreign-host 302s carried only error=
Was Location resolved with a WHATWG parser?Python and WHATWG disagreed on hosts that decide the outcome
Was the next hop followed?A first-Location check missed 8 of 27 deliveries
Did the code reach a listener you control?In 36 of the 63 off-callback codes, the code never left the client host
Is any client redirector reachable by traversal?An encoded %2e%2e reached one and delivered
Does a wildcard cover a name someone else could hold?A one-label wildcard delivered to a taken-over name
Is the client public without PKCE?27 of 27 stolen codes redeemed
Does /token compare redirect_uri with the stored value?Re-validation let 27 of 27 injections through
Is a verifier refused for a code without a challenge?Four variants accepted it
Is a verifier required whenever a challenge was sent?A server that checked only sent verifiers issued a token without one
Are plain, a missing method, or an unbound challenge accepted?The challenge, or the attacker's verifier, redeemed the code
Is a reused code refused and its tokens revoked?Without revocation the first token kept working
Is state bound to the session and consumed?Global or reusable state linked the victim to the attacker

FAQ

Does a 302 to an attacker-controlled host prove redirect_uri is not validated? No. Read the query. An exact-matching server that redirected errors produced twelve foreign-host 302s in our lab, all with error=invalid_request and no code. That is an open redirect on the authorization server, which RFC 6749 section 4.1.2.1 forbids, but no code was issued.

Does a 400 for an attacker URI prove redirect_uri is validated? No. Our hostname-only validator rejected https://evil.example/cb and delivered codes through a backslash parser disagreement, an encoded traversal and a raw-query redirector on the client host.

What does RFC 9700 require for redirect_uri matching? Exact string matching (section 2.1), except the port of loopback redirect URIs for native apps, which RFC 8252 section 7.3 requires the server to let vary.

If matching is exact, does an open redirect on the client still matter? The authorization redirect cannot reach it. The code can still leak from the callback page through Referer if that page loads third-party content or links elsewhere under a permissive referrer policy (RFC 9700 section 4.2), and RFC 9700 forbids the open redirect itself.

Does a confidential client need PKCE? RFC 9700 recommends it. A confidential client stopped direct redemption of all 27 stolen codes in our lab, but not their injection when the token endpoint did not compare redirect_uri; PKCE stopped all 27.

What is a PKCE downgrade attack? In RFC 9700 section 4.8, the attacker removes code_challenge from their own request, so the code is bound to nothing, and injects it into the victim's session. The server must refuse a token request with a code_verifier when there was no challenge. Separately, section 2.1.1 requires the verifier whenever a challenge was sent.

Is state still needed with PKCE? RFC 9700 lets a client that has confirmed PKCE support rely on it for CSRF protection; otherwise it needs one-time state bound to the user agent. A state checked against every value ever issued let the attacker's own value through in our lab.

What this post did not measure

Our own toy servers in Python 3.12.3 on loopback, and nothing else. Not tested: any identity provider, authorization server product or OAuth library; any real browser; fragment reattachment; Referer leakage; consent screens; OpenID Connect (ID tokens, nonce, iss) and mix-up attacks; pushed authorization requests; form-post response mode; refresh tokens; sender-constrained tokens; dynamic client registration; custom URI schemes; TLS. Nothing here measures any scanner, ours included.

The hypothetical findings, resolved

Where AppSecD fits

AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. Its policy-driven gating blocks a pull request or commit when it introduces a violation. Findings are deduplicated across scans, move through new, reopened and fixed states, and can require maker-checker approval before they are closed.

That is the whole claim. data/products.ts is the single source of truth for what these products do, and it does not mention OAuth, authorization servers, redirect URIs, the state parameter, PKCE, authorization codes or the implicit flow. So this post makes no claim that AppSecD tests for any of them. Nor does it claim anything about:

The mechanisms, measurements, confirmation procedure, fixes and checklist above are general practice that applies to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any deployment, user or finding.

More about AppSecD · All posts