GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — uv projects whose env is set by UV_PROJECT_ENVIRONMENT are never probed: agent scan patches the PATH interpreter and uv tool envs instead, the real env stays vulnerable, and vex attests not_affected · Issue #525 · SocketDev/socket-patch

uv projects whose env is set by UV_PROJECT_ENVIRONMENT are never probed: agent scan patches the PATH interpreter and uv tool envs instead, the real env stays vulnerable, and vex attests not_affected #525

New issue
Copy link
New issue
Copy link
Closed
#540
Closed
uv projects whose env is set by UV_PROJECT_ENVIRONMENT are never probed: agent scan patches the PATH interpreter and uv tool envs instead, the real env stays vulnerable, and vex attests not_affected#525
#540
Copy link
Labels
agent:triagedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:uvuvuvpriority:p1

Description

@mikolalysenko
Mikola Lysenko (mikolalysenko)
opened on Oct 2, 2026
Issue body actions

[agent] Found by the scheduled uv bug-hunt routine (ledger #310).

Summary

uv lets a project put its environment somewhere other than ./.venv with UV_PROJECT_ENVIRONMENT (an absolute path, or a path relative to the project root). uv's own Docker and CI guides use it (UV_PROJECT_ENVIRONMENT=/opt/venv, .venv-ci, and so on), and uv sync / uv run then install into and run from that directory. socket-patch never reads the variable. find_local_venv_site_packages only probes VIRTUAL_ENV, Pipenv, Poetry, ./.venv and ./venv. So it finds no venv, and get_site_packages_paths falls through to get_global_python_site_packages() (the fallback #504 describes).

In agent mode, a plain socket-patch scan --mode agent (no -g) in such a project:

  • leaves the real uv env unpatched (uv run imports the vulnerable bytes);
  • patches six in the PATH interpreter's site-packages, plus every other global copy with a patch. In my run that included backports.tarfile inside an unrelated uv tool environment (~/.local/share/uv/tools/poetry), which the project doesn't depend on;
  • exits 0 with status: success, and socket-patch vex then attests pkg:pypi/[email protected] as not_affected for the project's product.

In hosted mode, the redirect_pypi_stale_install guard checks the wrong interpreter. A project whose real env still holds the upstream six gets no stale-install warning, while the same project with a plain .venv gets it. VEX was only saved from a false attestation because the system Python happened to have an unpatched six.

Impact

  • The environment the app actually runs in stays vulnerable, while the exit code and the VEX document both say it's fixed. That's a false attestation.
  • A project-scoped command modifies files outside the project, including other tools' uv tool envs and, as root in Docker, the OS Python.

Repro (Linux, uv 0.8.17; the variable is honored the same way by uv 0.5.31; main 61cfb9b)

# stand-in "global" interpreter on PATH with six 1.16.0
uv venv G && uv pip install --python G/bin/python six==1.16.0
mkdir app && cd app
cat > pyproject.toml <<'EOF'
[project]
name = "app"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = ["six==1.16.0", "idna==3.7"]
EOF
uv lock
export UV_PROJECT_ENVIRONMENT=.venv-ci      # or an absolute path such as /opt/venv
uv sync                                      # env lands in ./.venv-ci; there is no ./.venv
PATH=../G/bin:$PATH socket-patch scan --mode agent --yes $API   # exit 0, status success, scannedPackages 118
.venv-ci/bin/python -c "import six; print(getattr(six,'SOCKET_PATCHED',0))"   # 0  <- real env unpatched
../G/bin/python   -c "import six; print(getattr(six,'SOCKET_PATCHED',0))"     # 1  <- PATH interpreter patched
uv run --frozen python -c "import six; print(getattr(six,'SOCKET_PATCHED',0))" # 0
PATH=../G/bin:$PATH socket-patch vex $API -O vex.json             # exit 0: six not_affected for pkg:pypi/[email protected]

The patch API was a local mock serving a free six 1.16.0 patch (the patched six.py appends SOCKET_PATCHED = 1). The absolute-path form (UV_PROJECT_ENVIRONMENT=$TMP/envs/app) gave the same result: real env 0, PATH Python 1, vex not_affected. Each form ran on a fresh project, so it reproduced twice.

Expected vs actual

  • Expected: CLI_CONTRACT.md, "cwd-only (single project)": the crawler inspects only the project rooted at --cwd. For a uv project, that's the environment uv uses for it, which uv sync / uv run take from UV_PROJECT_ENVIRONMENT when it's set (relative paths resolve against the project root). Global installs are the -g / --global-prefix surface only. VEX must not attest a patch that isn't applied in the project's env.
  • Actual: the uv project env is ignored, global and uv-tool copies are patched, and VEX attests.

Cells (Linux)

Shape real env PATH interpreter / uv tool env exit vex
agent, UV_PROJECT_ENVIRONMENT=<abs> (uv 0.8.17) ❌ unpatched ❌ patched 0 ❌ not_affected
agent, UV_PROJECT_ENVIRONMENT=.venv-ci (uv 0.8.17) ❌ unpatched ❌ patched 0 ❌ not_affected
hosted, UV_PROJECT_ENVIRONMENT=<abs>, before re-sync stale, no redirect_pypi_stale_install – 0 omitted (only because system six is unpatched)
control: default ./.venv (hosted) stale-install warning fires – 0 omitted ✅

Untested: macOS and Windows (the probe order is the same code path), and a stray ./.venv next to a UV_PROJECT_ENVIRONMENT env. I'd expect the wrong one to be patched there too.

Related

  • Agent-mode scan in a Pipenv project without a Pipenv venv patches the system Python's site-packages in place instead of the project's venv/ (regression from #388) #504 (Pipenv), Poetry with virtualenvs.in-project = true but no ./.venv keeps using its out-of-tree env, which socket-patch never probes: agent patches the global interpreter and hosted VEX falsely attests #476 (Poetry) and Agent and hosted mode ignore the interpreter PDM records in .pdm-python (venv.in_project = false, pdm use <venv>), so the real env is skipped or a stray .venv / the PATH python is patched, and VEX attests an unpatched install #502 (PDM) are the same class: a project env the tool uses but socket-patch doesn't probe, plus the non--g global fallback. This issue is the uv-specific missing probe. Fixing Agent-mode scan in a Pipenv project without a Pipenv venv patches the system Python's site-packages in place instead of the project's venv/ (regression from #388) #504's fallback alone would turn the uv case into "nothing patched, exit 0", and the real env would still be missed.

Suspect code

  • crates/socket-patch-core/src/crawlers/python_crawler.rs:381-385: the generic probe only tries <cwd>/.venv and <cwd>/venv. There's no UV_PROJECT_ENVIRONMENT arm, which needs to be resolved relative to the uv project root.
  • crates/socket-patch-core/src/crawlers/python_crawler.rs:1719-1724: the is_python_project → global fallback (see Agent-mode scan in a Pipenv project without a Pipenv venv patches the system Python's site-packages in place instead of the project's venv/ (regression from #388) #504).

Activity

  1. Mikola Lysenko (mikolalysenko)
    added
    bugSomething isn't workingSomething isn't working
    bughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agent
    pm:uvuvuv
    on Oct 2, 2026
  2. mikolalysenko commented on Oct 2, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 2, 2026
    CollaboratorAuthor
    More actions

    [agent] Triaged as priority:p1 (uv). Confirmed on main 61cfb9b: nothing under crates/ reads UV_PROJECT_ENVIRONMENT, and find_local_venv_site_packages_with only probes VIRTUAL_ENV, Pipenv, Poetry, ./.venv and ./venv. The global-interpreter fallback that then patches the wrong copy is the same one #504 reports for Pipenv, but the missing uv env lookup is a separate defect, so these aren't clustered. No open PR.


    Generated by Claude Code

  3. Mikola Lysenko (mikolalysenko)
    added
    agent:triaged
    priority:p1
    on Oct 2, 2026
  4. mikolalysenko commented on Oct 2, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 2, 2026
    CollaboratorAuthor
    More actions

    [agent] Claiming this issue (with #502, #528; shared root cause: find_local_venv_site_packages never resolves the env the project's package manager records (PDM .pdm-python / __pypackages__, uv UV_PROJECT_ENVIRONMENT), so discovery falls through to ./.venv or the PATH interpreter). Branch: agent/fix-python-manager-project-env. Claim-ID: 2026-10-02T07:21:09Z-11e135


    Generated by Claude Code

  5. Mikola Lysenko (mikolalysenko)
    added
    agent:claimed
    on Oct 2, 2026
  6. mikolalysenko commented on Oct 2, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 2, 2026
    CollaboratorAuthor
    More actions

    [agent] Fix in progress: #540


    Generated by Claude Code

  7. Mikola Lysenko (mikolalysenko)
    added 2 commits that reference this issue on Oct 2, 2026

    Find the env uv and PDM install a project into

    1883c61

    Fix Python env discovery ignoring uv/PDM env (#502, #525, #528) (#540)

    b0a32db
  8. Mikola Lysenko (mikolalysenko)
    closed this as completedin #540on Oct 2, 2026
  9. Mikola Lysenko (mikolalysenko)
    removed
    agent:claimed
    on Oct 2, 2026
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

    agent:triagedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:uvuvuvpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.