CVE-2023-20862: Spring Framework Spring Security Logout Not Clearing Vulnerability

MODERATE
Advisory Identifier: GHSA-x873-6rgc-94jc
CVSS 6.3
CWE-459
Published
Advisory Summary

CVE-2023-20862 is a MODERATE (CVSS 6.3) spring security logout not clearing vulnerability (CWE-459: Incomplete Cleanup) affecting Spring Framework libraries in the Maven ecosystem. The issue involves spring security logout not clearing security context. Remediation is available by upgrading affected packages to version 5.7.8, 5.8.3, 6.0.3.

CVE-2023-20862 at a Glance

CVE Identifier CVE-2023-20862
GHSA Identifier GHSA-x873-6rgc-94jc
Severity MODERATE
CVSS v3.1 Base Score 6.3
CWE Classification CWE-459: Incomplete Cleanup
Affected Product Spring Framework
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 6.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2023-20862

To remediate this vulnerability, upgrade all affected Spring Framework dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.springframework.security:spring-security-core fixed: 5.7.8
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>5.7.8</version>
</dependency>
org.springframework.security:spring-security-core fixed: 5.8.3
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>5.8.3</version>
</dependency>
org.springframework.security:spring-security-core fixed: 6.0.3
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>6.0.3</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.springframework.security

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2023-20862, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.springframework.security

Analyze the terminal output to locate any version of Spring Framework in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.7.8), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.springframework.security command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-459: Incomplete Cleanup, where the product does not properly "clean up" and remove temporary or supporting resources after they have been used. In Spring Framework, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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. 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.

CVE-2023-20862 Affected Spring Framework Versions

3 component(s)
Fixed Versions:
5.7.85.8.36.0.3
Product / Package Ecosystem Affected Versions Fixed Version
org.springframework.security:spring-security-core
Maven
≥ 5.7.0
< 5.7.8
5.7.8
org.springframework.security:spring-security-core
Maven
≥ 5.8.0
< 5.8.3
5.8.3
org.springframework.security:spring-security-core
Maven
≥ 6.0.0
< 6.0.3
6.0.3

References

Frequently Asked Questions

What is CVE-2023-20862?
CVE-2023-20862 is a security vulnerability in Spring Framework involving Spring Security logout not clearing security context under CWE-459: Incomplete Cleanup.
Which Spring Framework versions are affected?
Affected versions include releases prior to 5.7.8, 5.8.3, 6.0.3 across affected packages: org.springframework.security:spring-security-core.
What version fixes CVE-2023-20862?
Upgrading to 5.7.8, 5.8.3, 6.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is spring-security-core affected?
Yes, org.springframework.security:spring-security-core is affected in releases prior to 5.7.8, 5.8.3, 6.0.3. Upgrade your dependency to 5.7.8, 5.8.3, 6.0.3 or later.
What is the CVSS score of CVE-2023-20862?
CVE-2023-20862 has a CVSS v3.1 base score of 6.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2023-20862?
CVE-2023-20862 is classified under CWE-459: Incomplete Cleanup (The product does not properly "clean up" and remove temporary or supporting resources after they have been used.).
How can I check Maven dependencies for CVE-2023-20862?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.springframework.security'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-x873-6rgc-94jc",
  "modified" : "2023-08-23T22:15:24Z",
  "published" : "2023-04-19T21:30:26Z",
  "aliases" : [ "CVE-2023-20862" ],
  "summary" : "Spring Security logout not clearing security context",
  "details" : "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. 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.security:spring-security-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.7.0"
      }, {
        "fixed" : "5.7.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.security:spring-security-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.8.0"
      }, {
        "fixed" : "5.8.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework.security:spring-security-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-20862"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/spring-projects/spring-security"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20230526-0002"
  }, {
    "type" : "WEB",
    "url" : "https://spring.io/security/cve-2023-20862"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-459" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-05T22:58:08Z",
    "nvd_published_at" : "2023-04-19T20:15:10Z"
  }
}