Improve signature validation#3998
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens signature/password comparison logic by switching to constant-time equality checks to reduce timing side-channel leakage during HMAC/JWT verification and LDAP password comparison.
Changes:
- Use
MessageDigest.isEqual(...)for constant-time comparisons in multiple authentication/signature validation paths. - Harden
signed_requestclaim extraction to reject missing/unknown signing algorithms. - Decode and compare HMAC/JWT signatures as bytes rather than using
String.equals(...).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
server/src/main/java/org/cloudfoundry/identity/uaa/provider/oauth/ExternalOAuthAuthenticationManager.java |
Tightens signed_request algorithm enforcement and uses constant-time signature comparison (but introduces a Java compilation issue). |
server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/PasswordComparisonAuthenticator.java |
Replaces Arrays.equals with constant-time comparison for local LDAP password byte checks (leaves an unused import). |
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/jwt/UaaMacSigner.java |
Uses constant-time comparison for legacy HMAC JWT verification and introduces an opportunity to check supported algorithms before signing (also contains a typo in an exception message). |
Comment on lines
+662
to
+666
| if (!"HMAC-SHA256".equals(algorithm)) { | ||
| log.debug("Missing or unknown algorithm was used to sign request! No claims returned."); | ||
| return null; | ||
| } | ||
| //check if data is signed correctly | ||
| if (!hmacSignAndEncode(signedRequests[1], secret).equals(signature)) { | ||
| log.debug("Signature is not correct, possibly the data was tampered with! No claims returned."); | ||
| // check if data is signed correctly using constant-time comparison |
strehle
approved these changes
Jul 25, 2026
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.
No description provided.