grpc-spring-security-demo icon indicating copy to clipboard operation
grpc-spring-security-demo copied to clipboard

WARNING: Security bypass in multi threaded environments

Open ST-DDT opened this issue 6 years ago • 3 comments

According to SO each grpc callback can be triggered by a different thread, thus setting and clearing the security context only in the interceptor's startCall may lead to other threads picking up the security contexts. grpc avoided the issue for their contexts with this interceptor

I could observe rare / random security exceptions with an interceptor that works similar to the ones used in this repository. The likelihood of these exceptions increased by running more requests (both authenticated and non-authenticated) in parallel and running on slower/busier CPUs.

Is the SO overflow answer wrong or is this demo affected by this?

ST-DDT avatar Nov 11 '18 16:11 ST-DDT

Yes, this demo is indeed affected by this issue. It is something I have been intending to fix but unfortunately haven't had the time to fix.

alexleigh avatar Nov 12 '18 00:11 alexleigh

See https://github.com/yidongnan/grpc-spring-boot-starter/pull/126 for my attempt to fix the concurrency issue (for a different grpc-spring library though).

ST-DDT avatar Nov 12 '18 09:11 ST-DDT

See yidongnan/grpc-spring-boot-starter#126 for my attempt to fix the concurrency issue (for a different grpc-spring library though).

This concurrency issue is terrible, you can easily reproduce it by sending concurrent requests to the server. This means the demo shouldn't be used by anyone for any purposes.

@ST-DDT 's fix is live in net.devh:grpc-spring-boot-starter:2.2.0.RELEASE. Everyone should switch to that. THANK YOU!

alex-lzl avatar Dec 26 '18 07:12 alex-lzl