Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: ignore unrecognized parameters at the token endpoint - #29139

Merged
BobbyHo merged 7 commits into
mainfrom
plat-577-token-ignore-unrecognized-params
Sep 9, 2026
Merged

fix: ignore unrecognized parameters at the token endpoint#29139
BobbyHo merged 7 commits into
mainfrom
plat-577-token-ignore-unrecognized-params

Conversation

@BobbyHo

@BobbyHo BobbyHo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

TL;DR

The token endpoint rejected any form parameter it did not recognize. OAuth 2.1 §3.2 says it must ignore them. #28736 fixed this for /oauth2/authorize but left /oauth2/tokens alone, so a client sending nonce or client_assertion to both was accepted at one and refused at the other.

  • Removes the excess-parameter check from the token parser and logs the ignored names at debug, the same way the authorize endpoint does. Names only, since some of these parameters are credentials.
  • Repeated known parameters are still rejected. A test now pins that for all nine parameters the endpoint reads.
  • Both endpoint tests share one set of unrecognized parameters, so the same request is checked at both.
  • Trade-off: a misspelled optional parameter such as redirect_url is now silently ignored instead of getting a 400. The debug log is where it shows up.

No new endpoints, no schema change. Nothing outside coderd/oauth2provider changes.

Refs #28736
Closes https://linear.app/codercom/issue/PLAT-577

🤖 Generated with Claude Code

…en endpoint

OAuth 2.1 §3.2 says the token endpoint must ignore parameters it does not
recognize. Ours rejected them with a 400, so a client sending nonce or
client_assertion failed here while the same request passed at /oauth2/authorize.

Remove the excess-parameter check and log the ignored names at debug, as the
authorize endpoint already does. Values are not logged because some of these
parameters are credentials. Repeated known parameters are still rejected.

One trade-off: a misspelled optional parameter like redirect_url is now
silently ignored instead of returning a named 400. The debug log covers that.
@linear-code

linear-code Bot commented Sep 9, 2026

Copy link
Copy Markdown

PLAT-577

@BobbyHo

BobbyHo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Chat: Review in progress (15/15 reviewers complete) | View chat
Requested: 2026-09-09 16:19 UTC by @BobbyHo

deep-review v0.9.0 | Round 1 | 4166faf..3ebc121

Last posted: Round 1, 4 findings (1 Nit, 3 Note), COMMENT. Review

Finding inventory

Finding inventory - PR #29139

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 Nit Open authorize_test.go:937 addUnrecognizedParams comment overclaims log-formatter protection no test asserts R1 Bisky, Zoro Yes
CRF-2 Nit Raised in review body (process note) commit 3ebc121 subject Commit/PR subject is 80 cols, past 72-char git convention R1 Leorio No
CRF-3 Note Open tokens.go:193 Silent-ignore of misspelled optional params is bounded; no security downgrade R1 Mafuuu, Pariston, Chopper, Razor, Kurapika Yes
CRF-4 Note Open tokens.go:261 Repeated known param returns generic "missing required" message, names wrong problem R1 Leorio Yes
CRF-5 Note Open tokens.go:196 Logged ignored-params slice is attacker-controlled, unbounded element count (debug-only) R1 Kurapika Yes

Contested and acknowledged

None.

Round log

Round 1

Netero clean (no findings). Panel of 14: bisky, hisoka, mafu-san, mafuuu, pariston, kurapika, chopper, ging-go, gon, leorio, kite, komugi + wildcards zoro, razor. No P0-P4. Two convergent Nits (comment overclaim, commit subject length) and three Notes recording bounded tradeoffs. Mafuuu raised a resource-typo audience-downgrade concern; orchestrator verified against tokens.go:441-452 (RFC 8707 binding enforced) and Pariston's trace: the downgrade does not materialize when the code was bound. Reviewed against 4166faf..3ebc121.

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.

Clean, tightly scoped fix: the token endpoint stops rejecting unrecognized form parameters and reuses the existing ignoredParams helper so /oauth2/tokens now matches /oauth2/authorize (RFC 6749 §3.2, OAuth 2.1 §3.2). 95% of the diff is tests, and they are honest tests. TestOAuth2TokenUnrecognizedParametersIgnored redeems the issued token against /users/me instead of settling for the absence of a 400, so a handler that silently dropped the whole request would fail. TestOAuth2TokenRepeatedParameterRejected pins all nine read parameters and documents that the observed error codes diverge from RFC 6749 §5.2 so a later dispatch fix surfaces as a test diff. The debug log carries parameter names only, and the log test asserts the credential values never reach the sink.

Severity count: 0 P0-P4, 2 Nits, 3 Notes. Nothing blocks merge.

The panel tried hard to find a real defect and could not. Pariston: "I tried to build a case that the wrong thing is being fixed and could not." The one concern with a security dimension, a misspelled resource dropping the RFC 8707 audience binding (Mafuuu), does not materialize: authorizationCodeGrant (tokens.go:441-452) fails the exchange with invalid_target when the code was bound to a resource and the token request omits it, so no broadened-audience token is issued. The silent-ignore tradeoff is confined to genuinely optional, non-security parameters and is disclosed in the PR body.

Process note (Nit, CRF-2): the commit and PR subject fix(coderd/oauth2provider): ignore unrecognized parameters at the token endpoint is 80 columns, past the 72-char git convention, so it truncates in git log --oneline. The required scope path eats 27 columns, so the body is fine; only the whole line overruns. Not CI-enforced. A tighter description such as ignore unknown params at the token endpoint (70) fixes it. The commit body is excellent, do not touch it.


coderd/oauth2provider/tokens.go:261

Note [CRF-4] A client that duplicates a known parameter gets "missing required parameters or is otherwise malformed," which names the wrong problem (Leorio).

This PR makes repeat-rejection a tested, guaranteed behavior (TestOAuth2TokenRepeatedParameterRejected), so the message a client sees on a repeat is now in scope. Send resource twice and you get invalid_request with "The request is missing required parameters or is otherwise malformed": nothing is missing, and the developer burns time auditing required fields before guessing it was the duplicate. The parser already knows the field (parseSingle writes "provided more than once" to p.Errors[i].Detail); the handler discards it at the generic branch. Pre-existing dispatch code and out of this PR's scope, so not a finding, but cheap to fix if anyone touches this branch: surface the field name.

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/oauth2provider/authorize_test.go Outdated
Comment thread coderd/oauth2provider/tokens.go
Comment thread coderd/oauth2provider/tokens.go
@BobbyHo
BobbyHo marked this pull request as ready for review September 9, 2026 16:57
@coderagents

coderagents Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

This PR changes user-facing behavior of the public POST /oauth2/tokens endpoint: parameters it does not recognize (for example an OIDC nonce, client_assertion, or a misspelled redirect_url) are now ignored per RFC 6749 / OAuth 2.1 §3.2 instead of returning 400 invalid_request, while a repeated known parameter is still rejected.

Updates Needed

  • docs/admin/integrations/oauth2-provider.md - Addressed in c740211. A new "invalid_request from POST /oauth2/tokens for a repeated parameter" section documents that the token endpoint ignores unrecognized parameters (RFC 6749 §3.2), covers the misspelled-parameter case, states that a repeated known parameter still returns 400 (including the grant_typeunsupported_grant_type nuance), and includes a migration note for integrations that relied on the old error. Verified against the diff; matches the code behavior.

Automated review via Coder Agents

@github-actions

github-actions Bot commented Sep 9, 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.

@BobbyHo BobbyHo changed the title fix(coderd/oauth2provider): ignore unrecognized parameters at the token endpoint fix: ignore unrecognized parameters at the token endpoint Sep 9, 2026
Comment thread docs/admin/integrations/oauth2-provider.md Outdated

@dylanhuff-at-coder dylanhuff-at-coder 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.

overall lgtm, one non-blocking docs comment

BobbyHo and others added 3 commits September 9, 2026 11:02
… token parameters

A repeated redirect_uri, refresh_token, resource, or scope falls through
to the generic invalid_request message, which does not name the field.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…-unrecognized-params

# Conflicts:
#	coderd/oauth2provider/tokens.go
#	coderd/oauth2provider/tokens_internal_test.go
@BobbyHo
BobbyHo merged commit 1818844 into main Sep 9, 2026
31 checks passed
@BobbyHo
BobbyHo deleted the plat-577-token-ignore-unrecognized-params branch September 9, 2026 18:43
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 9, 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