doorkeeper: Token Introspection failed with a protected resource's credential
RFC7622 OAuth 2.0 Token Introspection says,
To prevent token scanning attacks, the endpoint MUST also require
some form of authorization to access this endpoint, such as client
authentication as described in OAuth 2.0 [RFC6749] or a separate
OAuth 2.0 access token such as the bearer token described in OAuth
2.0 Bearer Token Usage [RFC6750].
...
In this example, the protected resource uses a client identifier and
client secret to authenticate itself to the introspection endpoint.
So Token Introspection Endpoint should require a protected resource’s credential. But doorkeeper’s implementation requires a credential of the client the access token was issued to. https://github.com/doorkeeper-gem/doorkeeper/blob/a729e80248031c1030c4dc0f89474932fe0d6603/lib/doorkeeper/oauth/token_introspection.rb#L104-L109
Steps to reproduce
Send a request to Token Introspection Endpoint with a protected resource’s client_id/client_secret.
Expected behavior
Token Introspection Endpoint returns a success response.
Actual behavior
Token Introspection Endpoint returns a failure response.
{ active: false }
System configuration
Doorkeeper initializer: no customize
Ruby version:
2.5.3
Gemfile.lock:
doorkeeper (5.0.2)
railties (>= 4.2)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 15 (8 by maintainers)
Commits related to this issue
- #1204: check token used as auth for introspection — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- Fix #1204: check token used as auth for introspection — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- Fix #1204: check token used as auth for introspection — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- Fix #1204: check token used as auth for introspection Validate tokens in Token Introspection. Don't allow to introspect token using the same token for authorization. — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- Fix #1204: check token used as auth for introspection Validate tokens in Token Introspection. Don't allow to introspect token using the same token for authorization. — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- #1204: Improve token introspection configuration — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- Merge pull request #1260 from doorkeeper-gem/improve_token_introspection_customization #1204: Improve token introspection configuration — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- #1204: Improve token introspection configuration — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
- Merge pull request #1262 from doorkeeper-gem/allow_to_check_authorized_token_in_introspection #1204: Improve token introspection configuration — committed to doorkeeper-gem/doorkeeper by nbulaj 5 years ago
I mean if clients want to introspect
token-a, they need to specify another token (e.g.,token-b) in the Authorizaiton header.So, this is NG.
This is OK
Yes, it solves my problem. Thanks!
That is what separate mean in the RFC 7662 Section 2.1. If you want to use bearer tokens for token introspection API access control, you need an access token separated from the introspected token.
ref.) https://tools.ietf.org/html/rfc7662#section-2.1
OK @kurodashota-mf , I remember from where it:
https://www.oauth.com/oauth2-servers/token-introspection-endpoint/
see Error Response section. Need to investigate more to fix the issue.
So Doorkeeper checks if client credentials used to authenticate is the same as for client that token was issued for. I agree with nov that the second check (if no credentials that just check the token to be valid) is cucumbersome and need to be fixed.
Could you please propose a gist RSpec example that fails with current behavior?
As @kurodashota-mf says, Token Introspection (RFC 7662) is designed for Resource Servers (RS), not for Clients.
This spec enables RS calls Token Introspection API, so that it can detect which client is accessing to its resource with which scopes. It also imply RS has its own client credentials issued from AS.
This spec doesn’t prohibit Clients use the API, so that client can use the API to mitigate token replace attack. However, it’s not original purpose of the RFC. It’s just a side effect.
So, Token Introspection API should accept client credentials not only of OAuth Clients, but of Resource Servers.
ref.) https://tools.ietf.org/html/rfc7662#section-1
Plus, current doorkeeper seems accept whether
First one reject any other clients other than the client to which the token is issued, but the second accept any clients who have valid access tokens. It looks weird. If the introspected token is valid, anyone can specify it in bearer header too. Then the call success. I don’t get the design concept…
In general, the API would accept whether
ref.) https://tools.ietf.org/html/rfc7662#section-4
Hi @nbulaj. Thank you for your quick response.
There may be a little misunderstanding. I don’t want to the second solution.
Doorkeeper returns failure response in case
The token was issued to a different client than is making this request. But I think it’s wrong.From my understanding, in Token Introspection Endpoint, client_id and client_secret are not for authenticating a client an access_token issued to, but for authenticating a protected resource.
Hi @kurodashota-mf . Thanks for reporting this issue!
Let’s look:
So Doorkeeper can implement either first or second type of authorization (not both), right?
Btw, I agree that we can implement the second solution from the spec. Would you like to submit a PR?