Repository navigation
Ignore client-supplied scope on RFC 8628 device token requests - #1002
Merged
Merged
Conversation
The token endpoint pre-fills request.scopes from the untrusted scope parameter before the grant runs, which allowed a device-flow client to obtain a token for any scope within its own registration whenever validate_device_code did not populate request.scopes, bypassing the issue #944 consent-integrity guard. Clear scopes on the authorized path so the grant fails loudly unless the stored authorization populates them. Co-authored-by: JonathanHuot <[email protected]>
JonathanHuot
marked this pull request as ready for review
October 30, 2026 22:50
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TokenEndpoint.create_token_response) pre-fillsrequest.scopesfrom the untrustedscopeparameter for every grant. For the RFC 8628 device grant, this defeated the issue Add validate_device_authorization_code() to RequestValidator to give DeviceCodeGrant symmetry with Authorization Code Grant #944 consent-integrity guard: whenevervalidate_device_codedid not populaterequest.scopesfrom the stored authorization, the token was issued for the attacker-supplied scopes (validated only against the client's registration), instead of failing loudly.DeviceCodeGrant.validate_device_codenow neutralizes the parameter path for an authorized device code: it clearsrequest.scopesandrequest.scopebefore checking the stored authorization. If the validator did not populaterequest.scopes, the grant still fails withserver_error("validate_device_code must set request.scopes for an authorized device_code.") rather than minting a token for untrusted scopes.DeviceClient.prepare_request_bodydocs: RFC 8628 Section 3.4 token requests carry no scope parameter and oauthlib-based servers ignore it.Verification
python -m pytest tests/oauth2/rfc8628 -q— 40 passed (39 existing + 1 new regression test)python -m pytest tests/oauth2 -q— only the 7 pre-existing failures inrfc6749/test_parameters.py, identical on clean masterCloses #944