Skip to content

fix: make redirect_uris the source of truth for OAuth2 redirect URIs - #29440

Merged
BobbyHo merged 38 commits into
mainfrom
plat-619-1-redirect-uris-source-of-truth
Sep 22, 2026
Merged

BobbyHo merged 38 commits into
mainfrom
plat-619-1-redirect-uris-source-of-truth

Conversation

@BobbyHo

@BobbyHo BobbyHo commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

First of three in PLAT-619. Since #29014 the authorize and token endpoints accept every URI in callback_url and redirect_uris. Editing an app's callback through the admin API added a URI and removed nothing, and the API showed only the callback. An admin could not move an app off a stale redirect URI. This PR makes redirect_uris the only source of truth, with the first entry as the primary, and keeps callback_url as a deprecated copy of that entry until a later PR drops it.

PR What it does
this Backfill the list, read only from it, write both columns together, validate and cap every entry.
#29502 Accept and return redirect_uris on the admin API. Mark callback_url deprecated.
#29603 Edit the list in the admin UI.
  • One data migration. No schema change, no new query, no audit table change. Requests and responses keep their shape.

Implementation Details

The fix

  • Migration 000596 rewrites every row so redirect_uris starts with callback_url. It handles NULL lists, empty lists, and lists where the callback is missing or not first, in one statement that is safe to rerun. The table holds one row per app.
  • RegisteredRedirectURIs on the app model is the one read path. The authorize and token endpoints, the corrupt-callback log line, and the API response all read through it. A callback_url that is not in the list is no longer accepted; only a binary older than the migration could write such a row.
  • One shared function decides the list for every writer: admin create and update, registration, and the RFC 7592 update. All four store the list and set callback_url to its first entry in the same statement.
  • An admin update that sends only callback_url now replaces the previous primary and keeps the other registered URIs. Before, it added the new callback and kept the old one.

Validation

  • Every entry passes the same two checks the callback passes today: the shape rule behind the oauth2_callback_url tag, and the registration rules for public apps. The shape rule moved out of the struct tag into ValidateOAuth2RedirectURIShape so it can run per entry. It now also rejects fragments, so admin and registration store the same rules.
  • A list may hold at most 32 entries of at most 2048 bytes each, checked before parsing. The cap lives in ValidateRedirectURIs, so registration is bounded too. It previously accepted anything under the 4 MiB request body limit.
  • An admin update checks only the URIs the request introduces. Stored entries are skipped, and the count cap applies only when the list grows, so an app registered before the caps stays editable.
  • A failure on the request callback_url is reported against that field as "callback URL ...", with no list index. List entries keep the indexed wording for registration callers.

Unchanged

  • Request and response types. redirect_uris on the admin API is the next PR.
  • The RFC 7592 endpoints, apart from calling the shared function. They already wrote this shape.
  • NOT NULL and a cardinality check on redirect_uris wait for the column drop, so an old replica cannot fail an insert during a rolling upgrade.
  • During the upgrade window, an admin callback edit served by an old replica writes only callback_url. New replicas read the list first and do not see it. Saving the app again on new code fixes the row. Drain old replicas before the rollout to avoid it. The migration comment and the OAuth2 provider doc say the same.

Docs

  • docs/admin/integrations/oauth2-provider.md Limitations: the list is the source of truth, the upgrade window, and the 32 entry and 2048 byte caps.
Tests
  • TestMigration000596OAuth2RedirectURIsPrimary seeds each row shape, migrates, and checks the callback is first and nothing was lost. It runs the statement again and checks nothing changed.
  • TestOAuth2ProviderAppRedirectURIs: a callback-only update moves the primary and keeps the rest; choosing an existing alternate as the callback makes it the only entry; a stale callback_url is ignored on read; create stores the callback as the list; an oversized callback is refused on create and update; an app with 33 stored URIs, one oversized, can still be renamed and keeps its list; registration stores a deduplicated list.
  • TestResolveRedirectURIs: a table over the four documented input shapes, plus dedup and callback ordering.
  • TestOAuth2AuthorizeFollowsCallbackEdit: after a callback edit the old primary is refused on Coder, the other URI still works, an omitted redirect_uri goes to the new primary, and a code issued to the old URI fails exchange with invalid_request.
  • TestOAuth2AuthorizeIgnoresCallbackColumn: a seeded row with a stale column is refused for that URI and accepted for the listed one.
  • PublicDCRCallbackURLPolicy and BasicOperations now also assert the stored list after each update.
  • TestRegisteredRedirectURIs: the column is ignored, duplicates are dropped.
  • TestValidateOAuth2RedirectURIShape and TestValidateRedirectURIsSize in codersdk: accepted and rejected shapes including a fragment, 32 accepted and 33 refused, 2048 accepted and 2049 refused, an oversized value is refused before parsing.

Manual Tests

Scenario summary, all 33
# Scenario Result
1 Admin-created app on the old binary stores an empty redirect_uris list, not NULL Pass
2 Enable dynamic client registration (DCR) Pass
3 Register a DCR app with two redirect URIs (to be edited later) and a second, untouched one Pass
4 Plant the two row shapes the old binary cannot write: a NULL list, and a list where the callback is present but not first Pass
5 The PLAT-619 bug: an admin edits a DCR app's callback through the admin API; the old primary is not removed from the list Pass
6 The old binary still accepts the URI the admin tried to move away from, with no way through the admin API to remove it Pass
7 The DCR client's own view of its registration lacks the admin's edit (the admin API and the raw list disagree) Pass
8 Snapshot the five rows before the upgrade Pass
9 Check out the PR and restart the dev server on the same database, without a reset Pass
10 Migration 000596: every row now starts with its callback, and nothing was lost, across all five row shapes Pass
11 The migration statement is idempotent: rerunning it reports UPDATE 0, rows unchanged Pass
12 Column comments landed on both callback_url (deprecated) and redirect_uris Pass
13 The admin API now reads callback_url through the list's first entry Pass
14 The DCR client's own view now includes the admin's edit, with no new request from the client Pass
15 Enforcement after the backfill still accepts every URI the migration kept Pass
16 The fix: a callback-only PUT now replaces the primary and keeps the rest of the list, instead of adding to it Pass
17 Enforcement follows the edit: the removed URI is refused, the kept ones still work Pass
18 A code issued to a URI that is then removed from the list cannot be exchanged (invalid_request) Pass
19 Headline: promoting each surviving alternate in turn walks a stale DCR app down to a single, correct entry, using only callback_url Pass
20 An admin-created app behaves exactly as before: no visible change for an admin who never used DCR Pass
21 A stale callback_url column (only possible pre-migration) is ignored by every read path; a normal PUT repairs it Pass
22 A newly admin-created app stores the callback as the list, not an empty array Pass
23 An oversized callback is refused on update, and the row is left untouched Pass
24 A malformed callback (no host) is refused with a specific reason Pass
25 The public-client loopback rule (RFC 8252 §7.3) still applies to a DCR app's callback edit Pass
26 DCR registration past the 32-URI count cap is refused; no row is created Pass
27 DCR registration past the 2048-byte cap is refused Pass
28 Registration accepts exactly 32 entries; a duplicate entry is silently deduplicated, not rejected Pass
29 Registration applies the same structure rules as the admin API: fragment, hostless https, and bare private-use scheme are each refused Pass
30 A pre-existing app over the 32-URI cap cannot be saved by either writer, but can still be deleted Pass
31 The RFC 7592 client update writes both columns: the client reorders its own list, the admin API's callback_url and enforcement both follow Pass
32 Cleanup: every test app deleted Pass
33 Cleanup: DCR flag restored to its starting value Pass

No PR bugs found. One bug found and fixed in the test runbook itself
(scenario 18's helper originally posted to the wrong token endpoint path);
see the note under section 6.

Shell helpers used throughout

Run against the dev server through a coder port-forward ... --tcp 3000:3000
tunnel; the session token and embedded Postgres both live inside the
workspace, so they're read over ssh rather than exported once.

BASE_URL=http://localhost:3000
CB=http://localhost:9876/callback     # the primary every app starts with
ALT=http://localhost:9877/alt         # a second registered URI on the DCR apps
MOVED=http://localhost:9878/moved     # what the admin moves an app's callback to, pre-upgrade
MOVED2=http://localhost:9879/moved2   # what the admin moves it to, post-upgrade
ADMIN2=http://localhost:9880/admin2   # what the admin moves an admin-created app's callback to

# $1=method $2=path $3=json body (optional). Prints "HTTP <code>"; body saved to /tmp/resp.json.
req() {
  local code token
  token=$(ssh dev.<workspace> 'cat ~/coder/.coderv2/session')
  code=$(curl -s -o /tmp/resp.json -w '%{http_code}' -X "$1" "$BASE_URL$2" \
    -H "Coder-Session-Token: $token" -H 'Content-Type: application/json' ${3:+-d "$3"})
  echo "HTTP $code"
}

# $1=SQL, against the workspace's embedded Postgres via the system psql client.
pg() {
  ssh dev.<workspace> "PGPASSWORD=\$(cat ~/coder/.coderv2/postgres/password) \
    /usr/bin/psql -h localhost -p \$(cat ~/coder/.coderv2/postgres/port) -U coder -d coder -tA -c \"$1\""
}

new_pkce() {
  VERIFIER=$(openssl rand 32 | base64 | tr -d '\n=' | tr '+/' '-_')
  CHALLENGE=$(printf '%s' "$VERIFIER" | openssl dgst -sha256 -binary | base64 | tr -d '=' | tr '+/' '-_')
  STATE=$(openssl rand -hex 16)
}
urlenc() { jq -rn --arg v "$1" '$v|@uri'; }

# $1=client_id $2=redirect_uri, or "" to omit it. POSTs /oauth2/authorize as
# the admin and prints the status and the Location it would follow.
authz() {
  new_pkce
  local token url
  token=$(ssh dev.<workspace> 'cat ~/coder/.coderv2/session')
  url="$BASE_URL/oauth2/authorize?client_id=$1&response_type=code&state=$STATE&code_challenge=$CHALLENGE&code_challenge_method=S256"
  [ -n "${2:-}" ] && url="$url&redirect_uri=$(urlenc "$2")"
  curl -s -X POST "$url" -H "Coder-Session-Token: $token" -w 'HTTP %{http_code} redirect=%{redirect_url}\n'
}

# $1=client_id $2=code $3=redirect_uri. Exchanges with VERIFIER from the last authz call.
exchange() {
  curl -s -o /tmp/token.json -w 'HTTP %{http_code}\n' -X POST "$BASE_URL/oauth2/tokens" \
    -d grant_type=authorization_code -d "client_id=$1" -d "code=$2" \
    -d "redirect_uri=$3" -d "code_verifier=$VERIFIER"
}
1. Register apps on the old binary (parent commit)
req POST /api/v2/oauth2-provider/apps '{"name":"admin","callback_url":"'"$CB"'"}'
pg "SELECT callback_url, redirect_uris, redirect_uris IS NULL FROM oauth2_provider_apps WHERE id = '$A1_ID';"

req PUT /api/v2/oauth2-provider/settings '{"dynamic_client_registration_enabled":true}'

req POST /oauth2/register '{"redirect_uris":["'"$CB"'","'"$ALT"'"],"client_name":"dcr-edited","token_endpoint_auth_method":"none"}'
req POST /oauth2/register '{"redirect_uris":["'"$CB"'","'"$ALT"'"],"client_name":"dcr-untouched","token_endpoint_auth_method":"none"}'

pg "UPDATE oauth2_provider_apps SET redirect_uris = NULL WHERE id = '$P1_ID';"
pg "UPDATE oauth2_provider_apps SET redirect_uris = ARRAY['$ALT','$CB'] WHERE id = '$P2_ID';"
admin app       -> HTTP 201  row: CB | {} | f            (old binary: empty list, not NULL)
DCR settings    -> HTTP 200  false -> true
DCR app (edited)-> HTTP 201  row: CB | {CB,ALT}           (callback-first shape)
DCR app (kept)  -> HTTP 201  row: CB | {CB,ALT}           (identical shape, used as a control)
planted NULL    -> UPDATE 1  row: CB |     | t            (redirect_uris IS NULL)
planted 2nd     -> UPDATE 1  row: CB | {ALT,CB}           (callback present, not first)
2. Reproduce the PLAT-619 bug
req PUT "/api/v2/oauth2-provider/apps/$D1_ID" '{"name":"dcr-edited","callback_url":"'"$MOVED"'"}'
pg "SELECT callback_url, redirect_uris FROM oauth2_provider_apps WHERE id = '$D1_ID';"

authz "$D1_ID" "$CB"
authz "$D1_ID" "$MOVED"
authz "$D1_ID" ""

curl "$BASE_URL/oauth2/clients/$D1_ID" -H "Authorization: Bearer $REG_TOKEN"
admin PUT       -> HTTP 200  callback_url now MOVED; row: MOVED | {CB,ALT}   (list untouched)
authz CB        -> HTTP 302  code issued            <- the bug: still accepted after the "move"
authz MOVED     -> HTTP 302  code issued
authz (omitted) -> HTTP 302  redirects to MOVED, the column
DCR self-view   -> HTTP 200  redirect_uris = [CB, ALT]   (no MOVED: the client and the admin API disagree)

The admin's edit added MOVED and removed nothing; there was no way through
the admin API to revoke CB.

3-4. Snapshot, upgrade, and the migration's output

Snapshotted all five rows and schema_migrations = 595, then checked out
the PR branch and restarted the dev server on the same database (no
--db-reset).

ssh dev.<workspace> 'cd ~/coder && git fetch origin pull/29440/head:pr-29440 && git checkout pr-29440'
ssh dev.<workspace> 'tmux new-session -d -s coderd "env CODER_OAUTH2_PROVIDER_ENABLE=true ./scripts/develop.sh 2>&1 | tee ~/coderd-b.log"'
pg "SELECT version, dirty FROM schema_migrations;"
rows   # SELECT name, callback_url, redirect_uris FROM oauth2_provider_apps WHERE name LIKE 'test-%'
pg "UPDATE oauth2_provider_apps SET redirect_uris = array_prepend(callback_url, array_remove(COALESCE(redirect_uris, '{}'::text[]), callback_url)) WHERE redirect_uris[1] IS DISTINCT FROM callback_url;"
migration        -> schema_migrations: 595 -> 596, not dirty
admin app        -> {}          -> {CB}                  (empty list: callback prepended)
DCR edited (D1)  -> {CB,ALT}    -> {MOVED,CB,ALT}         (callback absent: prepended, both kept)
DCR untouched(D2)-> {CB,ALT}    -> {CB,ALT}                (already callback-first: row not touched)
planted NULL     -> NULL        -> {CB}                    (COALESCE to empty, callback prepended)
planted 2nd      -> {ALT,CB}    -> {CB,ALT}                (callback moved from position 2 to 1)
rerun migration  -> UPDATE 0, rows unchanged (idempotent)
column comments   -> present on both columns (cosmetic wording differs slightly from the draft, same meaning)
admin API GET    -> callback_url now equals redirect_uris[1] for every app
DCR self-view (D1)-> redirect_uris = [MOVED, CB, ALT]     (now includes the admin's pre-upgrade edit)
authz CB/ALT/MOVED/omitted -> all four still 302           (nothing lost by the migration)
5. The fix: a callback-only `PUT` actually replaces the primary
req PUT "/api/v2/oauth2-provider/apps/$D1_ID" '{"name":"dcr-edited","callback_url":"'"$MOVED2"'"}'
pg "SELECT callback_url, redirect_uris FROM oauth2_provider_apps WHERE id = '$D1_ID';"
authz "$D1_ID" "$MOVED"    # the URI just removed
authz "$D1_ID" "$CB"       # still registered
authz "$D1_ID" ""          # default

# issue a code to MOVED2, then move the primary away, then try to redeem it
OUT=$(authz "$D1_ID" "$MOVED2"); CODE=$(last_code "$OUT")
req PUT "/api/v2/oauth2-provider/apps/$D1_ID" '{"name":"dcr-edited","callback_url":"'"$ALT"'"}'
exchange "$D1_ID" "$CODE" "$MOVED2"

# repeat, promoting the last surviving alternate each time
req PUT "/api/v2/oauth2-provider/apps/$D1_ID" '{"name":"dcr-edited","callback_url":"'"$CB"'"}'
authz "$D1_ID" "$ALT"
PUT MOVED2   -> HTTP 200  row: MOVED2 | {MOVED2,CB,ALT}    MOVED gone, CB/ALT kept
authz MOVED  -> HTTP 400  "must match one of the application's registered redirect URIs"   <- the fix
authz CB     -> HTTP 302  still accepted
authz omitted-> HTTP 302  now redirects to MOVED2

stale code exchange -> HTTP 400  invalid_request (redirect_uri no longer registered; checked before code lookup)
  (found & fixed a bug in the test's own exchange() helper here: it posted to
  /oauth2/tokens -- the singular /oauth2/token silently hit the SPA route
  and returned 200 with the dashboard HTML instead of an error)

PUT CB (promote last alternate) -> HTTP 200  row: CB | {CB}   single entry
authz ALT (just removed)        -> HTTP 400  refused

Starting from D1's three-entry post-migration list, the admin walked it
down to one correct entry using nothing but repeated callback_url edits
-- the PLAT-619 headline, achievable here in steps; the next PR's list
field makes it one request.

6. Backward compatibility and the stale column
req PUT "/api/v2/oauth2-provider/apps/$A1_ID" '{"name":"admin","callback_url":"'"$ADMIN2"'"}'
authz "$A1_ID" ""
authz "$A1_ID" "$CB"

pg "UPDATE oauth2_provider_apps SET callback_url = 'http://localhost:9999/stale' WHERE id = '$D2_ID';"
req GET "/api/v2/oauth2-provider/apps/$D2_ID"
authz "$D2_ID" "http://localhost:9999/stale"
authz "$D2_ID" ""
req PUT "/api/v2/oauth2-provider/apps/$D2_ID" '{"name":"dcr-untouched","callback_url":"'"$CB"'"}'

req POST /api/v2/oauth2-provider/apps '{"name":"admin-new","callback_url":"'"$CB"'"}'
pg "SELECT redirect_uris FROM oauth2_provider_apps WHERE id = '$A3_ID';"
admin app callback move -> HTTP 200  row: ADMIN2 | {ADMIN2}   same behavior as before this PR
authz omitted/CB         -> 302 to ADMIN2 / 400 for the old CB   no visible change for a DCR-free admin

stale column planted -> UPDATE 1
GET                   -> callback_url is CB, not the planted stale value   (reads redirect_uris[1])
authz stale value     -> HTTP 400  refused
authz omitted         -> HTTP 302  to CB, the true primary
repair PUT            -> HTTP 200  row back to CB | {CB,ALT}, list untouched

new admin-created app -> row: {CB}, not {} as the old binary would have left it
7. Validation and caps
req PUT ".../$A1_ID" '{"name":"admin","callback_url":"http://localhost:9876/aaa...(2027 a's)"}'
req PUT ".../$A1_ID" '{"name":"admin","callback_url":"http:///no-host"}'
req PUT ".../$D1_ID" '{"name":"dcr-edited","callback_url":"http://example.com/cb"}'

req POST /oauth2/register '{"redirect_uris":[...33 URIs...],...}'
req POST /oauth2/register '{"redirect_uris":["http://localhost:9876/aaa...(2027 a's)"],...}'
req POST /oauth2/register '{"redirect_uris":[...32 URIs...],...}'
req POST /oauth2/register '{"redirect_uris":["'"$CB"'","'"$CB"'","'"$ALT"'"],...}'   # duplicate
for u in "$CB#frag" "https:///no-host" "com.example.app:cb"; do req POST /oauth2/register ...; done

# a pre-existing over-cap row (planted by SQL, since registration itself
# cannot create one)
pg "UPDATE oauth2_provider_apps SET redirect_uris = ARRAY(...33 entries...) WHERE id = '$OC_ID';"
req PUT ".../$OC_ID" '{"name":"renamed","callback_url":"..."}'
curl -X PUT "$BASE_URL/oauth2/clients/$OC_ID" -d '{"redirect_uris":[...33...],...}'
req DELETE ".../$OC_ID"
oversized callback (update)  -> HTTP 400  "callback URL must be at most 2048 bytes"; row untouched
malformed callback (no host) -> HTTP 400  "callback URL http and https URLs must include a host"; row untouched
public-client loopback rule  -> HTTP 400  "public clients may only use http with loopback addresses ..."; row untouched

register, 33 URIs   -> HTTP 400  invalid_client_metadata: "at most 32 redirect URIs are allowed"; 0 rows
register, oversized -> HTTP 400  invalid_client_metadata: "redirect URI at index 0: must be at most 2048 bytes"
register, 32 URIs   -> HTTP 201  32 entries stored (exactly the cap)
register, duplicate -> HTTP 201  [CB, ALT]  -- collapsed by dedup, not rejected
register, fragment/hostless/bare-scheme -> HTTP 400 x3  invalid_client_metadata, one reason each; 0 rows

pre-existing 33-entry row:
  admin PUT      -> HTTP 400  field redirect_uris, "at most 32 redirect URIs are allowed"
  RFC 7592 PUT   -> HTTP 400  invalid_client_metadata, same reason
  row unchanged (33 entries)
  DELETE         -> HTTP 204  (deletion is the working recovery path)
8. The RFC 7592 client update writes both columns

Run before cleanup, since it needs the untouched DCR app from section 1.

curl -X PUT "$BASE_URL/oauth2/clients/$D2_ID" -H "Authorization: Bearer $REG_TOKEN" \
  -d '{"redirect_uris":["'"$ALT"'","'"$MOVED2"'"],"client_name":"dcr-untouched","token_endpoint_auth_method":"none"}'
pg "SELECT callback_url, redirect_uris FROM oauth2_provider_apps WHERE id = '$D2_ID';"
req GET "/api/v2/oauth2-provider/apps/$D2_ID"
authz "$D2_ID" ""
authz "$D2_ID" "$CB"
client reorders its list -> HTTP 200  redirect_uris = [ALT, MOVED2]
row     -> ALT | {ALT,MOVED2}
admin API callback_url -> ALT   (follows the client's own edit)
authz omitted -> 302 to ALT
authz CB      -> 400  (dropped from the client's new list)
9. Cleanup
req GET /api/v2/oauth2-provider/apps
for id in $(jq -r '.[] | select(.name|startswith("test-")) | .id' /tmp/resp.json); do
  req DELETE "/api/v2/oauth2-provider/apps/$id"
done
pg "SELECT count(*) FROM oauth2_provider_apps WHERE name LIKE 'test-%';"
req PUT /api/v2/oauth2-provider/settings '{"dynamic_client_registration_enabled":false}'
8 apps deleted, each HTTP 204
remaining test rows: 0
DCR flag restored to false (its starting value)

Stack: this PR, then #29502 (admin API), then #29603 (UI).

Editing an app's callback added a new accepted URI without removing the
old one, and the admin API only showed the callback (PLAT-619, SEC-870).

- Backfill every row so the callback is the first redirect URI. The
  migration handles empty, missing, and out-of-order lists and is safe
  to rerun. The callback column is kept, marked deprecated.
- Read redirect URIs from the list only. A callback that is not in the
  list is no longer accepted.
- Write both columns together from one shared function. A callback-only
  update now replaces the previous primary and keeps the rest.
- Validate every entry the same way as the callback.
- Cap the list at 32 entries of 2048 bytes each, including at
  registration.

No existing request or response changes shape.
@linear-code

linear-code Bot commented Sep 16, 2026

Copy link
Copy Markdown

PLAT-619

@BobbyHo

BobbyHo commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review in progress (17/17 reviewers complete) | View chat
Requested: 2026-09-17 04:06 UTC by @BobbyHo

deep-review v0.9.0 | Round 4 | c29116d..255b2f5

Last posted: Round 4, 28 findings (1 P2, 11 P3, 9 Nit, 7 Note), COMMENT. Review

Finding inventory

Finding inventory - PR #29440

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 Note Superseded by CRF-7 (caps make it functional) coderd/oauth2provider/apps.go:56 validateRedirectURIs labels error redirect_uris on a field admin cannot set R1 Netero No
CRF-2 Note Author fixed (da9563c) coderd/oauth2provider/apps.go:33 resolveRedirectURIs silently de-dups DCR list; RFC 7592 GET echo changes; no write-path test R1 Netero Yes
CRF-3 Note Folded into CRF-12 coderd/oauth2provider/apps.go:51 validateRedirectURIs reimplements count/byte caps also in codersdk R1 Netero No
CRF-4 P2 Author fixed (718b1f9) coderd/oauth2provider/apps.go:233 Admin update re-validates carried-over stored URIs against new caps; legacy over-cap DCR app becomes uneditable, reintroducing PLAT-619 lockout R1 Ryosuke P2, Hisoka P2, Razor P3, Knuckle P3, Mafuuu P3, Pariston P3 Yes
CRF-5 P3 Author accepted R4 (explicit human known-risk acceptance; PRRC_kwDOGkVX1s7wYjpk) coderd/database/modelmethods.go:666 Read flip to redirect_uris[0] silently drops an admin callback edit made on an old replica mid rolling upgrade R1 Knov Yes
CRF-6 P3 Author fixed (a8067c9) coderd/oauth2provider/apps.go:33 resolveRedirectURIs ships branches no caller reaches and no test covers (build ahead of caller) R1 Bisky, Mafu-san, Luffy Yes
CRF-7 P3 Author fixed (f59171f) coderd/oauth2provider/apps.go:74 Admin callback validation error names redirect_uris / "index N", a field and index the admin never supplied R1 Leorio P3, Chopper Nit, Netero Yes
CRF-8 P3 Author fixed (da9563c) coderd/database/models.go:5627 Generated deprecation comment says redirect_uris[1]; a Go reader (0-based) gets the wrong element or a panic R1 Leorio Yes
CRF-9 Note Author fixed (da9563c) coderd/oauth2provider/apps.go:83 Admin and DCR writers store one column with divergent confidential-app rules (fragments allowed via admin) R1 Knov Yes
CRF-10 Note Author fixed (da9563c) coderd/oauth2provider/authorize.go:461 authorize parsed[0] and db2sdk [0] rely on an implicit min-length-1 invariant of RegisteredRedirectURIs R1 Razor, Ryosuke, Chopper Yes
CRF-11 Nit Author fixed (da9563c) codersdk/oauth2_validation.go:108 ValidateOAuth2CallbackURL is a generic redirect-URI shape check; name misleads R1 Gon Yes
CRF-12 Nit Author fixed (da9563c) coderd/oauth2provider/apps.go:51 validateRedirectURIs collides with codersdk.ValidateRedirectURIs but reimplements caps R1 Gon, Netero Yes
CRF-13 Nit Author fixed (da9563c) coderd/oauth2provider/apps.go:48 validateRedirectURIs doc restates the shape rules ValidateOAuth2CallbackURL already documents (drift) R1 Gon Yes
CRF-14 Nit Author fixed (da9563c) codersdk/oauth2_validation_test.go:56 uri(i) generator is cryptic; distinctness it buys is unused R1 Bisky Yes
CRF-15 Nit Author fixed (f59171f) coderd/oauth2provider/apps.go:80 Inconsistent punctuation between the two per-entry detail formats R1 Leorio Yes
CRF-16 P3 Author fixed (1e38088) coderd/oauth2provider/registration.go:306 CRF-4 fix missed the RFC 7592/DCR update writer: legacy over-cap DCR app is still locked out of self-service config updates R2 Meruem P3, Mafuuu P3, Luffy P3 Yes
CRF-17 P3 Author fixed (6f7112a) codersdk/oauth2_validation.go:106 New doc claim "Every stored redirect URI passes this check" is false; DCR path never runs the shape check for confidential apps (host/path/opaque divergence) R2 Mafuuu P3, Ryosuke Note Yes
CRF-18 Nit Author fixed (1e38088) codersdk/oauth2_validation.go:87 ValidateRedirectURIScheme doc comment duplicated verbatim (pre-existing; file central to PR) R2 Knov Yes
CRF-19 Nit Author fixed (a4c5940) coderd/oauth2provider/apps.go:34 resolveRedirectURIs doc references "the next PR", a forward reference that goes stale when that PR lands R2 Gon P2 (downgraded) Yes
CRF-20 P3 Author fixed (05348bf) docs/admin/integrations/oauth2-provider.md:718 CRF-5 mitigation docs (provider doc + migration comment) understate the consequence: reads like a display lag, hides that the stale URI stays a live accepted redirect target R2 Leorio Yes
CRF-21 Nit Author fixed (a4c5940) coderd/oauth2provider/apps.go:96 Public-client rejection detail doubles the phrase "public client" R2 Leorio Yes
CRF-22 Note Author fixed (c995ef8) coderd/oauth2provider/apps.go:171 Admin callback field yields two message qualities: shape failure via struct tag is generic/unactionable, size failure is specific; fragment rejection now hits the generic message R2 Chopper Yes
CRF-23 Note Author accepted R4 (non-empty DCR list matches read owner; leave as is) coderd/oauth2provider/registration.go:255 RFC 7592 responses echo raw app.RedirectUris, not the single read owner RegisteredRedirectURIs(); second read of the column that will diverge if fallback/dedup changes R2 Kurapika, Razor Yes
CRF-24 P3 Open coderd/oauth2provider/apps.go:91 Admin confidential path skips ValidateRedirectURI, so it accepts http:// to non-loopback hosts that the DCR path rejects (plaintext auth-code transport); PR's "same rules" claim overstated R4 Razor P3, Knov Note (Ryosuke: intentional) Yes
CRF-25 P3 Open codersdk/oauth2_validation.go:207 CRF-16 fix counts the raw resent list against a deduplicated stored baseline, so a legacy over-cap DCR app with duplicate URIs is still locked out of its own RFC 7592 updates R4 Hisoka P3, Razor Note Yes
CRF-26 P3 Open codersdk/oauth2_validation.go:113 Doc invariant "every stored redirect URI passes it" is false: the CRF-16 stored-skip re-opened the CRF-17 class; legacy rows keep unvalidated URIs (also apps.go:52 sibling doc) R4 Mafu-san P3, Leorio P3, Mafuuu Nit Yes
CRF-27 Nit Open codersdk/oauth2_validation.go:115 ValidateOAuth2RedirectURIShape carries an OAuth2 infix its sibling validators (ValidateRedirectURI*) do not R4 Gon Yes
CRF-28 Note Open codersdk/oauth2_validation.go:203 grow-only-cap + stored-skip branch logic duplicated between ValidateRedirectURIsUpdate and validateAppRedirectURIFields; cross-ref comments assert they match R4 Ryosuke, Gon Yes
CRF-29 P3 Open codersdk/oauth2_validation.go:168 validateScheme messages keep a "redirect URI ..." subject while post-unification callers add their own, producing "callback URL redirect URI must have a scheme" / doubled index subject R4 Leorio Yes
CRF-30 Note Open codersdk/oauth2_validation.go:141 CRF-17 unification newly rejects opaque-form custom-scheme URIs (scheme:path, no slash) that DCR accepted pre-PR; backward-compat for native-app clients, no changelog R4 Knov, Meruem Yes

Contested and acknowledged

CRF-5 (P3, modelmethods.go:666) - Rolling-upgrade read/write skew drops an admin callback edit

  • Finding: Flipping the read owner to redirect_uris[0] while an old replica still writes only callback_url means an admin callback edit that lands on an old replica mid-upgrade is silently dropped and does not self-heal.
  • Author defense (R2): No code change. The window is short and requires a callback edit to land on a pre-migration replica. Documented the operational mitigation (drain old replicas before rollout, or re-save the app on new code) in the migration comment, the PR description, and the OAuth2 provider doc under Limitations (commits 58d2036, f9bed52).
  • Status: Acknowledged and documented. Not yet panel-evaluated. The panel judges whether the documented mitigation is an acceptable disposition for a silent, non-recovering data drop, or whether a human accept/ticket decision is still needed.
  • Panel closure (R2): The mitigation is the correct engineering response because the read-flip that fixes PLAT-619 and a self-heal from callback_url are mutually exclusive (Ryosuke, Pariston, Takumi traced the conflict), so no in-PR code fix exists. But a silent non-self-healing drop cannot be accepted as permanent by a reviewer or the author-agent; needs an explicit human accept or a linked ticket.
  • Author accepted (R4, PRRC_kwDOGkVX1s7wYjpk): "Accepting this as a known risk. The rolling-upgrade window is an accepted limitation of this change, not something a later PR is expected to close." Consequence and mitigation documented for operators. This is the explicit human accept the panel required; finding closed.

CRF-23 (Note, registration.go:255) - RFC 7592 responses echo raw app.RedirectUris

  • Finding: The RFC 7592 GET/PUT responses echo app.RedirectUris directly (lines 192, 255, 412) rather than the single read owner RegisteredRedirectURIs(); a second read of the column that will diverge if the fallback or dedup semantics change.
  • Author accepted (R4, IC_kwDOGkVX1s8AAAABVD1XYA): Every dynamically registered client has a non-empty list, so the raw read matches what RegisteredRedirectURIs() returns today. Leaving as is for this PR.
  • Panel closure: Acceptable. Kurapika and Razor both rated it a Note (benign today), and the author engaged with the consequence. Closed.

Round log

Round 1

Netero-only first pass: 3 Notes, mechanical floor clean (P3-and-below gate). Panel of 17 (kurapika, razor, knov, knuckle, ryosuke, ging-go, chopper, komugi, mafuuu, bisky, hisoka, mafu-san, pariston, gon, leorio + wildcards killua, luffy). Convergence: 6 reviewers on CRF-4 (admin lockout), 2 at P2. kurapika, ging-go, komugi, killua: no findings. 1 P2, 4 P3, 2 Notes new, 5 Nits. CRF-1 superseded, CRF-3 folded. Reviewed against 6967259..96bbec0.

Round 2

Churn guard PROCEED: 12 addressed, 1 acknowledged (CRF-5, documented), 0 silent. Author pushed 718b1f9, 58d2036, f9bed52, 69bee1c, a8067c9, f59171f, da9563c; branch rebased (base d671150). Panel re-verifies the fixes against d671150..4c16899.

Round 2 (post-panel)

Netero: no findings; all 12 fixes verified mechanically. Panel of 16 (kurapika, razor, knov, ryosuke, meruem, mafuuu, hisoka, bisky, komugi, mafu-san, pariston, gon, leorio, chopper + wildcards takumi, luffy). All 12 fixes confirmed at root. New: CRF-16 P3 (3-way convergence Meruem/Mafuuu/Luffy: CRF-4 fix missed the RFC 7592 writer, verified in code), CRF-17 P3 (false doc invariant + admin/DCR validation divergence), CRF-20 P3 (CRF-5 doc understates consequence), plus 3 Nits and 2 Notes. CRF-5 held open at P3: whole panel agrees documented mitigation is the correct engineering response (no in-PR code fix; the read-flip and self-heal invariants conflict) but a silent non-self-healing drop cannot be agent-accepted; needs explicit human accept or a linked PLAT-619 ticket. CRF-6 closure (tests+doc for build-ahead) accepted as documented stacked design. Reviewed against d671150..4c16899. Event COMMENT (no P0/P1).

Round 3

BLOCKED by churn guard. Author addressed 5 (CRF-17 6f7112a, CRF-19/CRF-21 a4c5940, CRF-20 05348bf, CRF-22 c995ef8) and re-resolved CRF-5 without a new response (acknowledged, PROCEED-side). Three findings silent: CRF-16 (P3, verified registration.go unchanged), CRF-18 (Nit), CRF-23 (Note). These three were auto-folded into the round-2 review body (their lines were off the diff), which likely explains why they were missed while every inline thread was resolved. No panel, no Netero. Block review posted naming the silent items and the CRF-5 human-decision request. Branch rebased (base c29116d), squashed to single commit d6e9e78.

Round 4

Churn guard PROCEED: 2 addressed (CRF-16 fix 1e38088, CRF-18), 2 acknowledged (CRF-23 leave-as-is, CRF-5 explicit human accept), 0 silent. Block cleared. Panel re-verifies the CRF-16 fix (new stored-aware DCR update validator) plus the previously-unreviewed round-3 fixes (CRF-17 unification 6f7112a, CRF-22 struct-tag removal c995ef8), since round 3's panel was blocked. Reviewed against c29116d..255b2f5.

Round 4 (post-panel)

Netero: no findings. Panel of 15 (kurapika, razor, knov, meruem, ryosuke, chopper, bisky, hisoka, komugi, mafuuu, mafu-san, pariston, gon, leorio + wildcard killua). All four target fixes (CRF-16/17/18/22) verified at root, no cap bypass (stored is server-derived). But the fixes introduced/exposed new issues: CRF-24 P3 (admin confidential http-transport divergence, PR's "same rules" claim overstated), CRF-25 P3 (CRF-16 raw-vs-dedup count re-locks legacy over-cap DCR apps with duplicate URIs, verified in code), CRF-26 P3 (false doc invariant reintroduced by the stored-skip), CRF-29 P3 (validateScheme messages stutter after unification), plus CRF-28/30 Notes and CRF-27 Nit. Event COMMENT (no P0/P1). Reviewed against c29116d..255b2f5.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clean, well-tested change. Collapsing every consumer onto RegisteredRedirectURIs() gives one source of truth with a primary-first invariant, the migration is idempotent and lossless (WHERE redirect_uris[1] IS DISTINCT FROM callback_url with array_prepend/array_remove, verified by a re-run assertion), and the tests read the database directly instead of trusting response echoes. Bisky put it well: "this suite is lovely."

One P2 stands out. Six reviewers independently converged on CRF-4: UpdateApp re-validates the app's carried-over stored redirect URIs against the two caps this PR introduces, so a legacy DCR app whose list predates the caps becomes uneditable through the admin API, reintroducing the exact PLAT-619 lockout this PR exists to remove. Two reviewers rate it P2. The fix is to validate only the entries the request actually supplies and let already-stored entries pass through until the list-editing API lands.

Severity count: 1 P2, 4 P3, 2 Notes, 5 Nits. The P3s cluster around real seams: a silent lost callback edit during a rolling upgrade (CRF-5), resolveRedirectURIs shipping untested branches ahead of its caller (CRF-6), and error messages that name a field and index the admin never supplied (CRF-7). CRF-4 and CRF-5 both hinge on deployment or data states that no reviewer can bound from the diff, and both need a human decision rather than silent acceptance.

Netero's first-pass CRF-1 (field mislabel) is superseded by CRF-7: what read as cosmetic becomes the operator-visible symptom once the caps make the input reachable.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread coderd/database/modelmethods.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread coderd/database/models.go Resolved
Comment thread codersdk/oauth2_validation.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread codersdk/oauth2_validation_test.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
… app update

- Admin updates re-checked the whole stored list against the new caps.
- Apps registered before the caps with over 32 URIs, or a URI over 2048 bytes, could not be edited at all.
- Only URIs the request adds are checked now. The count cap applies only when the list grows.
… redirect URIs

- An old replica writes only callback_url on an admin update.
- New replicas read redirect_uris first, so that edit is not seen until the app is saved again.
- Drain old replicas before upgrading to avoid it.
…de window

- redirect_uris is now the source of truth, with the primary first.
- During a rolling upgrade, a callback edit on an old replica is not seen by new replicas until the app is saved again.
- An app may register at most 32 redirect URIs of at most 2048 bytes each. Older apps beyond that keep working.
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

- Covers all four documented input shapes, plus dedup and callback ordering.
- The doc comment notes that the list-with-callback and neither shapes get their caller when the admin API gains redirect_uris in the next PR.
…he callback field

- A failure on the request callback_url now says "callback URL ..." with no list index.
- List entries keep the indexed wording for registration callers.
…lidation

- The shape check now rejects fragments, so admin and registration store the same rules.
- Rename ValidateOAuth2CallbackURL to ValidateOAuth2RedirectURIShape and the local validator to validateAppRedirectURIFields.
- The column comment says "first entry of redirect_uris" instead of a 1-based index.
- RegisteredRedirectURIs documents that it is never empty.
- Test that registration stores a deduplicated list. Use plain numbered test URIs.
@BobbyHo

BobbyHo commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2. The author addressed all 15 round-1 findings and the panel verified each fix at the source, not just the response. CRF-4 (the P2 admin lockout) is fixed at root: validateAppRedirectURIFields skips stored URIs and gates the count cap on growth, so a legacy over-cap app stays editable, covered by a new 33-URI test. The renames, the fragment unification, the min-length invariant doc, the error-message rework, and the generated-comment fix all landed. Hisoka put it well: "Boring code gets silence. This wasn't boring, and it still walked away."

One fix was incomplete. Three reviewers (Meruem, Mafuuu, Luffy) independently found that the CRF-4 relaxation was applied only to the admin writer; the RFC 7592 / DCR self-service update path still runs the new caps over the client's full resent list with no stored exemption, so a legacy over-cap DCR app cannot update its own registration without first dropping URIs. Verified: UpdateClientConfiguration gates on req.Validate() -> ValidateRedirectURIs, which has no stored context. Same lockout class, on the writer the fix missed (CRF-16). The rule that one correction implies every instance applies here: thread stored URIs through both writers.

CRF-5 (rolling-upgrade skew) stays open at P3. The whole panel agrees the documented mitigation is the correct engineering response, because the read-flip that fixes PLAT-619 and a self-heal from callback_url are mutually exclusive, so no in-PR code change closes it. But a silent, non-self-healing drop whose failure mode reopens the exact stale-redirect-URI exposure PLAT-619 exists to end is not something a reviewer or the author-agent can accept as permanent. It needs an explicit human accept or a linked PLAT-619 tracking item, not documentation alone. Relatedly, CRF-20: the mitigation doc and migration comment read like a display lag and undersell that the stale URI stays a live redirect target during the window.

New this round: 3 P3 (CRF-16, CRF-17, CRF-20), plus CRF-5 held open at P3, 3 Nits, 2 Notes. CRF-6's build-ahead branches were closed with a table test and a disclosing comment rather than removal; the panel accepts that as a documented stacked-PR design.


coderd/oauth2provider/registration.go:306

P3 [CRF-16] The CRF-4 fix was applied only to the admin writer; the RFC 7592 / DCR update path still applies the new 32-count / 2048-byte caps to a legacy over-cap client's full resent list, so that client is locked out of its own config updates. (Meruem P3, Mafuuu P3, Luffy P3)

UpdateClientConfiguration gates on req.Validate(), which calls codersdk.ValidateRedirectURIs... Unlike the admin path, this path passes nil for stored and has no stored-skip: every entry the client resends is re-judged against the new caps.

Three reviewers converged. Verified: req.Validate() -> ValidateRedirectURIs enforces the hard caps with no stored context, and RFC 7592 update is a full replace, so a pre-cap DCR app with >32 URIs or a >2048-byte URI cannot edit any field (name, logo, scope) without first trimming its list, while GET still hands it that same list. Narrower than the admin case because the client owns its list, but it is the same class the fix set out to remove. Apply the same stored-aware relaxation on the update path (scope to update; create should still enforce the caps), or route both writers through one (candidate, stored) validator.

🤖

codersdk/oauth2_validation.go:87

Nit [CRF-18] The ValidateRedirectURIScheme doc comment is duplicated verbatim (the same 7 lines appear twice). (Knov)

Pre-existing at the base SHA, not introduced here, but this PR rewrites the surrounding file and it is a central file to the change, so it is cheap to fix in the same pass. Delete the second copy.

🤖

coderd/oauth2provider/registration.go:255

Note [CRF-23] The RFC 7592 responses echo the raw app.RedirectUris (also lines 192, 412) while every enforcement and admin path reads through the single owner RegisteredRedirectURIs(). (Kurapika, Razor)

Benign today because a DCR app always has a non-empty, deduplicated list, so the raw read equals the owner's output. Worth knowing: it is a second read of the same column that will diverge from the owner if the empty-list fallback or the dedup semantics ever change. Not worth changing now.

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread codersdk/oauth2_validation.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
- ValidateRedirectURI now rejects hostless http(s) and opaque URIs for every client type.
- Move the shared rules into a helper so both paths use one copy.
- Test that ValidateRedirectURI rejects everything the shape check rejects.
…upgrade

- The doc bullet and migration comment said the edit was "not visible".
- They now say it is silently discarded and the app keeps accepting the previous redirect URIs until saved again.
- Drop the forward reference to the next PR from the resolveRedirectURIs doc.
- Let the public client rejection message stand on its own instead of repeating "public client".
- Remove the oauth2_callback_url struct tag. It ran the shape check first and failed with a generic tag message.
- The handler already runs the same check and names the reason against callback_url.
- Test that a callback with a fragment reports that reason.
@BobbyHo

BobbyHo commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 3 is blocked before the panel. The author addressed five of the round-2 findings, verified by the churn guard: CRF-17 (DCR shape validation unified in 6f7112a), CRF-19 and CRF-21 (a4c5940), CRF-20 (mitigation doc reworded in 05348bf), and CRF-22 (struct tag removed so the callback reason is reported, c995ef8). Good, targeted fixes.

But three findings from the round-2 review are still open with no reply and no code change, so the panel will not re-review this round. All three were auto-folded into the round-2 review body (their lines were not on that round's diff), which is the likely reason they were missed while every inline thread was resolved. They are in the round-2 review body above; please scroll to the end of it.

  • CRF-16 (P3) coderd/oauth2provider/registration.go:306. The CRF-4 fix (validate only what the request introduces, skip stored entries, cap only on growth) was applied to the admin writer only. The RFC 7592 / DCR update path still runs the caps over the client's full resent list with no stored context, so a legacy over-cap DCR app is locked out of its own config updates. Verified again this round: registration.go is unchanged and UpdateClientConfiguration still gates on req.Validate() -> ValidateRedirectURIs with no stored argument. Same lockout class as CRF-4, on the writer the fix missed. Needed: apply the same stored-aware relaxation to the RFC 7592 update path (scope to update; create should still enforce the caps), or route both writers through one (candidate, stored) validator. If you intend to accept this gap instead, say so and why.

  • CRF-18 (Nit) codersdk/oauth2_validation.go:87. The ValidateRedirectURIScheme doc comment is still duplicated verbatim (the same seven lines appear twice). Pre-existing, but this PR rewrites the file. Delete the second copy, or reply that it is out of scope.

  • CRF-23 (Note) coderd/oauth2provider/registration.go:255. The RFC 7592 responses still echo raw app.RedirectUris (also lines 192, 412) rather than the single read owner RegisteredRedirectURIs(). Benign today; a one-line reply acknowledging it is enough to clear it.

Separately, CRF-5 (P3, rolling-upgrade skew) was re-resolved without a response to the reopened thread. As stated there, the documented mitigation is the right engineering answer and no in-PR code change can close the window, but accepting a silent, non-self-healing drop as permanent is a human decision. It needs an explicit human accept-the-risk or a linked PLAT-619 tracking item, not silent re-resolution.

Once you push fixes or respond to CRF-16, CRF-18, CRF-23, and CRF-5, the full panel will re-review.

🤖 This review was automatically generated with Coder Agents.

…pdate itself

- The RFC 7592 update path validated the full resent list with no stored context, so a legacy over-cap client could not save any change.
- It now skips redirect URIs the client already has and applies the count cap only when the list grew, matching the admin path.
- Create still enforces the caps on every entry.
- Remove the duplicated ValidateRedirectURIScheme doc comment.
@BobbyHo

BobbyHo commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Responses to the round-2 review-body items:

CRF-16: fixed in 1e38088. The RFC 7592 update handler now validates against the redirect URIs the client already has, skipping stored entries and applying the count cap only when the list grew. This matches the admin path. Create is unchanged and still enforces the caps on every entry. Added tests at the codersdk level and at the handler level with a seeded over-cap client.

CRF-18: removed the duplicated doc comment in the same commit.

CRF-23: acknowledged. The RFC 7592 responses return the stored list directly. Every dynamically registered client has a non-empty list, so this matches what RegisteredRedirectURIs would return today. Leaving as is for this PR.

@BobbyHo

BobbyHo commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 4 clears the block. The author responded to all four outstanding round-2/3 items: CRF-16 fixed in code (RFC 7592 update now uses a stored-aware validator), CRF-18 removed, CRF-23 acknowledged, and CRF-5 given an explicit human accept-the-risk. Both accepts are recorded and closed. The panel verified the four target fixes (CRF-16, CRF-17, CRF-22, CRF-18) at the source: the CRF-16 stored-skip opens no cap bypass because stored is server-derived from the existing row, create still enforces the caps on every entry, and the two writers share the grow-only rule. Bisky: "this one actually sparkles."

But round 3's panel was blocked, so this is the first panel pass over the round-3/4 validation rework, and that rework introduced or exposed four P3s, none blocking (no P0/P1):

  • CRF-25: the CRF-16 fix compares the client's raw resent list against a deduplicated stored baseline. A legacy DCR app with duplicate redirect URIs (pre-cap DCR stored them un-deduped, and the migration only removes callback duplicates) gets its unchanged, GET-echoed list rejected on PUT because raw count > unique count. Hisoka traced it and I confirmed the arithmetic in code: it re-locks the exact PLAT-619 class the fix set out to remove, for that subset. The admin path does not have this hole because it compares deduped against deduped.
  • CRF-24: the admin confidential path still accepts http:// to non-loopback hosts that the DCR path rejects, so the PR's "admin and registration enforce the same rules" claim is overstated. Razor rates it P3 (plaintext auth-code transport), Knov and Ryosuke read it as intentional admin-trust looseness. It is admin-gated and pre-existing, so it needs a human call: enforce ValidateRedirectURI for confidential admin entries, or document the deliberate split with its rationale.
  • CRF-26 and CRF-29 are the CRF-17/CRF-22 unification's loose ends: a doc invariant that the CRF-16 stored-skip made false again, and scheme error messages that now stutter ("callback URL redirect URI must have a scheme").

Severity count: 4 P3, 2 Notes, 1 Nit, all new. The code is close; these are refinements to the validation rework, not the core design, which the panel continues to find sound.

🤖 This review was automatically generated with Coder Agents.

Comment thread codersdk/oauth2_validation.go Resolved
Comment thread coderd/oauth2provider/apps.go Resolved
Comment thread codersdk/oauth2_validation.go Resolved
Comment thread codersdk/oauth2_validation.go Resolved
Comment thread codersdk/oauth2_validation.go Resolved
Comment thread codersdk/oauth2_validation.go Resolved
Comment thread codersdk/oauth2_validation.go Resolved
- Legacy clients may store duplicates, and the stored baseline is deduplicated.
- Resending the list as returned no longer reads as growth.
- Stored redirect URIs are checked again on every update, with no exception for apps that predate the caps.
- An app over the limits must be deleted and created or registered again.
- Remove the duplicated ValidateRedirectURIScheme doc comment again.
@BobbyHo

BobbyHo commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Response to CRF-16. Decision: the stored-skip logic is removed. Commits 6ff2f47, bb15f69 and 6e118d8 revert it, and a2918ae documents the recovery path. The caps stay.

Reasoning:

  • In practice it is very unlikely that a dynamically registered app holds more than 32 redirect URIs or one longer than 2048 bytes. Admin-created apps always had exactly one callback, and the DCR clients we see register one to three.
  • The Coder OAuth2.1 provider is still behind an experimental flag before release 2.38. Adding more logic to handle an edge case that most likely does not exist in the field is not worth the complexity.
  • An admin already has a way out. The app can be deleted and created or registered again, which works today regardless of the stored list. After PR 2 adds redirect_uris to the admin API, an admin can also trim the list directly.

The docs Limitations section and the validator comments now say this.

…hority

- Registration accepted the bare scheme:value form before this change.
- Add test cases for the three private-use forms.
- Rename ValidateOAuth2RedirectURIShape to ValidateRedirectURIShape to match its siblings.
- Scheme errors no longer start with "redirect URI", since every caller adds its own subject.
@BobbyHo
BobbyHo marked this pull request as ready for review September 17, 2026 20:00

@dylanhuff-at-coder dylanhuff-at-coder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments for docs and regression tests. There is now a duplicate 000598 migration which needs to be changed before merging, but otherwise lgtm.

The PR description still says stored URIs are skipped during validation and lists the removed 33-URI rename-success test. That no longer matches the implementation. Please update both to reflect that the full resolved list is validated, including on a rename.

Comment thread coderd/oauth2provider/apps.go Resolved
BobbyHo and others added 5 commits September 22, 2026 09:01
Main merged 000598_mcp_server_signing_secret, so the redirect_uris
migration collided on the same version number.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Saving the app again on the new version does not restore the edit, since
the form shows the old callback from redirect_uris. The admin must enter
the intended value again once every replica runs the new version.
…ect URIs

Replace the later-release promise with the current behavior: editing the
callback replaces the primary and preserves the other registered URIs,
and only the primary is displayed.
…t URIs

Cover an update that keeps the callback but retains a stored list of 33
URIs or a 2049-byte alternate. Both must fail with a redirect_uris error
and leave the row unchanged.
@BobbyHo
BobbyHo merged commit b9e3de8 into main Sep 22, 2026
30 of 31 checks passed
@BobbyHo
BobbyHo deleted the plat-619-1-redirect-uris-source-of-truth branch September 22, 2026 17:49
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants