
=====================================================================

                                  CERT-Renater

                       Note d'Information No. 2023/VULN167

_____________________________________________________________________

DATE                : 20/04/2023

HARDWARE PLATFORM(S): /

OPERATING SYSTEM(S): Systems running Spring Security versions prior
                                  to 5.7.8, 5.8.3, 6.0.3.

=====================================================================
https://spring.io/security/cve-2023-20862/
_____________________________________________________________________

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

 
https://docs.spring.io/spring-security/reference/5.8/migration/servlet/session-management.html#_require_explicit_saving_of_securitycontextrepository
 
https://docs.spring.io/spring-security/reference/servlet/authentication/session-management.html#store-authentication-manually
 
https://docs.spring.io/spring-security/reference/5.8.3/servlet/authentication/session-management.html#properly-clearing-authentication


=========================================================
+ CERT-RENATER        |    tel : 01-53-94-20-44         +
+ 23/25 Rue Daviel    |    fax : 01-53-94-20-41         +
+ 75013 Paris         |   email:cert@support.renater.fr +
=========================================================

