From 957343c07b80d313d3cdbfe77582fe81566b0a94 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Sat, 21 Nov 2026 21:33:23 +0700 Subject: [PATCH] fix(core): a free-threaded python3.14t.exe is a Python too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by running env list against this machine: the python.org installer puts python3.14t.exe (PEP 703) beside python.exe, the registry lists it, and the new name rule refused it — so Add interpreter… could not add an interpreter discovery itself reports. A version may now end in t; pythonw3.14t, pythont and python3.14tt are still refused. Co-Authored-By: Claude Opus 5.5 --- crates/pipdock-core/src/envs/mod.rs | 29 +++++++++++++++++++++++++---- docs/CLI-GUIDE.md | 3 ++- docs/SECURITY.md | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/crates/pipdock-core/src/envs/mod.rs b/crates/pipdock-core/src/envs/mod.rs index 447d124..e3f58b8 100644 --- a/crates/pipdock-core/src/envs/mod.rs +++ b/crates/pipdock-core/src/envs/mod.rs @@ -232,7 +232,8 @@ pub async fn scan_with(manual: &[PathBuf]) -> Vec { /// enforcement point, not the picker, which only suggests: /// /// - it must exist and be a file, or there is nothing to probe; -/// - its name must be `python.exe`, `python3.exe` or `python3.12.exe` (`python`, `python3`, … off +/// - its name must be `python.exe`, `python3.exe`, `python3.12.exe` or the free-threaded +/// `python3.14t.exe` (`python`, `python3`, … off /// Windows), so that adding an interpreter is not a way to start any program with PipDock's /// arguments. `pythonw.exe` is refused too: it has no console, the probe's output would be empty, /// and the failure would read as a broken environment instead of the wrong file; @@ -253,7 +254,7 @@ pub fn validate_interpreter(path: &Path, app_data: &Path) -> Result { if !is_python_name(path) { return Err(refuse(format!( "{} is not a Python interpreter PipDock will run: the file has to be python.exe \ - (or python3.exe, python3.12.exe)", + (or python3.exe, python3.12.exe, python3.14t.exe)", path.display() ))); } @@ -277,7 +278,10 @@ pub fn validate_interpreter(path: &Path, app_data: &Path) -> Result { Ok(canonical) } -/// `python`, `python3` or `python3.12`, with `.exe` on Windows; any case. +/// `python`, `python3` or `python3.12`, with `.exe` on Windows; any case. A version may end in `t`, +/// the free-threaded build's name (`python3.14t.exe`, PEP 703) — the python.org installer puts one +/// beside `python.exe`, and the registry reports it; refusing it was found by running `env list` +/// against this machine's own Pythons. fn is_python_name(path: &Path) -> bool { let Some(name) = path.file_name().and_then(|n| n.to_str()) else { return false; @@ -294,6 +298,10 @@ fn is_python_name(path: &Path) -> bool { let Some(version) = stem.strip_prefix("python") else { return false; }; + let version = match version.strip_suffix('t') { + Some(threaded) if !threaded.is_empty() => threaded, + _ => version, + }; version.is_empty() || (version.split('.').count() <= 2 && version @@ -623,12 +631,25 @@ mod tests { #[test] fn only_a_file_named_like_python_is_accepted() { - for name in ["python", "PYTHON", "python3", "python3.12", "Python3.14"] { + // The free-threaded build (PEP 703) is `python3.14t.exe`, beside `python.exe` in the same + // install — the registry lists it on this repository's own reference machine. + for name in [ + "python", + "PYTHON", + "python3", + "python3.12", + "Python3.14", + "python3.14t", + "python3t", + ] { assert!(is_python_name(Path::new(&exe(name))), "{name}"); } // pythonw has no console; the rest are other programs, or versions that are not versions. for name in [ "pythonw", + "pythonw3.14t", + "pythont", + "python3.14tt", "notepad", "py", "python3.12.1", diff --git a/docs/CLI-GUIDE.md b/docs/CLI-GUIDE.md index d11d143..dd0ce51 100644 --- a/docs/CLI-GUIDE.md +++ b/docs/CLI-GUIDE.md @@ -97,7 +97,8 @@ It appears in `env list` after discovery's own rows, with `source: "manual"`, an Environments screen. `pipdock env remove D:\work\scraper\myenv` takes it off again; nothing on disk is touched, and its pins and snapshots stay for the day it comes back. Since 1.6.0 a path you give `--env`, `env use` or `env add` must be named like a Python interpreter (`python.exe`, -`python3.exe`, `python3.12.exe`) and must not be one of PipDock's own venvs, or it is refused +`python3.exe`, `python3.12.exe`, the free-threaded `python3.14t.exe`) and must not be one of +PipDock's own venvs, or it is refused with PD-ENV-001 before anything runs it. Make one the default so you can stop typing `--env`: diff --git a/docs/SECURITY.md b/docs/SECURITY.md index ec2e589..0be7f28 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -12,7 +12,7 @@ PipDock's job is to run package managers against local environments. The realist - Package names are validated against the PEP 508 name grammar (`^[A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?$` after normalization) and version specs against PEP 440 before entering argv; anything else is rejected client-side with PD-PKG-002. - **The version half has been true only since 1.4.0.** Names always went through `PkgName`; versions were plain strings, so a dock-bay entry of `2.0 ; python_version<'0'` reached argv as one token pip read as a requirement whose marker is false — a silent no-op install. `pep440` is now the one place that says what a version and a specifier set may look like, and every way text arrives passes through it: install specs from either head, imported requirements, the IPC types that carry them, and the installed versions the guard set restates. - **Requirements and constraints reach an engine as files** (`-r `, `-c `) since 1.4.0: restating the installed set one argv entry per package (SP-1) passed Windows' 32,767-character command line at about 1,300 packages. The files hold exactly the tokens argv held — rendered `PinnedSpec`s and validated `Spec`s — and, like `probe.py` and the pins handed to pip-audit, each is an `exec::TempFile`: a fresh random name created with `create_new`, so an existing file is never written through, and deleted on drop. -- Interpreter paths come only from discovery (registry/launcher/uv/venv scan) or from a person — *Add interpreter…*, `pipdock env add`, `env use`, `--env`. **A path from a person goes through `envs::validate_interpreter` before anything runs it** (since 1.6.0; this line claimed it for two milestones while the only check was existence): it must be an existing file named `python.exe`, `python3.exe` or `python3.12.exe`, so the probe — which executes the file — cannot be pointed at another program; it must not be inside PipDock's own tools or audit venv, compared canonically so `..` cannot walk past; and it is stored canonical, without the verbatim prefix. Each refusal is PD-ENV-001. The picker that suggests a path is not the check: `env_add_manual` and a `manual` `env_probe` validate whatever the webview names. +- Interpreter paths come only from discovery (registry/launcher/uv/venv scan) or from a person — *Add interpreter…*, `pipdock env add`, `env use`, `--env`. **A path from a person goes through `envs::validate_interpreter` before anything runs it** (since 1.6.0; this line claimed it for two milestones while the only check was existence): it must be an existing file named `python.exe`, `python3.exe`, `python3.12.exe` or the free-threaded `python3.14t.exe`, so the probe — which executes the file — cannot be pointed at another program; it must not be inside PipDock's own tools or audit venv, compared canonically so `..` cannot walk past; and it is stored canonical, without the verbatim prefix. Each refusal is PD-ENV-001. The picker that suggests a path is not the check: `env_add_manual` and a `manual` `env_probe` validate whatever the webview names. - `probe.py` is stdlib-only, written to a temp file with a random name, executed with `-I` (isolated mode: ignores `PYTHONPATH`, user site) so a poisoned env cannot inject code into the probe — and with `-X utf8`, because `-I` implies `-E`, which also discards invariant 7's `PYTHONUTF8`/`PYTHONIOENCODING`: until 1.4.0 a venv under a folder named in Vietnamese crashed the probe. - **Owner decision 2026-07-27 (spike SP-6): `-I` stays, and the cost is disclosed rather than hidden.** Isolated mode also disables user site-packages, so on a *non-venv* system Python the probe sees fewer distributions than `pip list` does — measured at 352 vs 375 on the reference machine. Virtual environments, the primary target, have no user site and are unaffected. The probe therefore reports `hidden_user_site`: the user-site path when it exists, is off `sys.path`, and is non-empty; `null` otherwise. Only when it is non-null does the Installed screen show a note naming the path (`env.partialListing`), so the disclosure is accurate rather than a permanent disclaimer. Dropping to `-E` was rejected: a package in user site is part of the untrusted surface the isolation exists to exclude. - Child processes run with inherited user privileges only; PipDock never elevates in v1 (PD-PRM-001 blocks instead — elevation broker is P2 with its own review).