Skip to content

Refuse wheel installs through directory symlinks and replace file symlinks - #14296

Open
notatallshaw wants to merge 3 commits into
pypa:mainfrom
notatallshaw:fix/wheel-install-symlink-escape
Open

notatallshaw wants to merge 3 commits into
pypa:mainfrom
notatallshaw:fix/wheel-install-symlink-escape

Conversation

@notatallshaw

Copy link
Copy Markdown
Member

What does this PR do?

When pip writes a file, it follows any symlink already at that path, and a dangling symlink at a path pip is about to create is followed too. So a written file can land wherever the link points: wheel members, console scripts, REQUESTED, pip download and pip wheel output, and the --target copy across filesystems.

Fixes:

  • Wheel installs now resolve each file's parent directory and refuse when it falls outside its scheme directory.
  • A symlinked __pycache__ is refused the same way.
  • A symlink at a path pip is about to write is unlinked first, so a regular file replaces it and the link target is untouched.
  • A symlink that resolves inside the scheme still works

PR Checklist:

  • I agree to follow the PSF Code of Conduct.
  • I have read and have followed the CONTRIBUTING.md file.
  • I have added a news file fragment (or this PR does not need one).
  • I have read and followed the AI_POLICY.md file, and if any AI tools were used, I have disclosed it below.

Used Claude and Codex to do multiple rounds of checking for completeness and correctness.

@notatallshaw
notatallshaw force-pushed the fix/wheel-install-symlink-escape branch from 67993ef to 7ee6579 Compare September 5, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant