Skip to content

compare oauth2 secret tokens with constant-time MessageDigest.isEqual#3165

Merged
coheigea merged 1 commit into
apache:mainfrom
dxbjavid:oauth2-constant-time-token-compare
Jun 2, 2026
Merged

compare oauth2 secret tokens with constant-time MessageDigest.isEqual#3165
coheigea merged 1 commit into
apache:mainfrom
dxbjavid:oauth2-constant-time-token-compare

Conversation

@dxbjavid
Copy link
Copy Markdown
Contributor

@dxbjavid dxbjavid commented Jun 1, 2026

The registration access-token checks in DynamicRegistrationService, the session authenticity token in RedirectionBasedGrantService, and the state token in MemoryClientCodeStateManager all authenticate a request-supplied secret with String.equals, which returns on the first differing byte.
Route them through a new OAuthUtils.compareTokens that wraps MessageDigest.isEqual, the same constant-time idiom already used by compareCertificateThumbprints and the JOSE verifiers.

@coheigea coheigea merged commit 5e96ddb into apache:main Jun 2, 2026
5 of 8 checks passed
coheigea pushed a commit that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants