Skip to content

Junrar: LocalFolderExtractor mkdir escape allows directory creation outside extraction root

Low severity GitHub Reviewed Published Jul 21, 2026 in junrar/junrar • Updated Sep 17, 2026

Package

maven com.github.junrar:junrar (Maven)

Affected versions

<= 7.6.0

Patched versions

7.6.1

Description

Summary

LocalFolderExtractor validates only the final canonical file path before extraction. However, makeFile() creates intermediate directories one path segment at a time without checking whether each created directory remains inside the destination folder.

A malicious RAR entry can make the final file path resolve inside the extraction destination, while causing intermediate mkdir() calls to create attacker-chosen directories outside the extraction root.

This is an extraction root escape via unchecked intermediate directory creation. The default impact is directory creation outside the intended destination, not unconditional arbitrary file content write.

Affected Code

  • src/main/java/com/github/junrar/LocalFolderExtractor.java
    • createFile() checks only the final canonical path.
    • makeFile() calls dir.mkdir() for each intermediate segment without containment checks.

Relevant code flow:

private File createFile(final FileHeader fh, final File destination) throws IOException {
    String name = invariantSeparatorsPathString(fh.getFileName());
    File f = new File(destination, name);
    String dirCanonPath = f.getCanonicalPath();
    if (!dirCanonPath.startsWith(destination.getCanonicalPath() + File.separator)) {
        throw new IllegalStateException(...);
    }
    if (!f.exists()) {
        f = makeFile(destination, name);
    }
    return f;
}

private File makeFile(final File destination, final String name) throws IOException {
    final String[] dirs = name.split("/");
    String path = "";
    for (int i = 0; i < dirs.length - 1; i++) {
        path = path + File.separator + dirs[i];
        File dir = new File(destination, path);
        dir.mkdir();
    }
    path = path + File.separator + dirs[dirs.length - 1];
    final File f = new File(destination, path);
    f.createNewFile();
    return f;
}

Impact

An attacker who can supply a malicious RAR archive can create directories outside the intended extraction directory.

This violates the expected extraction boundary and can be used for filesystem pollution or file-vs-directory squatting. For example, an attacker can create a directory at a path where a later security-sensitive file is expected, causing future writes to that path to fail.

References

@gotson gotson published to junrar/junrar Jul 21, 2026
Published by the National Vulnerability Database Sep 16, 2026
Published to the GitHub Advisory Database Sep 17, 2026
Reviewed Sep 17, 2026
Last updated Sep 17, 2026

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(28th percentile)

Weaknesses

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. Learn more on MITRE.

CVE ID

CVE-2026-86071

GHSA ID

GHSA-89m4-43j5-vhhx

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.