Skip to content

🐛 fix(uv): limit home lookup to supplied env - #236

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/issue200-mapped-home
Nov 3, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/issue200-mapped-home

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

When a caller supplied an environment mapping without HOME or USERPROFILE, uv store discovery substituted ~ and expanded it from the process environment. Discovery could then execute a candidate in that process home even though the caller's mapping did not name the directory. Default uv roots now come only from the supplied mapping. This addresses draft advisory ANT-2026-XQVCZ8E5.

The home fallback escaped the mapping

Path.expanduser() resolves ~ to the process user's home. The old fallback used it when the mapping lacked a home variable, then probed executables under the resulting uv roots. The new selection skips home-derived roots when the mapping has no home variable.

flowchart LR
    M[Mapped home absent] --> O[Old: expand process home]
    O --> P[Probe process-home uv store]
    M --> N[New: skip home-derived roots]
    M --> D[Mapped data directory present]
    D --> R[Probe mapped uv store]
    classDef old fill:#ffd6d6,stroke:#c1121f,color:#5c0000;
    classDef fixed fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332;
    class O,P old;
    class N,D,R fixed;
Loading

Platform directory selection

uv uses platform data directories for managed Python installs. Windows still accepts an absolute mapped APPDATA; macOS and Linux still accept an absolute mapped XDG_DATA_HOME. The Windows profile default requires mapped USERPROFILE; Unix home defaults require mapped HOME. The platform branches use those values.

Behavior changes

An explicit mapping with only PATH no longer searches the process home for uv-managed interpreters. Calls that omit env still use the process environment as their mapping. An explicit UV_PYTHON_INSTALL_DIR still selects its own root. Fixes #200.

Reported by Anthropic's OSS Scanner: ANT-2026-XQVCZ8E5.

An explicit environment mapping must bound interpreter discovery. The
process-home fallback could probe and execute a uv-managed interpreter
outside that mapping.

Use mapped home and data-directory values for default uv roots. Correct
the Windows order test to plant an interpreter in the Windows uv store.

Fixes tox-dev#200.
@gaborbernat gaborbernat added bug Something isn't working security Security fixes and advisories labels Nov 3, 2026
@gaborbernat
gaborbernat merged commit 49356fe into tox-dev:main Nov 3, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security fixes and advisories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv lookup reads process HOME outside supplied environment

1 participant