fix(rpc): gate JSON-RPC dispatch landing legs on request provenance (#1956) - #147
Merged
Merged
Conversation
…ance (#1956) WIP anchor: thread RequestProvenance through dispatch/handle_rpc and fold land_origin at the four getContent/fetchRange landing sites. Tests + Cargo.lock follow. Salvage push before build. Co-Authored-By: Claude <noreply@anthropic.com>
…nce (#1956) The POST / JSON-RPC dig.getContent/dig.fetchRange landing legs gated only on the transport-axis ReadOrigin, not the #1654 Sec-Fetch-Site provenance axis, so a SAME-ORIGIN capsule page could POST dig.getContent and drive capsule landing (warm/backfill/reshare) — the CSRF door the /s/ serve gate already closes. Thread RequestProvenance through RpcDispatch::dispatch, handle_rpc, and handle_rpc_json (a required arg, fail-safe like origin). server.rs's POST handler classifies Sec-Fetch-Site via the existing provenance_for and passes it through; all trusted/non-browser callers pass FirstParty. Move landing_origin beside ReadOrigin/RequestProvenance in download.rs as the one shared fold, and apply it at ALL FOUR landing sites (range_miss_envelope + maybe_backfill_capsule in fetchRange; content_miss_envelope + maybe_backfill_capsule in getContent) so the reshare leg is closed too. Reads are never altered — bytes serve identically. Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
force-pushed
the
fix/1956-provenance-dispatch-landing
branch
from
August 2, 2026 17:08
69f5bde to
8ddcb85
Compare
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.
What changed
Closes DIG-Network/dig_ecosystem#1956.
The
POST /JSON-RPCdig.getContent/dig.fetchRangelanding legs (the implicit warm/backfill/reshare-on-miss that makes this node a discoverable DHT holder) gated only on the transport-axisReadOrigin, not theSec-Fetch-Siterequest-provenance axis that #1654 added to the/s/serve path. So a same-origin capsule page couldPOST dig.getContentand drive landing of arbitrary (chain-anchored) capsules — the CSRF door the/s/gate already closes, left open on the JSON-RPC path. (Bounded by #1623's chain-anchored verify — no fabrication — and not cross-site-reachable, since a cross-site POST is blocked by CORS + theapplication/jsonpreflight; this is the same-origin defense-in-depth follow-up from the #1654 audit.)The fix — one shared provenance fold, applied to the POST landing legs too
Option A (mirrors the shipped #1654
serve_content_plaintextpattern):originstays the transport axis; a newprovenanceaxis is threaded in and folded to aland_originused only for the landing side-effects. The read path is untouched — a cross-site POST still serves the bytes; only the durable warm/backfill/reshare/announce is withheld.landing_originis now the single shared fold — moved fromcontent_serve.rs(module-private) todownload.rsaspub(crate), besideReadOrigin/RequestProvenance/from_sec_fetch_site. Both the/s/path (#1654) and the JSON-RPC path (#1956) use it.provenance: RequestProvenancethreaded throughRpcDispatch::dispatch/handle_rpc/handle_rpc_json(a required arg, matching theoriginphilosophy — fail-safe, no defaulting).server.rsPOST /handler now classifiesSec-Fetch-Sitevia the existingprovenance_for(&headers)and passes it in — without this the gate would be a no-op (constantFirstParty).maybe_backfill_capsulecalls:range_miss_envelope+maybe_backfill(FetchRange) andcontent_miss_envelope+maybe_backfill(GetContent) — closing the miss-envelope→fetch_resource→spawn_capsule_reshareleg as well.FirstParty(control.rs,peer.rspeer-wire —landing_origin(Peer, FirstParty)==Peer, so peers still never land — the dig-runtime FFI, and the test callers): behaviour for every pre-existing caller is unchanged; only the browser-facing HTTP POST now classifies cross-site and withholds landing.SPEC.md §21.8extended to cover the JSON-RPC POST read methods + the shared fold (complements §21.9's token-gate on the explicitcache.fetchAndCache).Verification
New tests (each RED if any
land_originfold is dropped):cross_site_post_getcontent_serves_but_does_not_land,cross_site_post_fetchrange_serves_but_does_not_land,first_party_post_getcontent_still_lands,peer_transport_post_getcontent_unaffected,read_bytes_identical_regardless_of_provenance(dig-node-core),provenance_is_read_on_the_post_path(dig-node-service). The #1654/s/landing_originserve tests + the #1623 verify + #1614 single-flight tests remain green.cargo test -p dig-node-core→ 517 passed; the only 9 failures are the known local-only network-bind env tests (#1961), unrelated.cargo fmt --all -- --check→ 0 ·cargo clippy -p dig-node-core -p dig-node-service --all-targets --all-features -- -D warnings→ clean ·Cargo.lockupdated + committed.Version
fix:(security defense-in-depth; no wire/contract shape change — bytes served identically, all callers in-repo) →[workspace.package].version0.75.5 → 0.75.6. No SYSTEM.md/docs change (internal behaviour).Generated by Claude Code