-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
File paths of ZIP contents are not sanitized #8731
Comments
Thanks, I'll fix this (though PRs are also welcome). |
@SLeitgeb Can you say more about the threat model you're using here? |
The scenario that comes to mind involves a malicious package that would get installed as a user dependency. This package doesn't need to be a direct dependency, it could also be a dependency of another package. The WHL archive of the malicious package could be manipulated to include arbitrary files (SSH keys, binaries, etc.) that uv would then extract. Running uv as a privileged user in a production environment could then be quite bad. I don't think this scenario is too likely, and the offending packages would be easy to discover, but there could also be other implications I'm not seeing (maybe package sources outside of pypi?). |
I think you also need to stipulate that you've configured But if you're only installing wheels with |
Are you sure the example from the summary works? For local wheels, we use the |
@BurntSushi That seems right. I don't think it's a big issue, just something I wanted you to be aware of. |
@charliermarsh I tested this several times to be sure, once also with the package installed from a local index, with the same results. |
## Summary Based on the example in `async-zip`: https://github.com/Majored/rs-async-zip/blob/527bda9d58c1ba1fa973a0faeb68dce91fa4ffe4/examples/file_extraction.rs#L33 Closes: #8731. ## Test Plan Created https://github.com/astral-sh/sanitize-wheel-test.
Thanks for catching this @SLeitgeb, appreciate it. |
All files from a package WHL are extracted to the path resolved from the current directory. The ZIP file path is not sanitized first (as suggested in the async_zip package), which could lead to directory traversal attacks, e.g. by a malicious package.
The demo below uses relative filepaths, but this would presumably resolve absolute paths as well (e.g.
~/.cache/uv/archive-v0
+/etc/passwd
→/etc/passwd
).Tested on Arch Linux with uv 0.4.28, Python 3.10. This should also affect Windows.
An example of the issue using an empty payload file in a parent directory.
You should observe a
payload
file created two directories up relative to the directory from which the paths are resolved (should be the$HOME/.config
directory).The text was updated successfully, but these errors were encountered: