Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ private boolean validateCallbackURI(String callbackURI, OAuthAppDO oauthApp) {
registeredCallbackUrl =
registeredCallbackUrl.replaceFirst(OAuthConstants.LOOPBACK_IP_PORT_REGEX, StringUtils.EMPTY);
}
return (regexp != null && callbackURI.matches(regexp)) || registeredCallbackUrl.equals(callbackURI);

if (regexp == null) {
return registeredCallbackUrl.equals(callbackURI);
}
/*
Escape dots only when followed by a letter/digit (so .com, .org, etc. get escaped),
but don't touch .* or .+ or .{n} .
*/
regexp = regexp.replaceAll("(?<!\\\\)\\.(?=[A-Za-z0-9])", "\\\\.");
Comment on lines +358 to +361
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern modification could introduce security vulnerabilities. Modifying user-provided regex patterns at runtime can lead to unexpected behavior or bypass security checks. Consider validating the original regex pattern instead of modifying it, or use a whitelist of allowed patterns.

Suggested change
Escape dots only when followed by a letter/digit (so .com, .org, etc. get escaped),
but don't touch .* or .+ or .{n} .
*/
regexp = regexp.replaceAll("(?<!\\\\)\\.(?=[A-Za-z0-9])", "\\\\.");
Do not modify user-provided regex patterns at runtime.
Use the registered regex as provided.
*/
// regexp = regexp.replaceAll("(?<!\\\\)\\.(?=[A-Za-z0-9])", "\\\\.");

Copilot uses AI. Check for mistakes.

Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex regex pattern with multiple escaped backslashes is difficult to read and maintain. Consider extracting this pattern to a named constant with clear documentation explaining its purpose and behavior.

Copilot uses AI. Check for mistakes.

return callbackURI.matches(regexp);
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The matches() method is vulnerable to ReDoS (Regular Expression Denial of Service) attacks with malicious regex patterns. Consider adding timeout limits or using a safer regex matching approach to prevent potential DoS attacks.

Copilot uses AI. Check for mistakes.

}
}