Skip to content

Conversation

@HyunSangHan
Copy link
Contributor

AuthenticationProcessInterceptor was setting authentication in the SecurityContext but not clearing it after a request completed, allowing authentication state to leak between requests on the same thread.

This could let anonymous requests inherit the authentication from previous authenticated requests, potentially bypassing security checks.

The fix wraps the call listener so that the SecurityContext is always cleared when a request completes, is cancelled, or fails with an error.

Fixes #245

Signed-off-by: Hyunsang Han <gustkd3@gmail.com>
@HyunSangHan HyunSangHan force-pushed the security-context-cleanup branch from b7d61f3 to 1e356a2 Compare August 15, 2025 16:55
@dsyer dsyer merged commit 5e0eec8 into spring-projects:main Aug 16, 2025
5 checks passed
@HyunSangHan
Copy link
Contributor Author

HyunSangHan commented Aug 16, 2025

@dsyer
Thank you for your feedback and the fast merge!
I missed adding my name to @author section.

  * @author Dave Syer
+ * @author Hyunsang Han

Can I submit this with PR? 😅

HyunSangHan added a commit to HyunSangHan/spring-grpc that referenced this pull request Aug 16, 2025
Signed-off-by: Hyunsang Han <gustkd3@gmail.com>
dsyer pushed a commit that referenced this pull request Aug 16, 2025
Signed-off-by: Hyunsang Han <gustkd3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anonymous can access gRPC method protected by PreAuthorize annotation

2 participants