CVE-2024-36116: Reposilite backend Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-frvj-cfq4-3228
CVSS 8.8
CWE-22
Published
Advisory Summary

CVE-2024-36116 is a HIGH (CVSS 8.8) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Reposilite backend libraries in the Maven ecosystem. The issue involves path traversal in reposilite javadoc file expansion (arbitrary file creation/overwrite) (`ghsl-2024-073`). Remediation is available by upgrading affected packages to version 3.5.12.

CVE-2024-36116 at a Glance

CVE Identifier CVE-2024-36116
GHSA Identifier GHSA-frvj-cfq4-3228
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Reposilite backend
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 8.8

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

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 High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-36116

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

com.reposilite:reposilite-backend fixed: 3.5.12
<dependency>
    <groupId>com.reposilite</groupId>
    <artifactId>reposilite-backend</artifactId>
    <version>3.5.12</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=com.reposilite

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=com.reposilite

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

Note: The mvn dependency:tree -Dincludes=com.reposilite 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 Reposilite backend, 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

### Summary Reposilite v3.5.10 is affected by an Arbitrary File Upload vulnerability via path traversal in expanding of Javadoc archives. ### Details Reposilite provides support for JavaDocs files, which are archives that contain documentation for artifacts. Specifically, [JavadocEndpoints.kt](https://github.com/dzikoysk/reposilite/blob/68b73f19dc9811ccf10936430cf17f7b0e622bd6/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/infrastructure/JavadocEndpoints.kt#L28) controller allows to expand the javadoc archive into the server's file system and return its content. The problem is in the way how the archives are expanded, specifically how the new filename is created: [JavadocContainerService.kt#L127-L136](https://github.com/dzikoysk/reposilite/blob/68b73f19dc9811ccf10936430cf17f7b0e622bd6/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocContainerService.kt#L127-L136) ```kotlin jarFile.entries().asSequence().forEach { file -> if (file.isDirectory) { return@forEach } val path = Paths.get(javadocUnpackPath.toString() + "/" + file.name) path.parent?.also { parent -> Files.createDirectories(parent) } jarFile.getInputStream(file).copyToAndClose(path.outputStream()) }.asSuccess<Unit, ErrorResponse>() ``` The `file.name` taken from the archive can contain path traversal characters, such as '/../../../anything.txt', so the resulting extraction path can be outside the target directory. ### Impact If the archive is taken from an untrusted source, such as Maven Central or JitPack for example, an attacker can craft a special archive to overwrite any local file on Reposilite instance. This could lead to remote code execution, for example by placing a new plugin into the '$workspace$/plugins' directory. Alternatively, an attacker can overwrite the content of any other package. Note that the attacker can use its own malicious package from Maven Central to overwrite any other package on Reposilite. ### Steps to reproduce 1. Create a malicious javadoc archive that contains filenames with path traversal characters: ```bash zip test-1.0-javadoc.jar ../../../../../../../../tmp/evil.txt index.html ``` Make sure that `../../../../../../../../tmp/evil.txt` and `index.html` files exist on the system where you create this archive. 2. Publish this archive to the repository which Reposilite is mirroring, such as Maven Central or JitPack. For the test purposes, I used my own server that imitates the upstream maven repository: http://artsploit.com/maven/com/artsploit/reposilite-zipslip/1.0/reposilite-zipslip-1.0-javadoc.jar 3. Start Reposilite with 'releases' repository mirroring to 'http://artsploit.com/maven/' 4. Now, if the attacker send the request to http://localhost:8080/javadoc/releases/com/artsploit/reposilite-zipslip/1.0, the aforementioned archive will be obtained from the http://artsploit.com/maven/com/artsploit/reposilite-zipslip/1.0/reposilite-zipslip-1.0-javadoc.jar address and its 'evil.txt' file will be expanded to '$workspace$/tmp/evil.txt'. Note that to perform this action, an attacker does not need to provide any credentials, as fetching from the mirrored repository does not require authentication. 6. Confirm that '$workspace$/tmp/evil.txt' is created on the server where Reposilite is running. ### Remediation Normalize (remove all occurrences of `/../`) the `file.name` variable before concatenating it with `javadocUnpackPath`. E.g.: ```kotlin val path = Paths.get(javadocUnpackPath.toString() + "/" + Paths.get(file.name).normalize().toString()) ```

CVE-2024-36116 Affected Reposilite backend Versions

1 component(s)
Fixed Versions:
3.5.12
Product / Package Ecosystem Affected Versions Fixed Version
com.reposilite:reposilite-backend
Maven
≥ 3.3.0
< 3.5.12
3.5.12

References

Frequently Asked Questions

What is CVE-2024-36116?
CVE-2024-36116 is a security vulnerability in Reposilite backend involving Path traversal in Reposilite javadoc file expansion (arbitrary file creation/overwrite) (`GHSL-2024-073`) under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Reposilite backend versions are affected?
Affected versions include releases prior to 3.5.12 across affected packages: com.reposilite:reposilite-backend.
What version fixes CVE-2024-36116?
Upgrading to 3.5.12 (or the latest patched release for your respective branch) resolves the vulnerability.
Is reposilite-backend affected?
Yes, com.reposilite:reposilite-backend is affected in releases prior to 3.5.12. Upgrade your dependency to 3.5.12 or later.
What is the CVSS score of CVE-2024-36116?
CVE-2024-36116 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2024-36116?
CVE-2024-36116 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-2024-36116?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.reposilite'. 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-frvj-cfq4-3228",
  "modified" : "2024-11-04T13:53:13Z",
  "published" : "2024-08-02T21:13:13Z",
  "aliases" : [ "CVE-2024-36116" ],
  "summary" : "Path traversal in Reposilite javadoc file expansion (arbitrary file creation/overwrite) (`GHSL-2024-073`)",
  "details" : "### Summary\nReposilite v3.5.10 is affected by an Arbitrary File Upload vulnerability via path traversal in expanding of Javadoc archives.\n\n### Details\nReposilite provides support for JavaDocs files, which are archives that contain documentation for artifacts. Specifically, [JavadocEndpoints.kt](https://github.com/dzikoysk/reposilite/blob/68b73f19dc9811ccf10936430cf17f7b0e622bd6/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/infrastructure/JavadocEndpoints.kt#L28) controller allows to expand the javadoc archive into the server's file system and return its content. The problem is in the way how the archives are expanded, specifically how the new filename is created:\n\n[JavadocContainerService.kt#L127-L136](https://github.com/dzikoysk/reposilite/blob/68b73f19dc9811ccf10936430cf17f7b0e622bd6/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocContainerService.kt#L127-L136)\n\n```kotlin\njarFile.entries().asSequence().forEach { file ->\n    if (file.isDirectory) {\n        return@forEach\n    }\n\n     val path = Paths.get(javadocUnpackPath.toString() + \"/\" + file.name)\n\n    path.parent?.also { parent -> Files.createDirectories(parent) }\n    jarFile.getInputStream(file).copyToAndClose(path.outputStream())\n}.asSuccess<Unit, ErrorResponse>()\n```\n\nThe `file.name` taken from the archive can contain path traversal characters, such as '/../../../anything.txt', so the resulting extraction path can be outside the target directory.\n\n### Impact\n\nIf the archive is taken from an untrusted source, such as Maven Central or JitPack for example, an attacker can craft a special archive to overwrite any local file on Reposilite instance. This could lead to remote code execution, for example by placing a new plugin into the '$workspace$/plugins' directory. Alternatively, an attacker can overwrite the content of any other package.\n\nNote that the attacker can use its own malicious package from Maven Central to overwrite any other package on Reposilite.\n\n### Steps to reproduce\n\n1. Create a malicious javadoc archive that contains filenames with path traversal characters:\n```bash\nzip test-1.0-javadoc.jar ../../../../../../../../tmp/evil.txt index.html\n```\nMake sure that `../../../../../../../../tmp/evil.txt` and `index.html` files exist on the system where you create this archive.\n\n2. Publish this archive to the repository which Reposilite is mirroring, such as Maven Central or JitPack. For the test purposes, I used my own server that imitates the upstream maven repository:\nhttp://artsploit.com/maven/com/artsploit/reposilite-zipslip/1.0/reposilite-zipslip-1.0-javadoc.jar\n\n3. Start Reposilite with 'releases' repository mirroring to 'http://artsploit.com/maven/'\n\n4. Now, if the attacker send the request to http://localhost:8080/javadoc/releases/com/artsploit/reposilite-zipslip/1.0, the aforementioned archive will be obtained from  the http://artsploit.com/maven/com/artsploit/reposilite-zipslip/1.0/reposilite-zipslip-1.0-javadoc.jar address and its 'evil.txt' file will be expanded to '$workspace$/tmp/evil.txt'. Note that to perform this action, an attacker does not need to provide any credentials, as fetching from the mirrored repository does not require authentication.\n\n6. Confirm that '$workspace$/tmp/evil.txt' is created on the server where Reposilite is running.\n\n### Remediation\n\nNormalize (remove all occurrences of `/../`) the `file.name` variable before concatenating it with `javadocUnpackPath`. E.g.:\n\n```kotlin\nval path = Paths.get(javadocUnpackPath.toString() + \"/\" + Paths.get(file.name).normalize().toString())\n```\n\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.reposilite:reposilite-backend"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.3.0"
      }, {
        "fixed" : "3.5.12"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dzikoysk/reposilite/security/advisories/GHSA-frvj-cfq4-3228"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dzikoysk/reposilite/commit/848173738e4375482c70365db5cebae29f125eaa"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dzikoysk/reposilite"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dzikoysk/reposilite/releases/tag/3.5.12"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-02T21:13:13Z",
    "nvd_published_at" : null
  }
}