Vulnerabilities in pkg:maven/org.scala-sbt/io_2.13

PACKAGE
Advisory Identifier: GHSA-h9mw-grgx-2fhf
Advisory Summary

CVE-2023-46122 is a LOW (CVSS 3.9) sbt vulnerable to arbitrary file vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Sbt libraries in the Maven ecosystem. The issue involves sbt vulnerable to arbitrary file write via archive extraction (zip slip). Remediation is available by upgrading affected packages to version 1.9.7.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/org.scala-sbt/io_2.13

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/org.scala-sbt/io_2.13. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-h9mw-grgx-2fhf CVE-2023-46122 LOW sbt vulnerable to arbitrary file write via archive extraction (Zip Slip)

CVE-2023-46122 at a Glance

CVE Identifier CVE-2023-46122
GHSA Identifier GHSA-h9mw-grgx-2fhf
Severity LOW
CVSS v3.1 Base Score 3.9
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Sbt
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 3.9

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:R/S:U/C:N/I:L/A:L).

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

How to Fix CVE-2023-46122

To remediate this vulnerability, upgrade all affected Sbt 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.scala-sbt:sbt fixed: 1.9.7
<dependency>
    <groupId>org.scala-sbt</groupId>
    <artifactId>sbt</artifactId>
    <version>1.9.7</version>
</dependency>
org.scala-sbt:io_2.12 fixed: 1.9.7
<dependency>
    <groupId>org.scala-sbt</groupId>
    <artifactId>io_2.12</artifactId>
    <version>1.9.7</version>
</dependency>
org.scala-sbt:io_2.13 fixed: 1.9.7
<dependency>
    <groupId>org.scala-sbt</groupId>
    <artifactId>io_2.13</artifactId>
    <version>1.9.7</version>
</dependency>
org.scala-sbt:io_3 fixed: 1.9.7
<dependency>
    <groupId>org.scala-sbt</groupId>
    <artifactId>io_3</artifactId>
    <version>1.9.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.scala-sbt

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=org.scala-sbt

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

Note: The mvn dependency:tree -Dincludes=org.scala-sbt 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 Sbt, 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 Given specially crafted zip or JAR file, `IO.unzip` allows writing of arbitrary file. The follow is an example of a malicious entry: ``` +2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys ``` This would have a potential to overwrite `/root/.ssh/authorized_keys`. Within sbt's main code, `IO.unzip` is used in `pullRemoteCache` task and `Resolvers.remote`; however many projects use `IO.unzip(...)` directly to implement custom tasks - https://github.com/search?q=IO.unzip+language%3AScala&type=code&l=Scala&p=1 ### Patches The problem has been patched in https://github.com/sbt/io/pull/360 sbt 1.9.7 is available with the fix. ### Workarounds A workaround might be use some other library to unzip. ### References - https://github.com/snyk/zip-slip-vulnerability - https://security.snyk.io/vuln/SNYK-JAVA-ORGCODEHAUSPLEXUS-31680 - https://github.com/sbt/io/issues/358

CVE-2023-46122 Affected Sbt Versions

4 component(s)
Fixed Versions:
1.9.7
Product / Package Ecosystem Affected Versions Fixed Version
org.scala-sbt:sbt
Maven
≥ 0.3.4
< 1.9.7
1.9.7
org.scala-sbt:io_2.12
Maven
≥ 1.0.0
< 1.9.7
1.9.7
org.scala-sbt:io_2.13
Maven
≥ 1.0.0
< 1.9.7
1.9.7
org.scala-sbt:io_3
Maven
≥ 1.0.0
< 1.9.7
1.9.7

References

Frequently Asked Questions

What is CVE-2023-46122?
CVE-2023-46122 is a security vulnerability in Sbt involving sbt vulnerable to arbitrary file write via archive extraction (Zip Slip) under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Sbt versions are affected?
Affected versions include releases prior to 1.9.7 across affected packages: org.scala-sbt:sbt, org.scala-sbt:io_2.12, org.scala-sbt:io_2.13, org.scala-sbt:io_3.
What version fixes CVE-2023-46122?
Upgrading to 1.9.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sbt affected?
Yes, org.scala-sbt:sbt is affected in releases prior to 1.9.7. Upgrade your dependency to 1.9.7 or later.
Is io_2.12 affected?
Yes, org.scala-sbt:io_2.12 is affected in releases prior to 1.9.7. Upgrade your dependency to 1.9.7 or later.
What is the CVSS score of CVE-2023-46122?
CVE-2023-46122 has a CVSS v3.1 base score of 3.9 (LOW) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:L.
What CWE is associated with CVE-2023-46122?
CVE-2023-46122 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-2023-46122?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.scala-sbt'. 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-h9mw-grgx-2fhf",
  "modified" : "2023-11-01T05:51:17Z",
  "published" : "2023-10-24T01:51:04Z",
  "aliases" : [ "CVE-2023-46122" ],
  "summary" : "sbt vulnerable to arbitrary file write via archive extraction (Zip Slip)",
  "details" : "### Impact\n\nGiven specially crafted zip or JAR file, `IO.unzip` allows writing of arbitrary file. The follow is an example of a malicious entry:\n\n```\n+2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\n```\n\nThis would have a potential to overwrite `/root/.ssh/authorized_keys`. Within sbt's main code, `IO.unzip` is used in `pullRemoteCache` task and `Resolvers.remote`; however many projects use `IO.unzip(...)` directly to implement custom tasks - https://github.com/search?q=IO.unzip+language%3AScala&type=code&l=Scala&p=1\n\n### Patches\n\nThe problem has been patched in https://github.com/sbt/io/pull/360\nsbt 1.9.7 is available with the fix.\n\n### Workarounds\nA workaround might be use some other library to unzip.\n\n### References\n\n- https://github.com/snyk/zip-slip-vulnerability\n- https://security.snyk.io/vuln/SNYK-JAVA-ORGCODEHAUSPLEXUS-31680\n- https://github.com/sbt/io/issues/358",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.scala-sbt:sbt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.3.4"
      }, {
        "fixed" : "1.9.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.scala-sbt:io_2.12"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "1.9.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.scala-sbt:io_2.13"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "1.9.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.scala-sbt:io_3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "1.9.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sbt/sbt/security/advisories/GHSA-h9mw-grgx-2fhf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-46122"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sbt/io/issues/358"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sbt/io/pull/360"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sbt/io/commit/124538348db0713c80793cb57b915f97ec13188a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sbt/sbt"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-24T01:51:04Z",
    "nvd_published_at" : "2023-10-23T16:15:09Z"
  }
}