OAuth device authorization endpoint issues device codes to clients that did not register the device code grant type #2109
Labels
No labels
Abandoned
Blocked
Bug
Changelog
Added
Changelog
Missing
Changelog
None
Cherry-picking
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/E2EE
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Matrix/T&S
Merge
Merge/Manual
Merge/Squash
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
bob the builder
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity#2109
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
POST /_continuwuity/oauth2/deviceissues a device code to any registered client,without checking that the client registered
urn:ietf:params:oauth:grant-type:device_codein itsgrant_types.The token endpoint does enforce that check, so no access token can be obtained this
way. The practical effect is that a client which never registered the grant can still
start a device authorization flow, have the server display an approval prompt, get a
user to approve it, and only then fail at the token request.
Environment
mainat1b6bc83b9f70da341d062b6cdb7ced38bd497a93(read from source,not re-run against a build of
main).4c9426a13f7427d3318861f49aa36dfe7ee5055e(
feat: Add support for OAuth2 device auth flow).hybridcompatibility mode.Reproduction
Observed — step 2 returns
200 OKand a usable device code:Expected —
400 Bad Requestwith the error code RFC 6749 §5.2 assigns to thiscondition:
For completeness, the flow does dead-end at the token endpoint today — this step
already behaves correctly:
Specification
RFC 8628 §3.2 (Device Authorization Response):
RFC 6749 §5.2 defines the error code for exactly this condition:
and prescribes the status code:
grant_typesis the client metadata field registered through RFC 7591 dynamic clientregistration, which the server already stores and already honours at the token endpoint.
The Matrix Client-Server API lists the device authorisation grant among the OAuth 2.0
grant types it supports (spec v1.19), so this is the flow as Matrix specifies it, not an
unused corner of RFC 8628.
Impact
This is a conformance gap, not an authorization bypass.
Service::issue_tokenis theonly path to an access token, and it refuses the grant type before doing anything else,
so a device code obtained this way is inert.
What it does cost:
user code and approved access, instead of failing at the first request.
never going to serve. The user reasonably believes they granted something; nothing was
granted. A conformant server would never have shown the prompt.
request outright — so clients tested only against Continuwuity can ship a registration
that MAS rejects.
Related: error code at the token endpoint
The token endpoint reports the same condition as
invalid_grant. RFC 6749 §5.2 reservesinvalid_grantfor a grant that is "invalid, expired, revoked, does not match theredirection URI used in the authorization request, or was issued to another client", and
defines
unauthorized_clientfor a client "not authorized to use this authorizationgrant type". Happy to leave that alone if you would rather not change an existing error
code.