Skip to content

Use constant-time comparison for HMAC signature verification#3997

Closed
duanemay wants to merge 1 commit into
developfrom
worktree-uaa-mac-signer-constant-time
Closed

Use constant-time comparison for HMAC signature verification#3997
duanemay wants to merge 1 commit into
developfrom
worktree-uaa-mac-signer-constant-time

Conversation

@duanemay

Copy link
Copy Markdown
Member

Summary

  • UaaMacSigner.verify compared the recomputed HMAC signature to the token's signature via Base64URL.equals (backed by String.equals), which short-circuits on the first differing byte and can leak timing information useful for forging a valid HMAC.
  • Switched to MessageDigest.isEqual on the decoded signature bytes, matching the constant-time comparison pattern already used elsewhere in the codebase (e.g. PasswordComparisonAuthenticator).

Test plan

  • ./gradlew :cloudfoundry-identity-server:compileJava
  • ./gradlew :cloudfoundry-identity-server:test --tests JwtHelperTest --tests CommonSignerTest --tests JwtTokenSignedByThisUAATest

UaaMacSigner.verify compared the token's signature to the recomputed
signature using String.equals via Base64URL, which short-circuits on
the first differing character and can leak timing information about
the expected HMAC value. Switch to MessageDigest.isEqual on the
decoded signature bytes.
@duanemay duanemay closed this Jul 24, 2026
@duanemay
duanemay deleted the worktree-uaa-mac-signer-constant-time branch July 24, 2026 21:43
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