-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Use case:
We have a system A use OAuth2Login to implement user login(Code flow). And another system B works as OAuth2 provider.
Step 1: A supervisor login system A. Everything works well.
Step 2: Supervisor close browser without logout. System A session is still available.
Step 3: A non-privilege user login system B to do something, Everything works well. Session of system B is reset to non-privilege user.
Step 4: The non-privilege user login system A from login page, but found that the login user is actually supervisor. (Reuse the previous supervisor session)
Expected: At step 4, since non-privilege user start a new login process from login page, we expected non-privilege user login finally.
After debug, we found that at step 4, the login process of system A have got the oauth2 code (Code flow) and redirected to the redirect url, but the redirect url is not processed correctly and skipped since the following code.
Lines 851 to 855 in b1195e7
PathPatternParserServerWebExchangeMatcher loginPathMatcher = new PathPatternParserServerWebExchangeMatcher("/login/oauth2/code/{registrationId}"); | |
ServerWebExchangeMatcher notAuthenticatedMatcher = e -> ReactiveSecurityContextHolder.getContext() | |
.flatMap(p -> ServerWebExchangeMatcher.MatchResult.notMatch()) | |
.switchIfEmpty(ServerWebExchangeMatcher.MatchResult.match()); | |
return new AndServerWebExchangeMatcher(loginPathMatcher, notAuthenticatedMatcher); |
Since the existence of the previous session, the process of redirect url is skipped. And the previous session is reused incorrectly.
AFAIK the process of redirect url is used to validate oauth2 code and retrieve user/token info and cannot be skipped. So it looks a security issue.
And since the process of redirect url is skipped, the saved authentication request cannot be removed from (in memory) session and potential run out server memory.