Repository navigation
Fix: Send the PKCE code verifier instead of the challenge in the OAuth2 token request - #167
Open
ready4god2513 wants to merge 3 commits into
Open
ready4god2513 wants to merge 3 commits into
ready4god2513 wants to merge 3 commits into
Conversation
…h2 token request The OAuth2 session sent the S256 code challenge as both the code_challenge in the authorization request and the code_verifier in the token request, so the secret verifier RFC 7636 relies on was never used. Generate a random verifier, derive the challenge from it as BASE64URL(SHA256(verifier)), and send the verifier with the token request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rafaeljusto
approved these changes
Nov 4, 2026
chrisrollins65
approved these changes
Nov 6, 2026
bakaat
reviewed
Nov 6, 2026
bakaat
left a comment
There was a problem hiding this comment.
rollins wanna run claude through it ? lgtm anyway
Contributor
Yeah I always run claude on PRs before I approve them now, so already done. |
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.

What
session.OAuth2sent the same value as both thecode_challengein the authorization request and thecode_verifierin the token request. It hashed random bytes into an S256 challenge, used that challenge for both, and discarded the random input. The secret verifier that PKCE (RFC 7636) depends on was never sent. Anyone who saw the authorization request had everything needed to redeem the code, and a server that checks PKCE correctly rejects the token request.Change
generatePKCEreturns a verifier and its challenge:BASE64URL(SHA256(verifier)), per §4.2code_challenge_method=S256, as before), and the verifier in the token request.Tests
New
session/oauth2_test.go:TestGeneratePKCE: the verifier matches the RFC 7636 character set and length; the challenge is the S256 transform of the verifier; the verifier differs from the challenge and between calls.TestRetrieveTokenSendsVerifier: the token request posts the verifier ascode_verifier, checked against a local test server.go test ./...,go vet ./...andgolangci-lint run ./...pass.🤖 Generated with Claude Code