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
tarfile insecure pathname extraction #45385
Comments
tarfile does not check pathnames or linknames on extraction. This can Example for a symlink attack against /etc/passwd: foo -> /etc |
no change to extract() ? otherwise looks good to me. if you don't object, i am applying this to |
In principle I do not object, but this is a preliminary patch. I am I do not change extract() because it has become more and more a |
After careful consideration and a private discussion with Martin I do no I update the documentation with a warning, that it might be dangerous to |
if that can be considered "official stance", it's fine by me. feel free |
I updated the documentation, r57764 (trunk) and r57765 (2.5). |
Has anyone seen this? If so, what's been done so far? |
Doing something you shouldn't with untrusted input isn't the language's fault. |
Also coming here after being pinged on this CVE, my case was sourced from https://www.bleepingcomputer.com/news/security/unpatched-15-year-old-python-bug-allows-code-execution-in-350k-projects/. Seems the concern is that even if the package is conformant to the spec, the spec allows for behavior that is exploitable? |
If you think this is not a security issue then call it a feature request. In this case, I'd argue that absolute paths should be ok if the target directory is '/'. We'd want an up-to-date restore utility to be able to restore a system backup that was created with an older version of the utility (assuming the old version puts absolute paths into the archive and the new version specifies '/' as the target directory). As to the naming of A nice extension would be to allow |
Does anyone know what sort of patch Trellix is applying on public GitHub projects to fix CVE-2007-4559? |
Hello everyone, I am Kasimir, the project lead from Trellix for the research regarding CVE-2007-4559 and I just wanted to share some of our research here and answer possible questions from the community. Q: Does anyone know what sort of patch Trellix is applying on public GitHub projects to fix CVE-2007-4559? Our patch is based off of what is done in pip's source code. We created a wrapper function for extractall which takes in the tar object created by opening an archive, as well as any other parameters that would be passed to the extractall. Within the wrapper function we then check to see if the extracted files are all within the directory they should be extracted to. We chose this approach since we were worried that trying to filter out certain characters would increase the chances of a bypass. Not having a filter was also chosen since ".." is a legitimate use case and not a security concern if the extracted file does not escape outside of the directory that was specified as the extraction directory, our patch would not stop people from being able to do this. Q: Seems the concern is that even if the package is conformant to the spec, the spec allows for behavior that is exploitable? During our research we noticed that most other tools that allow you to extract tar files (including the default command line tool), do not allow tarfiles that attempt to write outside of the directory by default. Most of these tools aim to protect the user by default and allow knowledgable users to extract the files regardless with certain flags. The reason that we published our research was to bring our concern into the light since while analyzing open source repositories we discovered that most of the code did not do security checks despite being in situations where it should be done. We will be monitoring this thread and will attempt to answer any other questions that arise pertaining to our research! |
Thanks, @Kasimir123. Can I get a link to one of your PRs or a sample source code where you've fixed this vulnerability? |
@0xr1 Due to the large number of repositories that need patching we have been patching locally and will be starting to do the pull requests next week. The patches vary slightly based on each project since our patching tool attempts to match the syntax of whatever is being patched but what we are modifying is published here. |
Calling
Edit:
|
I think it falls into the responsibility of CPython standard library devs to design good APIs, which includes effort to make it hard for users to use them in a way that nurtures security issues. GNU tar*, at least, strips leading slashes from file names, and rejects attempts to extracts files that contain a Perhaps The non-safe variants could be made to emit a suppressable warning, and users who positively know they need to write outside the target directory could resort to/keep using them. * According to the docs, |
This issue is closed, I suggest continuing the discussion on the issue #73974. |
Hi! I'm a Senior Software Security Researcher over at the Open Source Security Foundation under the Linux Foundation.
IMHO, this is the responsibility of all API designers. But absolutely the python standard library.
PyYAML is currently using the |
Hey there,
That doesn't seem accurate: in the most recent version of PyYAML at the time of my previous post, and today,
Oh I don't doubt that security should be made the default to the extent possible/practical. This is easier to do for greenfield projects. There are people who have put a much better effort into how to improve Footnotes |
Back in 2019, I pushed an initiative across the entire java ecosystem for the major artifact servers like Maven Central, and JCenter (what pip is to the python ecosystem) to formally drop support for HTTP in favor of HTTPS only on January 15th, 2020.
This was due to a widespread common security vulnerability I discovered impacting the Java ecosystem: https://infosecwriteups.com/want-to-take-over-the-java-ecosystem-all-you-need-is-a-mitm-1fc329d898fb On January 15th, 2020, the build infrastructure of 20% of the java ecosystem was broken due to this change. It fixed a large security hole in the supply chain of the java ecosystem. This vulnerability has impacted tens of thousands of OSS projects (trellex just opened 65,000 pull requests attempting to fix this vulnerability). I recognize that there are negative impacts of API breaking changes, but it's important that ensuring API's aren't broken doesn't overshadow ensuring the users of those API are secure by default. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: