Require PKCE for public clients that register at /oauth/register

Open Beginner friendly
#55 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
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php

Research direction

Read modules/simple_oauth_client_registration/src/Service/ClientRegistrationService.php, especially lines 96 to 117, and check how registration sets the consumer's pkce field for clients using token_endpoint_auth_method: none. Verify that public client registration enables PKCE without requiring simple_oauth_pkce; done means the registered client requires a code challenge during authorization.

Written by the indexing model from the issue text.

Description

category::bug code priority::normal

Problem

ClientRegistrationService does not set the pkce field of the consumer (modules/simple_oauth_client_registration/src/Service/ClientRegistrationService.php, lines 96 to 117). The field is FALSE by default, and simple_oauth then does not require a code challenge for a public client.

simple_oauth_pkce is not a dependency of simple_oauth_client_registration. Without it, a client that registers with token_endpoint_auth_method: none completes the authorization code flow without a code challenge and without a code verifier. A party that intercepts the authorization code can redeem it with only the client identifier.

The README says "Mandatory PKCE" for all authorization code flows (README.md, line 15).

Expected Behavior

Registration sets pkce to TRUE for a public client, so that simple_oauth requires a code challenge. The result does not depend on simple_oauth_pkce.

Steps to Reproduce

  1. Install simple_oauth_client_registration without simple_oauth_pkce. Create a scope example:read for the authorization code grant.
  2. Send POST /oauth/register with the JSON body {"client_name": "Native app", "token_endpoint_auth_method": "none", "application_type": "native", "redirect_uris": ["com.example.app://callback"]}.
  3. A user with grant simple_oauth codes opens /oauth/authorize with response_type=code, the client_id, the redirect_uri and scope=example:read. The request has no code_challenge. The user presses "Allow".
  4. Send POST /oauth/token with grant_type=authorization_code, the client_id, the redirect_uri and the code. The request has no code_verifier. The response is 200 with an access token.

Additional Context

https://git.drupalcode.org/project/simple_oauth/-/work_items/3636064 asks for a safer default in simple_oauth. 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.