Repository navigation
Description
With a reused environment whose include directory is a symlink, --creator venv leaves the link in place. On Python 3.11, creation succeeds but makes an empty python3.11 directory at the link target, outside the environment. On Python 3.14, stdlib venv rejects the link and creation fails.
Affected code
Venv.create() at 8e09166d. The same directory list remains at ebe06113.
Mechanism
Venv.create() calls ensure_within() for bin_dir, purelib, and platlib before calling stdlib venv, but omits include. The builtin creator includes include_dir in its directory set. #3429 added the venv creator's directory check for its executable and library paths; the header path was not included.
Python 3.11's EnvBuilder.ensure_directories() creates <env>/include/python3.11 with os.makedirs(). It checks the final path for a link, but the parent include link is followed while creating the missing python3.11 directory. Python 3.14 creates and checks include itself, so it fails on the same tree.
Reproduction
From the virtualenv checkout at 8e09166ddfbdaed3a5dbccc216d38ff1d3dbb4c2, with Python 3.11 and the virtualenv command using that source:
scratch=$(mktemp -d)
mkdir -p "$scratch/checkout/.venv" "$scratch/user-folder"
ln -s ../../user-folder "$scratch/checkout/.venv/include"
(
cd "$scratch/checkout"
virtualenv --quiet --no-seed --no-periodic-update --app-data "$scratch/app-data" --python "$(command -v python3.11)" --creator venv .venv
)
find "$scratch/user-folder" -mindepth 1 -maxdepth 1 -printf '%f\n'
test -L "$scratch/checkout/.venv/include" && printf 'include remains a symlink\n'The run printed:
python3.11
include remains a symlink
The reported control runs with --creator builtin and with a link at .venv/lib left the outside folder empty. Expected: replace the include link with a directory inside the environment, as the builtin creator does. The Python 3.14 run should also succeed on this tree.
Impact
This requires a reused destination with an existing include link, the non-default --creator venv, and no --clear. On Python 3.11, the effect shown is one empty directory with a fixed name at the link target; Python 3.14 instead fails creation. The destination's contents are trusted, so this does not establish a separate security boundary crossing.
Reproducibility: moderate, because the setup needs a linked include directory and a selected creator. Real-world exposure: unlikely, because it also needs a reused environment and the non-default creator.
Credits
Reported by oss-scanner: ANT-2026-SQMY7UXO.
Activity
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include
🐛 fix(create): contain venv include