Skip to content

compare username token password and digest in constant time#3182

Merged
coheigea merged 1 commit into
apache:mainfrom
dxbjavid:usernametoken-constant-time-compare
Jun 4, 2026
Merged

compare username token password and digest in constant time#3182
coheigea merged 1 commit into
apache:mainfrom
dxbjavid:usernametoken-constant-time-compare

Conversation

@dxbjavid
Copy link
Copy Markdown
Contributor

@dxbjavid dxbjavid commented Jun 4, 2026

reading through STSStaxTokenValidator i noticed the local UsernameToken path checks the client-supplied password and password digest with String.equals, which bails out at the first mismatching character. that timing difference looks like enough to recover the expected digest (for a chosen nonce/created) or the plaintext password byte by byte and then authenticate. routed both comparisons through MessageDigest.isEqual over utf-8 bytes, which is the constant-time idiom already used elsewhere in cxf (OAuthUtils.compareTokens, HmacJwsSignatureVerifier). also made it null-safe so a missing password value just fails authentication instead of throwing.

@coheigea coheigea merged commit a4b17ea into apache:main Jun 4, 2026
5 checks passed
coheigea pushed a commit that referenced this pull request Jun 4, 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.

2 participants