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

Security issue fix in tar file extraction #35

Open
michaelessiet opened this issue May 4, 2022 · 0 comments
Open

Security issue fix in tar file extraction #35

michaelessiet opened this issue May 4, 2022 · 0 comments

Comments

@michaelessiet
Copy link

Quick description
There is an unsafe extraction of a tarfile in the setup_tools.py. A good practice would be to validate that the destination file path is present in the destination directory and that they are valid directories, not doing this may cause files to be overwritten within the destination directory to be overwritten.

In line 63 to 65

with tarfile.open(fileobj=content) as tf:
    dirname = tf.getnames()[0].partition('/')[0]
    tf.extractall()

I believe a better way would be to use

with tarfile.open(fileobj=content) as tf:
    dirname = tf.getnames()[0].partition('/')[0]
    tf.extractall(members=get_safe_members_in_tar_file(tf))

In my pull request this function will be found in tar_validation.py

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

No branches or pull requests

1 participant