Skip to content

fix(oauth-provider): PAR rejects unregistered redirect_uri#184

Merged
ascorbic merged 3 commits into
mainfrom
fix/par-validate-redirect-uri
May 24, 2026
Merged

fix(oauth-provider): PAR rejects unregistered redirect_uri#184
ascorbic merged 3 commits into
mainfrom
fix/par-validate-redirect-uri

Conversation

@ascorbic
Copy link
Copy Markdown
Owner

Summary

pdscheck's `flow.par-rejects-unregistered-redirect-uri` step caught a defense-in-depth gap: Cirrus's PAR endpoint accepted any `redirect_uri` whose URL parsed cleanly, regardless of whether it was registered in the client metadata. RFC 6749 §3.1.2.4 requires rejection at this point. The subsequent `/oauth/authorize` step does re-validate (`provider.ts:370`), so the practical exploitability was limited — but issuing a `request_uri` for an unregistered redirect is itself a spec violation and a footgun if any code path elsewhere ever trusted the PAR-stored `redirect_uri` without re-checking.

Fix

  • Plumb the existing `ClientResolver` into `PARHandler`.
  • After URL-validating `redirect_uri`, resolve the client and reject with `invalid_request` if the URI isn't in `client.redirectUris`.
  • Provider constructor reordered so `clientResolver` is built before `parHandler` consumes it.
  • New regression test in `packages/oauth-provider/test/par.test.ts` covering the rejection.
  • Existing tests use a new `StubResolver` (extends `ClientResolver`) that returns a fixed registered redirect so they still pass the new check.

Test plan

  • `pnpm --filter @getcirrus/oauth-provider test` — 117 passing (12 in par.test.ts incl. the new one).
  • `pnpm --filter @getcirrus/oauth-provider check` — clean.
  • `pnpm --filter @getcirrus/pds test` — 313 unit + 84 CLI passing.
  • Re-run pdscheck OAuth flow against the deployed PDS once this lands: expect `flow.par-rejects-unregistered-redirect-uri` to pass.

ascorbic added 2 commits May 24, 2026 22:14
runPostCallback was marking every PRE_REDIRECT_STEPS entry as 'pass'
regardless of its actual outcome before the redirect — so any failure
in the pre-redirect leg (PAR boundary tests, scope selection, metadata
validation, etc.) would silently become green once the user came back
from the auth server.

Snapshot each pre-redirect step (status, message, evidence, timings)
into the persisted state alongside codeVerifier/stateNonce, and restore
from it after the callback. If no persisted result is present (older
session storage), the steps render as 'skip' with a 'no persisted
result' message rather than a fabricated pass.
RFC 6749 §3.1.2.4 requires the authorization server to reject any
redirect_uri that was not registered in the client metadata. Cirrus
checked this at the authorize step (provider.ts:370) but not at PAR,
so a caller could obtain a valid request_uri for an unregistered
redirect — defense-in-depth weakness flagged by pdscheck's
flow.par-rejects-unregistered-redirect-uri check.

Wire the existing ClientResolver into PARHandler and validate
redirect_uri against client.redirectUris before issuing the
request_uri. Adds a regression test covering the rejection.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
pdscheck 8d858a8 May 24 2026, 10:13 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
cirrusdocs 8d858a8 Commit Preview URL

Branch Preview URL
May 24 2026, 10:13 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
atproto-pds 8d858a8 May 24 2026, 10:13 PM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

Open in StackBlitz

npm i https://pkg.pr.new/create-pds@184
npm i https://pkg.pr.new/@getcirrus/oauth-provider@184
npm i https://pkg.pr.new/@getcirrus/pds@184

commit: 8d858a8

@ascorbic ascorbic enabled auto-merge (squash) May 24, 2026 22:12
@ascorbic ascorbic merged commit 47c8c1e into main May 24, 2026
7 checks passed
@ascorbic ascorbic deleted the fix/par-validate-redirect-uri branch May 24, 2026 22:13
@mixie-bot mixie-bot Bot mentioned this pull request May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant