Repository navigation
🐛 fix(discovery): don't hang on FIFO version files - #292
Merged
gaborbernat merged 1 commit intoNov 30, 2026
Merged
Conversation
Shim resolution checks that a .python-version path is a file, then opens it by name. Another local user who can write to a shared parent directory can swap in a FIFO between those two calls, and open() then waits for a writer with no timeout to bound the wait, hanging discovery. Open version files with O_NONBLOCK and check the descriptor that is read, skipping anything that is not a regular file. O_NOFOLLOW is not used, so symlinked version files keep working. Reported by oss-scanner as ANT-2026-2XCH1H5T.
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 reads
.python-versionfiles in the current folder and its parents, as pyenv does. Another user who can write a parent folder such as/tmpcould swap that file for a named pipe between discovery's check and its read, and make discovery and the calling tool hang. 🔒 Version files are now opened without waiting, and anything that is not a regular file is skipped. This addresses draft advisory ANT-2026-2XCH1H5T.lease.pyopens the file and holds a write lease on it (fcntl(2)F_SETLEASE), as a backup or sync tool might:Before:
After:
The disk cache already opens its entries this way (open(2)
O_NONBLOCK); version files now follow it and check the opened file withS_ISREGbefore reading.Regular and symlinked version files are read as before. Windows is unchanged. A file system that blocks while opening, such as an unresponsive network mount, is not covered.
Reported by oss-scanner: ANT-2026-2XCH1H5T.