Repository navigation
fix(wpm): reject cached-index source injection + index hash ledger; loopback proxy fallback opt-in (issues #1176 #1177) - #1179
Merged
Conversation
…back proxy fallback opt-in (issues #1176, #1177) #1176 (P1): merged_sources folded sources declared inside the CACHED index into the candidate set, so one poisoned fetch persistently injected new download locations whose artifacts self-consistently passed the index's own sha256 checks. Candidate sources are now the built-in registry plus user_sources only; mirrors must come from the user (wpm source add / config) or the shipped built-in registry. update_index additionally keeps a supply-chain ledger: last_success_source (already recorded) plus the SHA-256 of the persisted index (last_index_sha256), prints a warning when the index content changes while being served from a non-preferred source, and the --json payload carries index_sha256. #1177 (P2): after a direct-connection failure wpm probed loopback proxy ports 127.0.0.1:7897/7890/7891/7892/7893/10808/10809 by default; any unprivileged local process listening there could serve both index and artifacts. The probe is now opt-in via allow_loopback_fallback=true in .wpm/config.json (default false); http_get lost its default-on argument so every call site states the policy explicitly. --proxy and proxy environment variables remain the trusted paths and are unchanged. Compatibility: explicitly configured user_sources / preferred_source / --proxy / region=cn auto-selection all keep working (ordering and fallback semantics untouched; only cache-declared sources stopped being trusted). Regression tests (tests/unit/wpm): self-consistent poisoned cache index rejected end-to-end (source list, index update, install), ledger + warning on non-preferred content change + quiet same-hash refresh, index_sha256 in the --json payload, loopback probing absent by default and present when opted in. wpm group: 58/58 pass. Note: per AGENTS.md the new i18n keys (command.wpm.warn.index_changed_nonpreferred) need a follow-up catalog sync in unixwin/winuxcmd-i18n; English fallbacks land here first.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…on (#1180) - seq: 64 KiB chunked stdout + integral to_chars fast path, measured 332ms -> ~45ms on 100k lines, byte stream unchanged (#1173). - du, sed: POSIX drive-form operands resolve through the shared operand boundary like grep/wc/head/find (#1174). - Retitle [Unreleased] to [1.1.7] (date slot left for the release commit). The #1176/#1177 wpm supply-chain entries were already recorded by #1179 itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1176
Closes #1177
#1176 (P1) — cached-index sources no longer trusted, index ledger added
merged_sourcesfolded thesourcesarray declared inside the cached index into the candidate set (wpm.cpp:318-352), so one poisoned fetch persistently injected new download locations; the injected index also carries the artifactsha256values, so the poison was fully self-consistent. Candidate sources are now the built-in registry +user_sourcesonly (merged_sources(root), wpm.cpp:318-338); new mirrors must come from the user (wpm source add/ config) or the shipped built-in registry.wpm index updateadditionally keeps a supply-chain ledger (wpm.cpp:3336-3361):last_success_source(existing) andlast_index_sha256— SHA-256 of the persisted index — in.wpm/config.json;command.wpm.warn.index_changed_nonpreferred, new i18n key, English fallback in source; catalog sync inunixwin/winuxcmd-i18nis a follow-up per fix(wpm): interaction audit fixes - outdated receipt anchoring, install --json, help force semantics (#1156) #1158 precedent);wpm index update --jsonpayload carriesindex_sha256.#1177 (P2) — loopback proxy fallback is opt-in
After a direct-connection failure wpm probed
127.0.0.1:7897/7890/7891/7892/7893/10808/10809by default (wpm.cpp:1228-1240/1325-1341); an unprivileged local process listening there could serve both index and artifacts past the index's own sha256 checks. Now:loopback_fallback_allowed(root)readsallow_loopback_fallbackfrom.wpm/config.json, default false (wpm.cpp:1229-1239);http_getlost its silent default-on argument — every call site (artifact download, manifest fetch, index fetch) states the policy explicitly;--proxy/ proxy env vars remain the trusted paths, semantics unchanged.Compatibility matrix
wpm source add/user_sourcesmirrorspreferred_sourcepin /--source/wpm source useregion=cnauto selection + probe--proxy/ env proxy usersallow_loopback_fallback: trueTests (tests/unit/wpm, 58/58 pass; 4 new)
wpm_rejects_sources_declared_in_cached_index— self-consistent poison (index + matching artifact sha256 overfile://, offline) smuggled only via the cached index:source listexcludes it,index updatefetches from the legitimate source,install evil-toolexits 1 and nothing lands inusr/bin.wpm_index_update_records_hash_and_warns_on_nonpreferred_change— ledger seeded on first update; preferred source dies, mirror serves changed content → warning + new hash +last_success_source; same-hash refresh stays quiet.wpm_index_update_json_records_index_sha256— 64-hexindex_sha256in the--jsonpayload.wpm_loopback_proxy_fallback_off_by_default_opt_in_via_config— dead artifact URL: default output contains noloopback proxytrace; withallow_loopback_fallback: truethe probe trace appears.Verified:
scripts/build-with-vs.ps1(Debug, x64) builds clean;ctest -R wpm58/58; clang-format run over the tree (only this PR's files carry changes). CHANGELOG +DOCS/en/wpm_guide.mdupdated.