8000 abort tarball extraction if unsafe path encountered by msarahan · Pull Request #8374 · conda/conda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

abort tarball extraction if unsafe path encountered #8374

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

Merged
merged 3 commits into from
Mar 6, 2019

Conversation

msarahan
Copy link
Contributor
@msarahan msarahan commented Mar 4, 2019

Conda's handling of tarball extraction leaves potential for malicious tarballs to do naughty things. More at

https://bugs.python.org/issue1044#msg55464
https://nvd.nist.gov/vuln/detail/CVE-2007-4559

The most recent development in Python seems to be at https://bugs.python.org/issue21109

This patch is intended to exit out when malcious paths are encountered, but we should study the most recent development in Python mentioned above to double-check.

This code will be rendered obsolete by the switch to libarchive (via conda-package-handling) thanks to its security flags: https://github.com/conda/conda-package-handling/blob/master/conda_package_handling/tarball.py#L68-L77

@msarahan msarahan requested a review from a team as a code owner March 4, 2019 22:04
@msarahan msarahan force-pushed the abort_on_unsafe_tarball_path branch 2 times, most recently from c571259 to 965fa5e Compare March 5, 2019 21:02
@msarahan
Copy link
Contributor Author
msarahan commented Mar 5, 2019

Note: this code is really a placeholder. The right answer to this is our libarchive-based tarball handling. This implementation is here to get 4.6.x into a better state, but it should be replaced by the conda-package-handling code.

for member in tar_file.getmembers():
if (os.path.isabs(member.name) or
not os.path.realpath(member.name).startswith(os.getcwd())):
sys.exit("tarball {} contains unsafe path: {}. Erroring out."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would raising an error be more appropriate here? That would allow conda's error handling and logging framework to capture and report the error.

@kalefranz
Copy link
Contributor
kalefranz commented Mar 5, 2019

.

@msarahan
Copy link
Contributor Author
msarahan commented Mar 5, 2019

The performance penalty here is going to suck. We should probably put it behind the safety checks parameter. Maybe we can skip safety checks for signed packages from known channels or something.

@msarahan msarahan force-pushed the abort_on_unsafe_tarball_path branch from 8ea3be3 to f315829 Compare March 6, 2019 19:38
@msarahan msarahan force-pushed the abort_on_unsafe_tarball_path branch from f315829 to f86c79b Compare March 6, 2019 19:41
@msarahan msarahan merged commit c9e3a04 into conda:master Mar 6, 2019
@msarahan msarahan deleted the abort_on_unsafe_tarball_path branch March 6, 2019 21:06
@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Aug 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0