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

Fixes #29; filenames containing .. being rejected. #30

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

dom96
Copy link
Contributor

@dom96 dom96 commented Oct 1, 2021

This is a 1am PR so review carefully :)

@guzba
Copy link
Owner

guzba commented Oct 2, 2021

Thanks very much for the PR. I have one thought that I want to check with you.

As you have deduced, my primary goal with avoiding relative paths is to prevent extracting a zip or tarball from writing files outside of the directory you told it to put the files. No one probably wants extracting a zip to put files in random places on their machine.

The PR suggests changing the check to /../. My concern would be if the path is ../a/path/ where it starts with a ... This would/could write out of the directory but pass the test. Could I be wrong about that or does that make sense? It has been a bit for me since I was working on this haha.

If that is possible, would checking for ../ be a good middle ground? More specific than just .. but still catch the initial relative which /../ would miss? No reason not to take just one moment and get your thought on that.

@dom96
Copy link
Contributor Author

dom96 commented Oct 2, 2021

Thanks for the quick review! Definitely worth thinking about this, one thing that immediately comes to mind is what if there is a folder named test-..? I just tested and was able to create this path:

$ pwd
/mnt/c/Users/morfe/other_projects/zippy/test-../foo

Maybe we could check as well whether the path starts with ../?

@guzba
Copy link
Owner

guzba commented Oct 2, 2021

Maybe we could check as well whether the path starts with ../?

Sure, that sounds good to me. Are you ok updating this PR to that check?

@guzba guzba merged commit fbe73f8 into guzba:master Oct 5, 2021
@guzba
Copy link
Owner

guzba commented Oct 5, 2021

Merged this and adjusted to 246385f

@dom96
Copy link
Contributor Author

dom96 commented Oct 5, 2021

Hey, sorry I didn't get a chance to adjust this. FWIW I think you want to also check for the string containing /../ and \..\ as you might get something like foobar/../../../../

@guzba
Copy link
Owner

guzba commented Oct 5, 2021

Npnp, just was already working on zippy so I just grabbed it quick. Added the suggested check and tagged zippy 0.7.2.

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