Skip to content

Reseeding hangs when an existing RECORD is a FIFO #3627

Description

@gaborbernat

Reseeding an existing environment waits indefinitely when its old pip RECORD is a FIFO with no writer. The app-data seeder checks that the path exists, then opens it to read the whole file.

Affected code

At the reproduced main commit ebe06113f440731ab9c5bd6506a4793140532dc9, PipInstall._uninstall_previous_version selects the old distribution, _uninstall_dist reads top_level.txt, and _record_paths reads RECORD. The report's earlier commit 8e09166ddfbdaed3a5dbccc216d38ff1d3dbb4c2 has the same unchecked reads in _uninstall_dist.

Mechanism

The seeder finds a matching pip-*.dist-info in the reused destination and reads its metadata before replacing pip. Python's Path.exists() accepts an existing FIFO, and Path.read_bytes() opens it. A FIFO opened for reading waits for a writer, so the seeder never reaches the cleanup code. top_level.txt uses read_text() after the same existence check and has the same problem.

Reproduction

From the repository root on POSIX with Python 3.15:

tmp=$(mktemp -d)
mkdir -p "$tmp/env/lib/python3.15/site-packages/pip-1.dist-info"
mkfifo "$tmp/env/lib/python3.15/site-packages/pip-1.dist-info/RECORD"
timeout 6s env PYTHONPATH="$PWD/src" python -m virtualenv --no-periodic-update --app-data "$tmp/cache" "$tmp/env"
printf 'exit status: %s\n' "$?"

On ebe06113f440731ab9c5bd6506a4793140532dc9, the virtualenv command printed nothing and timeout returned 124 after six seconds. A regular RECORD should allow reseeding to finish; a FIFO should be skipped or produce an error without waiting for a writer.

Impact

This affects a POSIX run that reuses a destination containing a FIFO as seed package metadata. Reproducibility is moderate because it needs this specific setup. Real-world exposure is unlikely because the destination must already contain unusual metadata; package installers normally write regular files. The destination contents are trusted. A very large regular RECORD or top_level.txt would still be read in full, so rejecting special files alone would not bound memory use.

Credits

Reported by oss-scanner: ANT-2026-GY26H3A6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions