CVE-2021-22118: Spring Framework Improper Privilege Management Vulnerability

HIGH
Advisory Identifier: GHSA-gfwj-fwqj-fp3v
CVSS 7.8
CWE-668 CWE-269
Published
Advisory Summary

CVE-2021-22118 is a HIGH (CVSS 7.8) improper privilege management vulnerability (CWE-668: Exposure of Resource to Wrong Sphere) affecting Spring Framework libraries in the Maven ecosystem. The issue involves improper privilege management in spring framework. Remediation is available by upgrading affected packages to version 5.2.15, 5.3.7.

CVE-2021-22118 at a Glance

CVE Identifier CVE-2021-22118
GHSA Identifier GHSA-gfwj-fwqj-fp3v
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-668: Exposure of Resource to Wrong Sphere
Affected Product Spring Framework
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 7.8

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

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

How to Fix CVE-2021-22118

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:spring-web fixed: 5.2.15
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.2.15</version>
</dependency>
org.springframework:spring-web fixed: 5.3.7
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.3.7</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

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=org.springframework

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.2.15), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.springframework 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-668: Exposure of Resource to Wrong Sphere, where the product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource. 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 Framework, versions 5.2.x prior to 5.2.15 and versions 5.3.x prior to 5.3.7, a WebFlux application is vulnerable to a privilege escalation: by (re)creating the temporary storage directory, a locally authenticated malicious user can read or modify files that have been uploaded to the WebFlux application, or overwrite arbitrary files with multipart request data.

CVE-2021-22118 Affected Spring Framework Versions

2 component(s)
Fixed Versions:
5.2.155.3.7
Product / Package Ecosystem Affected Versions Fixed Version
org.springframework:spring-web
Maven
≥ 5.2.0
< 5.2.15
5.2.15
org.springframework:spring-web
Maven
≥ 5.3.0
< 5.3.7
5.3.7

References

Frequently Asked Questions

What is CVE-2021-22118?
CVE-2021-22118 is a security vulnerability in Spring Framework involving Improper Privilege Management in Spring Framework under CWE-668: Exposure of Resource to Wrong Sphere.
Which Spring Framework versions are affected?
Affected versions include releases prior to 5.2.15, 5.3.7 across affected packages: org.springframework:spring-web.
What version fixes CVE-2021-22118?
Upgrading to 5.2.15, 5.3.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is spring-web affected?
Yes, org.springframework:spring-web is affected in releases prior to 5.2.15, 5.3.7. Upgrade your dependency to 5.2.15, 5.3.7 or later.
What is the CVSS score of CVE-2021-22118?
CVE-2021-22118 has a CVSS v3.1 base score of 7.8 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-22118?
CVE-2021-22118 is classified under CWE-668: Exposure of Resource to Wrong Sphere (The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.).
How can I check Maven dependencies for CVE-2021-22118?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.springframework'. 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-gfwj-fwqj-fp3v",
  "modified" : "2023-07-19T14:39:30Z",
  "published" : "2022-05-24T19:03:28Z",
  "aliases" : [ "CVE-2021-22118" ],
  "summary" : "Improper Privilege Management in Spring Framework",
  "details" : "In Spring Framework, versions 5.2.x prior to 5.2.15 and versions 5.3.x prior to 5.3.7, a WebFlux application is vulnerable to a privilege escalation: by (re)creating the temporary storage directory, a locally authenticated malicious user can read or modify files that have been uploaded to the WebFlux application, or overwrite arbitrary files with multipart request data.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework:spring-web"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.2.0"
      }, {
        "fixed" : "5.2.15"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.2.14"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.springframework:spring-web"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.3.0"
      }, {
        "fixed" : "5.3.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.3.6"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-22118"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/spring-projects/spring-framework/issues/26931"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/spring-projects/spring-framework/commit/0d0d75e25322d8161002d861fff3ec04ba8be5ac"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/spring-projects/spring-framework/commit/cce60c479c22101f24b2b4abebb6d79440b120d1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/spring-projects/spring-framework"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210713-0005"
  }, {
    "type" : "WEB",
    "url" : "https://spring.io/security/cve-2021-22118"
  }, {
    "type" : "WEB",
    "url" : "https://tanzu.vmware.com/security/cve-2021-22118"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com//security-alerts/cpujul2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujan2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuoct2021.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-269", "CWE-668" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-22T18:24:11Z",
    "nvd_published_at" : "2021-05-27T15:15:00Z"
  }
}