Skip to content

vex --no-verify attests a vendored NuGet or Bun package whose lock pins other bytes, and a stale NuGet pin is pinned again only with the patch service reachable #2455

Backlog

Description

[agent] Found by the architecture refactor routine while fixing #2381 (PR #2453), on that PR's branch at 2e5af57 over main at 2440352. Lead L145. The first point is on main for Bun's lock as well.

The problem

#2453 makes vendor --check and vex read the content pin of a NuGet lock, as they already read Bun's: a lock that pins other bytes than the committed vendored artifact does not install it. Three places still do not agree with that rule.

1. vex --no-verify attests a package whose lock pins other bytes

The contract says of --no-verify: "verified against on-disk state (unless --vex-no-verify; the wiring gates apply either way)". It calls a pin mismatch a wiring failure ("vendor --check reports the same as a wiring failure"). The pin is compared in the verification step (core vex/verify.rs, the lock_pin_mismatch arms), which --no-verify skips, and not in the wiring gates.

The real .NET SDK 8, the tree dotnet restore --force-evaluate leaves (the lock on the upstream contentHash, nuget.config and the vendored nupkg as vendored, the app loading the upstream assembly), the binary of #2453:

$ socket-patch vex --product pkg:nuget/app@1.0.0
Warning: omitting pkg:nuget/Fx.Alpha@1.0.0 from VEX: the lockfile pins the vendored artifact to a sha512 that is not that file's, so an install does not deliver it; re-run socket-patch scan --mode vendored (vendor_lock_pin_mismatch)
Error: No applied patches with vulnerability metadata to attest.
[exit 1]

$ socket-patch vex --product pkg:nuget/app@1.0.0 --no-verify
Warning: 1 of 1 VEX statement was emitted without on-disk verification of the patch […]
Wrote OpenVEX document with 1 statement            # "status": "not_affected"
[exit 0]

apply --vex, scan --vex and vendor --vex with --vex-no-verify go the same way. For Bun the same holds on main (read, and run for NuGet only): the Bun arm is in the same skipped step.

2. The run that pins a stale lock again needs the patch service, though the committed nupkg is intact

On that tree the committed nupkg holds the patch and only the lock's hash is stale. The re-vendor takes the path of a missing or stale artifact: it asks the patch service for the nupkg again, and only then pins the lock.

$ SOCKET_OFFLINE=1 socket-patch vendor
Error: Cannot vendor pkg:nuget/Fx.Alpha@1.0.0: --vendor-source=service needs the network but --offline is set
Vendored 0 packages; 1 failed.
[exit 1]                                           # the lock still holds the upstream hash

With the service unreachable it fails the same way ("patch service request failed"). The writer has the sha512 of the committed bytes in hand at that point (core vendor/nuget_feed.rs, nuget_prelude: pin_stale), and could pin from it. The open point is the warning: that run reports vendor_artifact_rebuilt today, which would no longer be true, and vendor_artifact_reused ("re-wired as-is, no service download, no rebuild") is the contract's code for PyPI only.

3. Read, not run

  • scan --mode vendored --dry-run and get --mode vendored --dry-run say already_vendored from the ledger's uuid alone (CLI commands/scan/vendor_flow.rs, the preview's AlreadyVendored arm), where the wet run pins the lock again. Stop verifying and attesting a vendored NuGet package whose lock pins other bytes #2453 fixed the same answer for vendor --dry-run.
  • One lock whose target frameworks pin different hashes for the package (a hand-resolved merge; dotnet does not write one) is reported by vendor --check as "wiring missing … re-run socket-patch vendor to rewire it". The config still names the feed, and the re-run fails on "conflicting contentHash values". Run at the writer: the re-vendor fails and the lock is unchanged.
  • The "wiring missing … re-run socket-patch vendor" text of vendor --check names a command that does nothing in a project with no .socket/manifest.json (what scan --mode vendored leaves): it exits 0 with "No manifest to vendor from". Every ecosystem's unwired state lands on that text.

Planned fix

  1. Judge the pin where the wiring gates are, so that --no-verify reads it, for Bun and NuGet alike; a CLI test for each.
  2. When only the pin is stale, pin from the committed nupkg with no download; a maintainer's word on the warning code would help.
  3. Run the three read-only points before changing them.

Not run: Bun under --no-verify, SDK 10, Windows and macOS.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Dec 2, 2026
  2. added a commit that references this issue on Dec 2, 2026
  3. mikolalysenko commented on Dec 5, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] The third "read, not run" point above is now run, on main at cd7c5c5, and it is wider than the one message. Lead L259 of the architecture refactor routine.

    What happens

    In a project vendored by scan --mode vendored or get --mode vendored there is no .socket/manifest.json (the contract: "every scan/get --mode vendored … project is manifest-less"). When such a project loses its lock wiring, every command the CLI names to put it back exits 0 and changes nothing:

    $ socket-patch scan --mode vendored --yes          # uv 0.11.32, three packages; .socket/vendor/ only
    $ socket-patch rollback --preserve-state --yes
    Unwired vendoring for pkg:pypi/idna@3.7 (artifact preserved)
    Unwired vendoring for pkg:pypi/packaging@24.0 (artifact preserved)
    Unwired vendoring for pkg:pypi/six@1.16.0 (artifact preserved)
    
    Manifest entries and vendored artifacts preserved (--preserve-state); re-apply with `socket-patch apply` or `socket-patch vendor`.
    [exit 0]
    
    $ socket-patch vendor --check
    pkg:pypi/idna@3.7: wiring missing: no lockfile or config references .socket/vendor/pypi/d076329e-… any more, so a fresh install gets the unpatched package; re-run `socket-patch vendor` to rewire it
    (the same line for packaging and six)
    [exit 1]
    
    $ socket-patch apply
    No patch manifest found; nothing to apply.
    [exit 0]
    
    $ socket-patch vendor
    No manifest to vendor from; 3 vendored entries are tracked in the ledger — `socket-patch repair` verifies them.
    [exit 0]                                           # --json: "status": "noManifest", no warning
    
    $ socket-patch repair
    No manifest; no patch artifacts to download.
    
    Repair complete.
    [exit 0]
    
    $ socket-patch vendor --check                      # unchanged: three "wiring missing" lines
    [exit 1]
    

    uv.lock and pyproject.toml are the pre-vendor files throughout. The one command that wires the three packages again is socket-patch scan --mode vendored, which no line above names, and which needs the patch service although the artifacts and the ledger's embedded records are on disk:

    $ socket-patch scan --mode vendored --yes --offline
    Error: scan requires network access to query the patch API and cannot run with --offline/SOCKET_OFFLINE (strict airgap)
    [exit 1]
    

    So --preserve-state keeps, in a vendored project, a state that nothing can re-apply offline, and its closing line names two commands that do not re-apply it. That line also says "Manifest entries … preserved" in a project that has no manifest (format_preserved_note(manifest_scope.len(), …) is called with 0).

    repair's part is true as written: it does check the artifacts' bytes, and downloads one again after I appended a byte to a vendored wheel. It does not look at the wiring.

    It does not need --preserve-state

    The unwired state is what an ordinary re-lock leaves. Both of these give the pre-vendor lock byte for byte, and then the same exchange:

    • Poetry 2.4.3: poetry lock --regenerate (a plain poetry lock keeps the wiring).
    • npm 10.9.9: rm package-lock.json && npm install --package-lock-only. The npm text is another one: vendored wiring drifted: package-lock.json node_modules/ms still resolve ms@2.0.0 outside the vendored artifact, so that copy installs unpatched; re-run socket-patch vendor to rewire every copy.
    $ socket-patch vendor --check                      # [exit 1], "re-run `socket-patch vendor`"
    $ socket-patch vendor
    No manifest to vendor from; 2 vendored entries are tracked in the ledger — `socket-patch repair` verifies them.
    [exit 0]
    $ socket-patch vendor --check                      # [exit 1], unchanged
    

    vex is right in each of these states: it omits the unwired packages (vendor_unwired) and exits 1 when none is left. A CI step that runs socket-patch vendor to keep the wiring in place passes while the lock installs the registry packages.

    Run on uv, Poetry, PDM 2.25.9 (lock 4.5.0), Pipenv and npm for the --preserve-state route (the same six exit codes and an unchanged tree in each), and on Poetry and npm for the re-lock route, with a stand-in patch API that serves real patched wheels and tarballs. remove <purl> --preserve-state unwires the same way and prints no closing note in such a project (run on uv).

    Where

    • vendor --check, every ecosystem: commands/vendor.rs L692-L695, and the half-unwound uv text above it (L682-L689).
    • npm's drift text: vendor/npm_lock.rs L1038-L1041.
    • The --preserve-state note of rollback (remove shares it for a project with a manifest): commands/rollback.rs L592-L610.
    • The no-manifest line of vendor: commands/vendor.rs L3018-L3029. Its doc comment already says of these projects that "their refresh path is scan --mode vendored".
    • CLI_CONTRACT.md, the --preserve-state section: "vendor re-runs re-wire them", and under remove: "a re-vendor re-wires from the live lock probe".
    • By grep, 26 message lines in 13 files name socket-patch vendor as the command to run again (vendor/verify.rs, vex/discover/npm.rs, vex/discover/cargo.rs, vendor/maven_repo.rs, vendor/jvm/gradle.rs, vendor/cargo.rs, vex.rs, vex_sources.rs, and others). Some of them are for a project that has a manifest, where the command is right. Two already name both commands: the pnpm 11 text of Keep a vendored pnpm patch when pnpm 11.0.0 to 11.0.2 rewrite its lock entry without the tarball #2434 and NO_FILE_INVENTORY in vendor/redownload.rs.

    The order of the changes explains it. The contract sentence dates from the change that added --preserve-state (d5e1815, 2026-08-28), when a vendored project had a manifest. Vendored mode became manifest-free in 09956d9 (2026-09-23), which gave vendor its "tracked in the ledger" line. The "wiring missing" text came after that, in b194fa1 (2026-10-05, #725), and names vendor all the same.

    #2275 is the same loop for a ledger that cannot be read.

    Planned fix

    1. One helper that names the command for the entry at hand: socket-patch scan --mode vendored for a ledger entry with no manifest record, socket-patch vendor for one that has a record. vendor --check, the vex warnings, the --preserve-state note and vendor's no-manifest line take their wording from it. The note stops naming manifest entries and apply when the manifest holds none.
    2. The two contract sentences say which command re-wires which project.
    3. A CLI test per route: a manifest-less vendored project, rollback --preserve-state, then each command a message names must either re-wire or not be named.

    That is a change of message text only. The other reading of the contract sentence is that plain vendor should re-wire a manifest-less project from the ledger's embedded records and the committed artifacts, with no network. That would make --preserve-state useful offline, and it is a larger change that I would not make without a maintainer's word.

    Not run: Cargo, Go, gem, Composer, NuGet and the JVM backends (the vendor --check text is shared; their own texts were read only); a project that has both a manifest and ledger-only entries; Windows and macOS.


    Generated by Claude Code

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:triagedarch-auditbugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions