CVE-2023-20862: Empty SecurityContext Is Not Properly Saved Upon Logout

HIGH | APRIL 17, 2023 | CVE-2023-20862

Description

In Spring Security, versions 5.7.x prior to 5.7.8, versions 5.8.x prior to 5.8.3, and versions 6.0.x prior to 6.0.3, the logout support does not properly clean the security context if using serialized versions. Additionally, it is not possible to explicitly save an empty security context to the HttpSessionSecurityContextRepository. This vulnerability can keep users authenticated even after they performed logout.

Specifically, an application is vulnerable when any of the following is true:

  • You are using the SecurityContextHolderFilter or requireExplicitSave(true) and you are using Spring Security's logout support with serialized sessions (e.g. Spring Session) and invalidateHttpSession(false)
  • You are logging users out manually by saving an empty SecurityContext into the HttpSessionSecurityContextRepository
  • You have a custom SecurityContextRepository that does not rely on the HttpSession

An application is not vulnerable if any of the following is true:

  • You are still using the deprecated SecurityContextPersistenceFilter or requireExplicitSave(false)
  • You are using Spring Security's logout support with in-memory sessions.
  • You are not saving an empty SecurityContext into the HttpSessionSecurityContextRepository

Affected Spring Products and Versions

Spring Security:

  • 6.0.0 to 6.0.2
  • 5.8.0 to 5.8.2
  • 5.7.0 to 5.7.7

Mitigation

Users of affected versions should apply the following mitigation. 5.7.x users should upgrade to 5.7.8. 5.8.x users should upgrade to 5.8.3. 6.0.x users should upgrade to 6.0.3. No other steps are necessary. Releases that have fixed this issue include:

Spring Security:

  • 5.7.8
  • 5.8.3
  • 6.0.3

Credit

This issue was identified and responsibly reported by Daniel Furtlehner from Porsche Informatik.

References

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all