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 — In a PDM `__pypackages__` (PEP 582) project, hosted mode gives no stale-install warning and `vex` attests not_affected while the copy `pdm run` imports is still unpatched · Issue #528 · SocketDev/socket-patch

In a PDM __pypackages__ (PEP 582) project, hosted mode gives no stale-install warning and vex attests not_affected while the copy pdm run imports is still unpatched #528

New issue
Copy link
New issue
Copy link
Closed
#540
Closed
In a PDM __pypackages__ (PEP 582) project, hosted mode gives no stale-install warning and vex attests not_affected while the copy pdm run imports is still unpatched#528
#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:pdmPDMPDMpriority:p1

Description

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

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

Summary

docs/testing/pdm-compatibility.md:72-76 says __pypackages__ (PEP 582) projects aren't covered by agent or vendored mode, and tells users to "Run PDM with python.use_venv on, or use hosted mode." On that recommended hosted path, socket-patch never looks at __pypackages__/<py>/lib. After scan --mode hosted rewrites pdm.lock, the stale-install check therefore doesn't fire, and socket-patch vex attests the patch (not_affected / inline_mitigations_already_exist, exit 0), even though the copy PDM imports from __pypackages__ still holds upstream bytes.

The in-project .venv control behaves correctly: the "installed files … still differ from the patched hashes" warning fires, and vex omits the package (not_applied, exit 1).

The opposite direction also goes wrong. If the PATH interpreter happens to have the same release installed (here /usr/local/lib/python3.11/dist-packages/urllib3 1.26.18), vex checks that copy instead. So after a correct pdm sync that put the patched wheel into __pypackages__, it omits the patch as not_applied (exit 1).

Impact

A CI gate on socket-patch vex passes, and the VEX document says the CVE is mitigated, for a PEP 582 project that never reinstalled. Users can miss the reinstall because the stale-install warning they'd normally see doesn't print. PEP 582 is the default layout on PDM 0.x/1.x, and on 2.x under python.use_venv = false.

Repro (Linux, real PDM, local mock of the patch API serving a real patched urllib3 wheel)

cat > pyproject.toml <<'EOF'
[project]
name = "demo"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = ["urllib3==1.26.17"]
EOF
pdm config -l python.use_venv false
mkdir __pypackages__
pdm use -f /usr/bin/python3.11          # .pdm-python -> /usr/bin/python3.11 (has no urllib3 1.26.17)
pdm lock && pdm sync                    # upstream urllib3 -> __pypackages__/3.11/lib
socket-patch scan --mode hosted --yes   # pdm.lock -> hosted url + patched sha256; NO "still differ" warning
socket-patch vex -O vex.json            # exit 0, 1 statement: not_affected / inline_mitigations_already_exist
pdm run python -c "import urllib3; print(urllib3.__file__, getattr(urllib3, 'SOCKET_PATCHED', 'UPSTREAM'))"
# .../__pypackages__/3.11/lib/urllib3/__init__.py UPSTREAM

Control: the same steps without use_venv false / __pypackages__ (in-project .venv) print the stale-install warning, and vex exits 1 with not_applied.

Expected vs actual

  • Expected: the hosted stale-install check and vex verify the environment PDM actually installs into. In VEX terms, CLI_CONTRACT.md says vex attests from the hosted references "and the installed files", and the routine's bar is that a VEX attestation for a patch that isn't applied is a bug. At minimum, a PEP 582 project should get the same not_applied omission and stale-install warning a .venv gets, or vex should refuse to attest an install it can't locate rather than treat the lock as proof.
  • Actual: no warning, and not_affected is attested over unpatched installed bytes. When the PATH interpreter has its own copy, the verdict comes from that unrelated copy instead.

Matrix (Linux; 2 of 2 fresh runs per cell, main 61cfb9b)

PDM layout stale-install warning vex installed copy
2.29.2 __pypackages__ none exit 0, not_affected upstream
2.29.2 .venv (control) yes exit 1, omitted not_applied upstream
2.12.4 __pypackages__ none exit 0, not_affected upstream
2.12.4 .venv (control) yes exit 1, omitted not_applied upstream
2.29.2 __pypackages__, after pdm sync (patched), PATH python has upstream 1.26.18 — exit 1, not_applied (false negative) patched

macOS and Windows weren't run. The discovery code has no OS-specific branch for this. Not bisected: v4.0.0 hosted VEX has different (ledger-based) semantics, so it isn't a like-for-like comparison.

Suspect code

  • crates/socket-patch-core/src/crawlers/python_crawler.rs:329 (find_local_venv_site_packages) and :1709 (get_site_packages_paths): there's no __pypackages__/<X.Y>/lib probe, so a PDM PEP 582 project falls through to is_python_project → the global / PATH interpreter.
  • crates/socket-patch-cli/src/commands/scan/hosted/python.rs:136: the stale-install warning uses the same discovery.
  • Related but distinct: 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 (the interpreter recorded in .pdm-python / .pdm.toml is ignored). Its fix wouldn't cover this, because in PEP 582 mode .pdm-python names the base interpreter (/usr/bin/python3.11), while packages live in __pypackages__. Same symptom family as 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 / Hosted Hatch rewrite leaves an existing Hatch environment unpatched with no stale-install warning, and vex still attests not_affected #335 / In a --system-site-packages venv, pip keeps the base interpreter's unpatched copy after a hosted rewrite, no stale-install warning fires, and vex attests it as patched #409.

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:pdmPDMPDM
    on Oct 2, 2026
  2. Mikola Lysenko (mikolalysenko)
    added a commit that references this issue on Oct 2, 2026

    pdm: 2026-10-02 bug-hunt run (#528, #502/#451 comments)

    912f37b
  3. mikolalysenko commented on Oct 2, 2026

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

    [agent] Triaged as priority:p1 (PDM). I checked this on main 61cfb9b. crates/socket-patch-core/src/crawlers/python_crawler.rs never probes __pypackages__/<X.Y>/lib: there's no match for __pypackages__ anywhere in the crawler. So a PEP 582 project falls through to the PATH interpreter, and that discovery path also feeds the hosted stale-install check and vex. Not a duplicate. Related to #502 (the .pdm-python interpreter is ignored) but a separate fix, as the report notes. No open fix PR.


    Generated by Claude Code

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

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

    [agent] Claiming this issue (with #502, #525; 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

  6. Mikola Lysenko (mikolalysenko)
    added
    agent:claimed
    on Oct 2, 2026
  7. 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

  8. Mikola Lysenko (mikolalysenko)
    added a commit that references this issue on Oct 2, 2026

    Find the env uv and PDM install a project into

    1883c61
  9. mikolalysenko commented on Oct 2, 2026

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

    [agent] PDM bug-hunt re-triage: I tested PR #540 (head 60dfb81) with real PDM against a local mock of the patch API, and it fixes this issue. Main 61cfb9b still reproduces it.

    Setup: PEP 582 project (python.use_venv false, pdm use -f /usr/bin/python3.12, pdm lock && pdm sync), so upstream urllib3 1.26.18 sits in __pypackages__/3.12/lib. Then scan --mode hosted -y, vex, pdm sync, vex again.

    PDM build stale-install warning vex before reinstall vex after pdm sync (patched)
    2.29.2 main 61cfb9b none exit 0, not_affected (wrong) exit 0, not_affected
    2.29.2 PR #540 printed exit 1, omitted exit 0, not_affected
    2.12.4 main 61cfb9b none exit 0, not_affected (wrong) exit 0, not_affected
    2.12.4 PR #540 printed exit 1, omitted exit 0, not_affected

    The PATH interpreter (/usr/local/bin/python3) has no urllib3 1.26.18 in this container, so I couldn't re-check the false-negative variant from the report here. Leaving this open until #540 merges.


    Generated by Claude Code

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

    Merge Bugbot autofix, keeping the use_venv-aware fix

    2b5c881

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

    b0a32db
  11. Mikola Lysenko (mikolalysenko)
    closed this as completedin #540on Oct 2, 2026
  12. 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:pdmPDMPDMpriority: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.