Skip to content

Conversation

@dlebrero
Copy link

(java.io ByteArrayOutputStream File)))

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

@aviadatsnyk aviadatsnyk Jun 18, 2018

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
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