Skip to content

[java] arbitrary directory creation during archive extraction to a pathname to a restricted directory #16087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions java/src/org/openqa/selenium/io/Zip.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public static void unzip(InputStream source, File outputDir) throws IOException
while ((entry = zis.getNextEntry()) != null) {
File file = new File(outputDir, entry.getName());
if (entry.isDirectory()) {
String canonicalOutputDirPath = outputDir.getCanonicalPath();
String canonicalDirPath = file.getCanonicalPath();
if (!canonicalDirPath.startsWith(canonicalOutputDirPath + File.separator)) {
throw new IOException("Directory entry is outside of the target dir: " + entry.getName());
}
FileHandler.createDir(file);
continue;
}
Expand Down
Loading