Skip to content

WW-5855 Compare the transaction token in constant time - #2195

Open
sohankanna wants to merge 1 commit into
apache:mainfrom
sohankanna:WW-5855
Open

sohankanna wants to merge 1 commit into
apache:mainfrom
sohankanna:WW-5855

Conversation

@sohankanna

Copy link
Copy Markdown

Fixes WW-5855

TokenHelper.validToken compared the submitted token with token.equals(sessionToken), which returns as soon as a character differs. It now goes through a package-private tokensMatch(token, sessionToken) that compares the UTF-8 bytes with MessageDigest.isEqual, and treats a null session token as "no match" exactly as before. Behavior is otherwise unchanged: on a mismatch the session token stays, and on a match it is removed.

Testing

TokenHelperTest: new testTokensMatchComparesWholeValue (equal, a copy, last character differs, longer, shorter, empty) and testTokensMatchRejectsMissingSessionToken. TokenHelperTest: 13 run, 0 failures. Full mvn -pl core test: 3,876 run, 0 failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant