Skip to content

Commit

Permalink
Catch IllegalArgumentException when decoding base64
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 committed Dec 31, 2024
1 parent 164291a commit f8eccec
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ private class CommonWebSocketCreator implements WebSocketCreator {
Matcher matcher = WEBSOCKET_ACCESS_TOKEN_PATTERN.matcher(secWebSocketProtocolHeader);
if (matcher.find() && matcher.group("base64") != null) {
String base64 = matcher.group("base64");
accessToken = new String(Base64.getDecoder().decode(base64));
try {
accessToken = new String(Base64.getDecoder().decode(base64));
} catch (IllegalArgumentException e) {
logger.warn("Invalid base64 encoded access token in Sec-WebSocket-Protocol header from {}.",
servletUpgradeRequest.getRemoteAddress());
return null;
}
} else {
logger.warn("Invalid use of Sec-WebSocket-Protocol header from {}.",
servletUpgradeRequest.getRemoteAddress());
Expand Down

0 comments on commit f8eccec

Please sign in to comment.