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
Fix path traversal vulnerability #100
Fix path traversal vulnerability #100
Conversation
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.
Thanks @aidy1991 I have a suggestion.
Regarding reporting an error - this is a very good suggestion. Feel free to open a PR for it (I can provide some pointers if needed).
archive_path = jp_root_dir / "test.tar.gz" | ||
open(unsafe_file_path, 'a').close() | ||
with tarfile.open(archive_path, "w:gz") as tf: | ||
tf.add(unsafe_file_path, "../../../../../../../../../../tmp/test") |
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.
We could parametrize this test to add also "../test"
.
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.
I see, it looks good. I'll fix to use parametrize and add ../test
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
@fcollonval
Okay, I will try to work on the issue. |
("../../../../../../../../../../tmp/test"), | ||
("../test"), |
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.
🚀
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.
Thanks @aidy1991
Thank you for your review 👍 |
See https://nvd.nist.gov/vuln/detail/CVE-2007-4559
extractall()
oftarfile
has path traversal vulnerability. We need to check file path before usingextractall()
to avoid it.If we need to add a unit test for this, please let me know.I added a unit test.How to reproduce
/tmp/test
will be created (After this PR, the request of extracting will be failed as 400 bad request)Unrelated to this PR, is it the intended behavior that the user is not notified of an error when an extract request fails?