From fbfdb9312b4c5aa18ce4232ffd039451219874cd Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:49:40 -0700 Subject: [PATCH] fix(update): widen UV-env isolation to the sibling dependency-sync sites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The salvaged fix covered the git-path sync; the same raw-os.environ construction existed at the main update path and the interrupted-install recovery path. All three now build their uv env via managed_python_env() (#83914 class — same bug, all sites). A/B-proven with real uv: poisoned UV_PYTHON/UV_SYSTEM_PYTHON steers the merge-base construction into the hijacker's interpreter (VERDICT: HIJACKED); the managed construction installs into the install's venv (VERDICT: ISOLATED). Compose-checked with #92824's stale-VIRTUAL_ENV pin: isolation + pin together install into the running interpreter on the site-packages shape. --- hermes_cli/update_cmd.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py index e3e1580f1f..4bb78f9dab 100644 --- a/hermes_cli/update_cmd.py +++ b/hermes_cli/update_cmd.py @@ -1665,7 +1665,13 @@ def _update_via_zip(args, *, had_desktop_app_before_update: bool = False) -> boo if not uv_bin: uv_bin = _ensure_uv_for_termux(pip_cmd) if uv_bin: - uv_env = {**os.environ, "VIRTUAL_ENV": str(_m().PROJECT_ROOT / "venv")} + # Same third-party UV-env isolation as the main update path (#83914): + # a user-level UV_PYTHON_INSTALL_DIR / UV_PYTHON from unrelated + # software must not steer which interpreter uv resolves here. + from hermes_cli.managed_uv import managed_python_env + + uv_env = managed_python_env() + uv_env["VIRTUAL_ENV"] = str(_m().PROJECT_ROOT / "venv") if _m()._is_termux_env(uv_env): uv_env.pop("PYTHONPATH", None) uv_env.pop("PYTHONHOME", None) @@ -6300,7 +6306,12 @@ def _cmd_update_impl(args, gateway_mode: bool): check=False, ) if repair_uv: - repair_env = {**os.environ, "VIRTUAL_ENV": str(_m().PROJECT_ROOT / "venv")} + # Isolated from third-party UV env vars (#83914), same as + # the main-path and git-path dependency syncs. + from hermes_cli.managed_uv import managed_python_env + + repair_env = managed_python_env() + repair_env["VIRTUAL_ENV"] = str(_m().PROJECT_ROOT / "venv") _m()._install_python_dependencies_with_optional_fallback( [repair_uv, "pip"], env=repair_env, group="all" )