CVE-2023-46122
sbt vulnerable to arbitrary file write via archive extraction (Zip Slip)
Description
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
Affected Maven artifacts (4)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.scala-sbt » io_2.12 | >= 1.0.0, < 1.9.7 | 1.9.7 |
| org.scala-sbt » io_2.13 | >= 1.0.0, < 1.9.7 | 1.9.7 |
| org.scala-sbt » io_3 | >= 1.0.0, < 1.9.7 | 1.9.7 |
| org.scala-sbt » sbt | >= 0.3.4, < 1.9.7 | 1.9.7 |
Blast radius
54% of the dependent artifacts (112) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 2,695 |
| 2 hops | 1,469 |
| 3 hops | 3,389 |
| 4 hops | 1,998 |
| 5 hops | 94 |
| 6 hops | 57 |
Most used dependents
- net.alchim31.maven » scala-maven-plugin3,328 usages
- org.scala-sbt » sbt1,243 usages
- org.scala-sbt » util-logging59 usages
- org.scala-sbt » util-testing41 usages
- org.scala-sbt » zinc34 usages
- org.scala-sbt » librarymanagement-core30 usages
- org.scala-sbt » librarymanagement-ivy27 usages
- com.github.sbt » sbt-native-packager_2.12_1.021 usages
- org.scala-sbt » main20 usages
- ch.epfl.scala » bloop-frontend17 usages
- org.scala-sbt » zinc-classpath15 usages
- build.bleep » bleep-core15 usages
- org.scala-sbt » zinc-apiinfo11 usages
- org.scala-sbt » util-cache10 usages
- ch.epfl.bluebrain.nexus » nexus-workbench10 usages
Computed from the dependency graph of build 20261127.1117 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
| Advisory | NVD CVE-2023-46122 | nvd.nist.gov |
| Package | sbt/sbt | github.com |
| Web | sbt/sbt advisory GHSA-h9mw-grgx-2fhf | github.com |
| Web | sbt/io issue #358 | github.com |
| Web | sbt/io pull request #360 | github.com |
| Web | sbt/io commit 1245383 | github.com |
