$ the-wire · showcase
Spring Security Stops Thread Leaks
By RepoJournal · Filed · About Spring · Composed from the cited sources · methodology
Spring Security's SecurityContextHolderThreadLocalAccessor is sharing mutable state across threads, and a fix is already in motion.
Spring Security is fixing a cross-thread authentication leak [1]. The `SecurityContextHolderThreadLocalAccessor` propagates the same `SecurityContext` to other threads when Micrometer Context Propagation is used [1], which Tadaya Tsuyukubo warns "can cause authentication to leak between threads" [2]. The patch creates a fresh `SecurityContext` per target thread while reusing only the `Authentication` value [2]. Meanwhile, spring-tools landed a trio of SpEL navigation improvements [3] [4] [5], including go-to-definition across the type hierarchy and full annotation coverage. Dependabot churned out routine bumps for MockWebServer [6] and Jackson [7], and Josh Cummings merged 7.0.x into 7.1.x [8] [9]. The HQL and JPQL parser fix in spring-tools is a targeted bugfix [10] [11]. With 11 commits and 4 PRs across the repos, the thread-sharing fix is the one to watch.
Action items
- → Review SecurityContextHolderThreadLocalAccessor usage and test thread isolation in your Spring Security 7.x applications spring-projects/spring-security [immediate]
- → Watch for the merged fix in the next Spring Security release spring-projects/spring-security [plan]
- → Update to the latest spring-tools snapshot to get SpEL navigation fixes spring-projects/spring-tools [monitor]
References
- [1] SecurityContextHolderThreadLocalAccessor should not share SecurityContext instance across threads ↗ spring-projects/spring-security
- [2] Prevent sharing SecurityContext across threads spring-projects/spring-security ↗
- [3] GH-1370: go to definition in SpEL expressions finds methods in the type hierarchy ↗ spring-projects/spring-tools
- [4] GH-1371: cover all Spring annotations that carry SpEL expressions ↗ spring-projects/spring-tools
- [5] GH-1371: go to definition in SpEL expressions works for all annotations supporting SpEL ↗ spring-projects/spring-tools
- [6] Bump com.squareup.okhttp3:mockwebserver from 5.4.0 to 5.5.0 ↗ spring-projects/spring-ldap
- [7] Bump com.fasterxml.jackson:jackson-bom from 2.22.1 to 2.22.2 ↗ spring-projects/spring-security
- [8] Merge branch '7.1.x' ↗ spring-projects/spring-security
- [9] Merge branch '7.0.x' into 7.1.x ↗ spring-projects/spring-security
- [10] Make proper parsing call for HQL and JPQL parser ↗ spring-projects/spring-tools
- [11] Make proper parsing call for HQL and JPQL parser (#1969) ↗ spring-projects/spring-tools