You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(e2e): cover fail-closed-on-RPC-loss for the authorized-origin gate #1374
kind:securitySecurity impact; report a vulnerability to [email protected], not herekind:testTest coverage, flakes, fixtures or the e2e harnessprio:mediumScheduledrustDependabot: a Cargo update; use area: labels for Rust code otherwise
ADR 037 §85 promises the authorized-origin gate has "the same fail-closed-on-RPC-unavailability behavior" as the rest of the chain-backed surface. ChainOriginDirectory documents per-namespace fail-close with a delta_remove_origin fallback and deferred re-read healing (crates/node/src/dht/chain_origin_directory.rs:72-82).
None of it is covered end to end. This is the one path where a bug means the node serves content nobody claimed — i.e. it fails open instead of closed — so it is worth an executable assertion rather than trust in the unit tests.
Sketch: bring up the G-NODE-08 shape, ratify, confirm a backend-only hash serves; then kill or stall the anvil RPC and assert a fresh backend-only hash in the same namespace is refused rather than served. Restoring the RPC should heal it.
Higher effort than the other e2e follow-ups because it needs RPC fault injection — ChainFixture currently has no way to pause or drop the anvil endpoint.
Investigated — this is a finding about the fail-close semantics, not a missing test
While implementing the fail-closed-on-RPC-loss e2e I traced the actual gate behavior, and the sketched assertion ("stall the anvil RPC → a fresh backend-only hash in the same [already-authorized] namespace is refused") tests a behavior that does not exist.
The gate's authorization check is entirely cache-backed, with no live RPC read:
pull_origin_gate_blocks → DirectoryCache::has_any → active_node_for reads only the cached origins_of_ns and operator_node maps (crates/node/src/dht/chain_origin_directory.rs:149-183).
Liveness is ChainStakerSet::is_active, which is self.proj.read(|s| s.contains(node_id)) (crates/node/src/dht/chain_staker_set.rs) — an in-memory projection, not a live read.
Neither cache is invalidated on a failed refresh.
So a warm namespace — one the node already resolved before the RPC went away — keeps serving its cached authorization through a transient outage. It favors availability and serves stale, healing on the watcher's next successful read. Stalling the RPC does not flip a warm namespace to refused.
The "fail-closed-on-RPC-loss" guarantee (ADR 022 §FIND_VALUE, ADR 037 §85) is the cold path: an empty or never-resolved directory resolves to "no authorized origin" → refused. That is already covered by unit tests — pull_origin_gate_decision and the EmptyOriginDirectory cases (the #1292 hazard) in crates/node/src/handlers/client/mod.rs and crates/node/src/dht/origin.rs.
A deterministic e2e for the RPC-loss angle is also impractical: SIGSTOP/SIGCONT on the anvil child (the state-preserving way to model an outage) freezes anvil for the fixture too, so no new chain state can be established mid-stall.
Resolution: documented the warm-vs-cold distinction in ADR 022 §FIND_VALUE (the fail-closed guarantee bounds what an unknown namespace resolves to, not how fast a known one reacts during an outage; the conservative direction is a lagging de-authorization, not an un-authorized origin admitted). Serving stale-authorized content during a transient blip is a defensible design for this gate.
Closing as a finding. If strict warm-cache freshness is actually wanted, that's a code change (a last-successful-refresh staleness bound on the origin directory / staker cache) with an availability tradeoff — worth a separate, explicitly-scoped issue rather than this one.
kind:securitySecurity impact; report a vulnerability to [email protected], not herekind:testTest coverage, flakes, fixtures or the e2e harnessprio:mediumScheduledrustDependabot: a Cargo update; use area: labels for Rust code otherwise
Activity
test(e2e): close soundness gaps in the G-NODE-08 wire-opacity scan
test(e2e): add G-NODE-08 authorized-origin recognition (opaque backen…
thiras commentedon Jul 24, 2026
Investigated — this is a finding about the fail-close semantics, not a missing test
While implementing the fail-closed-on-RPC-loss e2e I traced the actual gate behavior, and the sketched assertion ("stall the anvil RPC → a fresh backend-only hash in the same [already-authorized] namespace is refused") tests a behavior that does not exist.
The gate's authorization check is entirely cache-backed, with no live RPC read:
pull_origin_gate_blocks→DirectoryCache::has_any→active_node_forreads only the cachedorigins_of_nsandoperator_nodemaps (crates/node/src/dht/chain_origin_directory.rs:149-183).ChainStakerSet::is_active, which isself.proj.read(|s| s.contains(node_id))(crates/node/src/dht/chain_staker_set.rs) — an in-memory projection, not a live read.So a warm namespace — one the node already resolved before the RPC went away — keeps serving its cached authorization through a transient outage. It favors availability and serves stale, healing on the watcher's next successful read. Stalling the RPC does not flip a warm namespace to refused.
The "fail-closed-on-RPC-loss" guarantee (ADR 022 §FIND_VALUE, ADR 037 §85) is the cold path: an empty or never-resolved directory resolves to "no authorized origin" → refused. That is already covered by unit tests —
pull_origin_gate_decisionand theEmptyOriginDirectorycases (the #1292 hazard) incrates/node/src/handlers/client/mod.rsandcrates/node/src/dht/origin.rs.A deterministic e2e for the RPC-loss angle is also impractical: SIGSTOP/SIGCONT on the anvil child (the state-preserving way to model an outage) freezes anvil for the fixture too, so no new chain state can be established mid-stall.
Resolution: documented the warm-vs-cold distinction in ADR 022 §FIND_VALUE (the fail-closed guarantee bounds what an unknown namespace resolves to, not how fast a known one reacts during an outage; the conservative direction is a lagging de-authorization, not an un-authorized origin admitted). Serving stale-authorized content during a transient blip is a defensible design for this gate.
Closing as a finding. If strict warm-cache freshness is actually wanted, that's a code change (a last-successful-refresh staleness bound on the origin directory / staker cache) with an availability tradeoff — worth a separate, explicitly-scoped issue rather than this one.
fix: origin deny-set & authorized-origin gate correctness (#1398, #1368…