Repository navigation
🐛 fix(discovery): ignore stdlib landmark owned by another user - #288
Merged
Merged
Conversation
An interpreter symlink stayed unresolved whenever the directory beside it held an existing lib/pythonX.Y/os.py, whoever owned that file. A venv built from the link records the link's directory as home, and CPython then imports the standard library from there. A file another user created in a shared parent such as /tmp was enough to switch the resolution off. The landmark now counts only when lib, lib/pythonX.Y and os.py are each owned by root, the effective user or the owner of the link's directory. They are checked with lstat, so a symlink owned by another user cannot pass on the owner of its target. Platforms without geteuid keep the previous check. Fixes tox-dev#283. Reported by oss-scanner as ANT-2026-UFV4PHZZ.
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.
Discovery keeps an interpreter symlink unresolved when a standard library sits next to it, so that aliases such as Debian's
/usr/bin/python3stay as they are (#86). It never checked who owned that library, so another local user could create one beside a link kept under a shared folder such as/tmp. Environments built from that link withvenvthen loaded the other user's standard library. 🐛 Only a library owned by root, the current user or the owner of the link's folder keeps a link unresolved now. Fixes #283.On
python:3.13-slimwith two accounts,malloryandalice:Before:
After:
The rule from #87 that keeps distribution aliases stays, with one added condition on who installed the library.
Distribution, pyenv, uv and Homebrew installs behave as before. A library owned by some other account now resolves to the real interpreter, as release 1.4.1 did (#85). Windows is unchanged. A link placed directly in a world-writable folder right below
/stays exposed, as it is topython -m venvwithout python-discovery.Reported by oss-scanner: ANT-2026-UFV4PHZZ.