CVE-2021-21234: Spring Framework Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-p4q6-qxjx-8jgp
CVSS 7.7
CWE-22
Published
Advisory Summary

CVE-2021-21234 is a HIGH (CVSS 7.7) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Spring Framework libraries in the Maven ecosystem. The issue involves directory traversal in spring-boot-actuator-logview. Remediation is available by upgrading affected packages to version 0.2.13.

CVE-2021-21234 at a Glance

CVE Identifier CVE-2021-21234
GHSA Identifier GHSA-p4q6-qxjx-8jgp
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Spring Framework
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 7.7

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:C/C:H/I:N/A:N).

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

How to Fix CVE-2021-21234

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.

eu.hinsch:spring-boot-actuator-logview fixed: 0.2.13
<dependency>
    <groupId>eu.hinsch</groupId>
    <artifactId>spring-boot-actuator-logview</artifactId>
    <version>0.2.13</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=eu.hinsch

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=eu.hinsch

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

Note: The mvn dependency:tree -Dincludes=eu.hinsch 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. 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

### Impact The nature of this library is to expose a log file directory via admin (spring boot actuator) HTTP endpoints. Both the filename to view and a base folder (relative to the logging folder root) can be specified via request parameters. While the filename parameter was checked to prevent directory traversal exploits (so that `filename=../somefile` would not work), the base folder parameter was not sufficiently checked, so that `filename=somefile&base=../` could access a file outside the logging base directory). ### Patches The vulnerability has been patched in release 0.2.13. Any users of 0.2.12 should be able to update without any issues as there are no other changes in that release. ### Workarounds There is no workaround to fix the vulnerability other than updating or removing the dependency. However, removing read access of the user the application is run with to any directory not required for running the application can limit the impact. Additionally, access to the logview endpoint can be limited by deploying the application behind a reverse proxy. ### For more information If you have any questions or comments about this advisory: * Open an issue in the [github repo](https://github.com/lukashinsch/spring-boot-actuator-logview)

CVE-2021-21234 Affected Spring Framework Versions

1 component(s)
Fixed Versions:
0.2.13
Product / Package Ecosystem Affected Versions Fixed Version
eu.hinsch:spring-boot-actuator-logview
Maven
< 0.2.13
0.2.13

References

Frequently Asked Questions

What is CVE-2021-21234?
CVE-2021-21234 is a security vulnerability in Spring Framework involving Directory Traversal in spring-boot-actuator-logview under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Spring Framework versions are affected?
Affected versions include releases prior to 0.2.13 across affected packages: eu.hinsch:spring-boot-actuator-logview.
What version fixes CVE-2021-21234?
Upgrading to 0.2.13 (or the latest patched release for your respective branch) resolves the vulnerability.
Is spring-boot-actuator-logview affected?
Yes, eu.hinsch:spring-boot-actuator-logview is affected in releases prior to 0.2.13. Upgrade your dependency to 0.2.13 or later.
What is the CVSS score of CVE-2021-21234?
CVE-2021-21234 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2021-21234?
CVE-2021-21234 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check Maven dependencies for CVE-2021-21234?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=eu.hinsch'. 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-p4q6-qxjx-8jgp",
  "modified" : "2021-01-07T22:28:53Z",
  "published" : "2021-01-05T17:29:40Z",
  "aliases" : [ "CVE-2021-21234" ],
  "summary" : "Directory Traversal in spring-boot-actuator-logview",
  "details" : "### Impact\nThe nature of this library is to expose a log file directory via admin (spring boot actuator) HTTP endpoints. Both the filename to view and a base folder (relative to the logging folder root) can be specified via request parameters. While the filename parameter was checked to prevent directory traversal exploits (so that `filename=../somefile` would not work), the base folder parameter was not sufficiently checked, so that `filename=somefile&base=../` could access a file outside the logging base directory).\n\n### Patches\nThe vulnerability has been patched in release 0.2.13. Any users of 0.2.12 should be able to update without any issues as there are no other changes in that release.\n\n### Workarounds\nThere is no workaround to fix the vulnerability other than updating or removing the dependency. However, removing read access of the user the application is run with to any directory not required for running the application can limit the impact. Additionally, access to the logview endpoint can be limited by deploying the application behind a reverse proxy.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in the [github repo](https://github.com/lukashinsch/spring-boot-actuator-logview)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "eu.hinsch:spring-boot-actuator-logview"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.2.13"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/lukashinsch/spring-boot-actuator-logview/security/advisories/GHSA-p4q6-qxjx-8jgp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21234"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lukashinsch/spring-boot-actuator-logview/commit/1c76e1ec3588c9f39e1a94bf27b5ff56eb8b17d6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lukashinsch/spring-boot-actuator-logview/commit/760acbb939a8d1f7d1a7dfcd51ca848eea04e772"
  }, {
    "type" : "WEB",
    "url" : "https://search.maven.org/artifact/eu.hinsch/spring-boot-actuator-logview"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-01-05T17:28:54Z",
    "nvd_published_at" : "2021-01-05T18:15:00Z"
  }
}