-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[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
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
whether valid or not, I just wanted to point out that @odaysec's commit history is basically all just drive-by AI-generated slop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this change does make sense, but the impact is mutch lower than the title did tell.
So i have update the title to match the actual issue the PR does fix.
@odaysec please run the format script, so this could be merged.
User description
selenium/java/src/org/openqa/selenium/io/Zip.java
Line 103 in 3744929
Extracting files from a malicious zip file, or similar type of archive, is at risk of directory traversal attacks if filenames from the archive are not properly validated.zip archives contain archive entries representing each file in the archive. These entries include a file path for the entry, but these file paths are not restricted and may contain unexpected special elements such as the directory traversal element (..). If these file paths are used to create a filesystem path, then a file operation may happen in an unexpected location. This can result in sensitive information being revealed or deleted, or an attacker being able to influence behavior by modifying unexpected files.
fix the issue, we need to validate the paths of directories being created in the
unzip
method. Specifically:FileHandler.createDir
for a directory entry, ensure that the canonical path of the directory is within the canonical path of the output directory.File.getCanonicalPath()
to normalize paths and compare them usingString.startsWith()
to ensure the directory is within the intended output directory.This fix will prevent directory traversal attacks by ensuring that no directories or files are created outside the intended output directory.
PR Type
Bug fix
Description
Fix directory traversal vulnerability in zip extraction
Add canonical path validation for directory entries
Prevent malicious archives from creating files outside target directory
Diagram Walkthrough
File Walkthrough
Zip.java
Add directory traversal protection
java/src/org/openqa/selenium/io/Zip.java