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

CVE-2007-4559 Patch #89

Closed
wants to merge 1 commit into from
Closed

Conversation

TrellixVulnTeam
Copy link

Patching CVE-2007-4559

Hi, we are security researchers from the Advanced Research Center at Trellix. We have began a campaign to patch a widespread bug named CVE-2007-4559. CVE-2007-4559 is a 15 year old bug in the Python tarfile package. By using extract() or extractall() on a tarfile object without sanitizing input, a maliciously crafted .tar file could perform a directory path traversal attack. We found at least one unsantized extractall() in your codebase and are providing a patch for you via pull request. The patch essentially checks to see if all tarfile members will be extracted safely and throws an exception otherwise. We encourage you to use this patch or your own solution to secure against CVE-2007-4559. Further technical information about the vulnerability can be found in this blog.

If you have further questions you may contact us through this projects lead researcher Kasimir Schulz.

@CAM-Gerlach
Copy link
Collaborator

This doesn't appear to be a huge threat; its certainly possible that an attacker could have malicious sdists with directory traversal, on PyPI or (perhaps) locally, but given they contain arbitrary executable code, once run they can do anything they want anyway, so that seems like a much more likely attack vector. Funny enough, the same was even more true of our usage in Spyder—they were used to save and restore the user's own Python session, which inherently involves executing arbitrary code, so the BadTAR attack was purely academic (since any sane attacker would simply include their malicious code right within the pickle, rather than relying on a more complex, fragile and limited BadTar exploit chain)—but funny enough, they still featured us on their blog.

This PR has some linting issues, and there doesn't appear to be any reason to define these as nested functions, while the file is open within the context manager no less, as opposed to normal module-level functions, other than automating mass PRs, whereas doing so would be more idiomatic, efficient, safe and re-usable.

However, it doesn't hurt to patch this; based on experience they won't respond here, but I could apply the same patch we did on spyder-ide/spyder-kernels#428 , if you think this is worth doing @regebro

@regebro
Copy link
Owner

regebro commented Nov 21, 2022

Yes, I think it's a good idea to do something about this. And I like the spyder implementation better.

@CAM-Gerlach
Copy link
Collaborator

Thanks @regebro , opened as PR #90 for your review with some additional simplification using pathlib and minor tweaks to follow Pyroma's conventions (Black, etc).

@regebro regebro closed this in #90 Nov 24, 2022
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.

None yet

3 participants