Skip to content
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

WriteEntryToDirectory - entry with root path crash #824

Open
omermircor opened this issue Apr 8, 2024 · 5 comments
Open

WriteEntryToDirectory - entry with root path crash #824

omermircor opened this issue Apr 8, 2024 · 5 comments
Labels

Comments

@omermircor
Copy link

Hi, When I call WriteEntryToDirectory with entry key that is rooted for example '/root/file.txt' and the directory '/root2' as param.
the code fails with Entry is trying to create a directory outside of the destination directory.
The reason for that is Path.Combine ignore the directory path param.
The solution should be move use Path.Join.

@adamhathcock
Copy link
Owner

There was to avoid a specific vulnerability to not allow extraction outside the destination directory:

https://github.com/adamhathcock/sharpcompress/pull/374/files

Path.Join does not seem applicable.

@Ilanlido
Copy link

@adamhathcock Hi, i would've assume that if my destination folder is /root2 and the directory inside the zip is for example /root/file.txt then it will be extracted to /root2/root/file.txt (just like if i extract the zip manually on my pc)

@adamhathcock
Copy link
Owner

adamhathcock commented Apr 16, 2024

again, the linked PR prevents extraction to directories outside of the current one

@Ilanlido
Copy link

I understand, again, i didn't expect it to extract to outside directories i'm expecting it to extract the full path into my desired destination folder - the problem is that when using Path.Combine("/root","/root2/test.txt") it will return "/root2/test.txt" instead of "/root/root2/test.txt"

@adamhathcock
Copy link
Owner

These are just convenance methods. You don't have to use them. You can write your own to write entries to whatever you like and however you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants