Fix the 500 response of /oauth/revoke for a valid token with a space

Open Beginner friendly
#54 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php

Research direction

Start with TokenLookupService::resolveToken() in modules/simple_oauth_server_metadata/src/Service/TokenLookupService.php and compare the value sent in the Authorization header with the value passed to the JWT parser. Check the exception handling in modules/simple_oauth_server_metadata/src/Controller/TokenRevocationController.php and look for existing revocation tests. Done when valid tokens with surrounding spaces return 200 and are either revoked or treated as unknown, without changing the response for invalid tokens.

Written by the indexing model from the issue text.

Description

category::bug code priority::minor

Problem

POST /oauth/revoke returns 500 with server_error when the token parameter is a valid access token with one space before or after it. The token stays active. An invalid value with a space gets 200.

TokenLookupService::resolveToken() puts the value in an Authorization header and gives it to the resource server. The resource server reads the value without the space and accepts it. The method then gives the original value to the JWT parser, and the parser throws an exception (modules/simple_oauth_server_metadata/src/Service/TokenLookupService.php, lines 72 to 83). TokenRevocationController changes each exception into a 500 (modules/simple_oauth_server_metadata/src/Controller/TokenRevocationController.php, lines 161 to 171).

Expected Behavior

The endpoint returns 200 for each token value. RFC 7009 section 2.2 gives that status also for an invalid token. The endpoint revokes a valid token with a space, or it treats the value as unknown.

Steps to Reproduce

  1. Get an access token for a confidential client.
  2. Send POST /oauth/revoke with the client credentials. Set the token parameter to the access token and one trailing space.
  3. The response is 500 with {"error": "server_error"}. Introspection still reports the access token as active.

Additional Context

/oauth/introspect returns active: false for the value with the space. Found on v2.1.1.

Dominant language
JavaScript
Stars
6
Forks
9
Avg merge
9h 41m
Merged PRs (30d)
15

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from e0ipso/simple_oauth_21

All issues in e0ipso/simple_oauth_21

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.