Skip to content

Fixing Zip Slip vulnerability#111

Open
dlebrero wants to merge 2 commits into
Raynes:masterfrom
clj-commons:zip-slip
Open

Fixing Zip Slip vulnerability#111
dlebrero wants to merge 2 commits into
Raynes:masterfrom
clj-commons:zip-slip

Conversation

@dlebrero

Copy link
Copy Markdown

Comment thread src/me/raynes/fs/compression.clj Outdated
(java.io ByteArrayOutputStream File)))

(defn- check-final-path-inside-target-dir! [f target-dir entry]
(when-not (-> f .getCanonicalPath (.startsWith (.getCanonicalPath target-dir)))

@aviadatsnyk aviadatsnyk Jun 18, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlebrero great job fixing this!

can you please add the path separator after (.getCanonicalPath target-dir) and make it
(str (.getCanonicalPath target-dir) (java.io.File/separator)) (or any better implementation)?
This is to make sure that an evil file like /tmp/safe.UNSAFE/evil.sh cannot be written if the target directory is /tmp/safe.
See also the java reference implementation https://snyk.io/research/zip-slip-vulnerability#java.

@dlebrero

Copy link
Copy Markdown
Author

@aviadatsnyk thanks a lot for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants