This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 8574198baa8 compare pkce code verifier and client secret hash in
constant time (#3170)
8574198baa8 is described below
commit 8574198baa814a84cb45ecbeaab7aede8978b774
Author: Javid Khan <[email protected]>
AuthorDate: Wed Jun 3 18:52:36 2026 +0530
compare pkce code verifier and client secret hash in constant time (#3170)
* compare pkce code verifier and client secret hash in constant time
* use OAuthUtils.compareTokens for the constant-time comparisons
---
.../rs/security/oauth2/grants/code/AuthorizationCodeGrantHandler.java | 2 +-
.../cxf/rs/security/oauth2/provider/ClientSecretHashVerifier.java | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git
a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/AuthorizationCodeGrantHandler.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/AuthorizationCodeGrantHandler.java
index 39e6c79cfb5..6331b732003 100644
---
a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/AuthorizationCodeGrantHandler.java
+++
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/grants/code/AuthorizationCodeGrantHandler.java
@@ -183,7 +183,7 @@ public class AuthorizationCodeGrantHandler extends
AbstractGrantHandler {
codeVerifierTransformer = defaultCodeVerifierTransformer;
}
String transformedCodeVerifier =
codeVerifierTransformer.transformCodeVerifier(clientCodeVerifier);
- return clientCodeChallenge.equals(transformedCodeVerifier);
+ return OAuthUtils.compareTokens(clientCodeChallenge,
transformedCodeVerifier);
}
}
diff --git
a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/ClientSecretHashVerifier.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/ClientSecretHashVerifier.java
index f37cbed6501..9c8cd76aeb0 100644
---
a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/ClientSecretHashVerifier.java
+++
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/ClientSecretHashVerifier.java
@@ -21,6 +21,7 @@ package org.apache.cxf.rs.security.oauth2.provider;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthUtils;
import org.apache.cxf.rt.security.crypto.MessageDigestUtils;
/**
@@ -31,7 +32,7 @@ public class ClientSecretHashVerifier implements
ClientSecretVerifier {
public boolean validateClientSecret(Client client, String clientSecret) {
String hash =
MessageDigestUtils.generate(StringUtils.toBytesUTF8(clientSecret),
hashAlgorithm);
- return hash.equals(client.getClientSecret());
+ return OAuthUtils.compareTokens(hash, client.getClientSecret());
}
public void setHashAlgorithm(String hashAlgorithm) {
this.hashAlgorithm = hashAlgorithm;