Skip to content

🐛 fix(seed): contain metadata lookups - #3649

Merged
gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/3624-contain-seed-lookups
Nov 20, 2026
Merged

gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:fix/3624-contain-seed-lookups

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

_uninstall_dist checked an absolute or .. path listed in existing package metadata before deciding whether it belonged to the environment. Such an entry could cause a filesystem lookup elsewhere during reseeding. The lookup is now skipped when the entry leaves the environment lexically. Fixes #3624.

Metadata path resolution

An absolute right-hand path replaces the left-hand path when RECORD entries are joined to site-packages. The old _record_paths also searched the derived __pycache__ directory before the cleanup guard ran. It now checks the lexical path before that search (new code).

Cleanup ordering

The old cleanup loop called exists() before resolving containment. The new lexical guard rejects absolute and .. entries outside the environment before that call. The existing resolved-path check still controls removal through parent links.

Behavior changes

Malformed absolute and .. metadata entries outside the environment are skipped with a warning. Relative entries that reach another directory within the environment, such as ../../../bin/pip, remain eligible for cleanup. Parent links still use the existing post-lookup containment check. The report did not establish a Windows network request or credential use from the old lookup.

Reported by oss-scanner: ANT-2026-5PAH96SM.

@gaborbernat
gaborbernat force-pushed the fix/3624-contain-seed-lookups branch from 0e53221 to 20fea37 Compare November 20, 2026 06:29
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 06:34
@gaborbernat
gaborbernat force-pushed the fix/3624-contain-seed-lookups branch 4 times, most recently from af2a7f9 to 4bb17f5 Compare November 20, 2026 09:09
The cleanup guard from pypa#3428 runs after checking RECORD paths. A malformed
absolute path can trigger an outside lookup before removal is rejected.
Check lexical and resolved parents before querying metadata entries or
their bytecode directories. Keep relative entries within the environment.

Fixes pypa#3624
Resolving a parent link can probe outside the environment before the guard
returns. Limit the early check to path text and leave the existing containment
check to protect deletion. Exercise absolute and traversal entries through
reseeding.
@gaborbernat
gaborbernat force-pushed the fix/3624-contain-seed-lookups branch from 4bb17f5 to 0509881 Compare November 20, 2026 10:46
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 12:28
@gaborbernat
gaborbernat merged commit 6f0966f into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/3624-contain-seed-lookups branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seed cleanup looks up outside paths before containment

1 participant