Repository navigation
🐛 fix(discovery): don't search siblings of the base prefix - #293
Merged
gaborbernat merged 2 commits intoNov 30, 2026
Merged
Conversation
Deciding that an executable lies inside the environment used a bare string prefix, so <dir>/venv-3.11/bin counted as inside <dir>/venv. Its leftover "-3.11/bin" was then appended to the base prefix, and discovery ran whatever interpreter-named file sat in <base>-3.11/bin before the real base install. A user who can create entries in a shared directory could plant that file and have it returned as the base interpreter. Compare whole path components instead, so a folder is only mapped onto the base prefix when it is really inside the environment. A prefix that ends in a separator, such as the filesystem root, now maps correctly too. Reported by oss-scanner as ANT-2026-X5XPI5K4.
os.path.commonpath also raises when it mixes a relative executable folder with an absolute prefix, not only for paths on different Windows drives.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolving a Python 3.9 or 3.10 virtual environment to its base Python could search a folder next to the base install, and start any interpreter found there. With the base Python directly in a shared folder such as
/tmp, another local user could put a program in that neighbouring folder and have it run as whoever resolved the environment. 🔒 Discovery now searches only inside the base install. This addresses draft advisory ANT-2026-X5XPI5K4.base-3.10/bin/pythonstands in for a program another user placed next to the base install; it only records that it was started:Before:
After:
Folders are now compared by whole path components with
os.path.commonpathinstead ofstr.startswith.Python 3.11 and later find the base through
getpathand do not use this search. A base install at the file system root now maps correctly, where it used to produce a broken path. Windows was not tested, because the test machine cannot create symlinks.Reported by oss-scanner: ANT-2026-X5XPI5K4.