Repository navigation
fix: batch of six quick-win MEDIUM bug fixes (#841 #842 #843 #861 #862 #863) - #865
Conversation
The schema's stated policy is that operator typos fail at load, and the cache/origin/DHT/receipts structs already set `deny_unknown_fields`. But `FileConfig` and seven section structs did not, so a typo'd whole-section header like `[netork]` or a key like `slash_judge_addres` was silently dropped — the node then ran with wrong defaults for security-relevant knobs or failed later with a confusing "missing required" error. Add `#[serde(deny_unknown_fields)]` to `FileConfig` and the `Network`, `Identity`, `Blockchain`, `Payment`, `Gossip`, `Security`, and `Observability` section structs, plus `RetryPolicy` (composes with the existing `#[serde(default)]`). No struct uses `#[serde(flatten)]`, so the attribute is compatible everywhere. Adds load-failure tests for both a typo'd key and a typo'd whole-section header. Closes #842 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
clap folds `DECDN_RELAY_URL` into `cli.relay_url`, which `resolve_network_into` treats as highest precedence over the file's `network.relay_urls`. An operator who configures a multi-entry failover list (#795/#817) in TOML but has a stale exported `DECDN_RELAY_URL` gets the whole list silently replaced by the single env value — quietly defeating the redundancy feature. Emit an `eprintln!` warning (tracing is not initialized at resolve time) naming the overridden list length when `--relay-url`/env is set and a non-empty `relay_urls` exists. The override behavior is already pinned by `resolve_network_cli_relay_url_overrides_file_list`, which now also documents that it exercises this warning trigger. Closes #843 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces several security, validation, and robustness improvements. Key changes include enforcing deny_unknown_fields on configuration structs to catch typos, redacting credentials from relay URLs in summaries, warning when a CLI override disables relay redundancy, expanding environment variables in discovery fields, rejecting self-reports in reputation validation, and masking IPv6 addresses to /64 prefixes in the DHT rate limiter to prevent bypasses. The feedback recommends sorting peer keys deterministically during environment variable expansion to ensure stable and predictable error reporting instead of relying on non-deterministic HashMap iteration.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if let Some(peers) = d.peers.as_mut() { | ||
| for (id, peer) in peers.iter_mut() { | ||
| expand_str( | ||
| &mut peer.relay_url, | ||
| &format!("network.discovery.peers[{id}].relay_url"), | ||
| )?; | ||
| for (idx, addr) in peer.addrs.iter_mut().enumerate() { | ||
| *addr = expand_value( | ||
| addr, | ||
| &format!("network.discovery.peers[{id}].addrs[{idx}]"), | ||
| )?; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Iterating directly over peers (which is a HashMap) is non-deterministic. If multiple environment variable expansion errors occur across different peers, the error returned by expand_env will be non-deterministic, making config validation output unstable across runs. Sorting the peer keys deterministically before expansion ensures consistent and predictable error reporting.
if let Some(peers) = d.peers.as_mut() {
let mut keys: Vec<_> = peers.keys().cloned().collect();
keys.sort_unstable();
for id in keys {
if let Some(peer) = peers.get_mut(&id) {
expand_str(
&mut peer.relay_url,
&format!("network.discovery.peers[{id}].relay_url"),
)?;
for (idx, addr) in peer.addrs.iter_mut().enumerate() {
*addr = expand_value(
addr,
&format!("network.discovery.peers[{id}].addrs[{idx}]"),
)?;
}
}
}
}References
- Use unstable sorting (
sort_unstableorsort_unstable_by) instead of stable sorting (sortorsort_by) when sorting elements with unique keys (such as keys retrieved from a HashMap), as stable ordering is unnecessary, and unstable sorting is faster and avoids auxiliary memory allocation.
There was a problem hiding this comment.
Fixed in 3223fc1. Sorting the peer keys before expansion (iter_mut().collect() + sort_unstable_by on the id) so the first surfaced ? error is stable across runs. This also matches the existing convention in resolve_discovery_into, which sorts peers by node_id for the same nondeterminism reason. Added expand_env_discovery_peer_error_order_is_deterministic pinning that two malformed peers always report the lexicographically-smallest id.
There was a problem hiding this comment.
Pull request overview
This PR batches six localized Rust bug fixes across config parsing/expansion, CLI validation output, node DHT/dispatch rate limiting, and gossip reputation validation—tightening operator safety (fail-fast on typos, env-expansion correctness, credential redaction) and closing two security/abuse gaps (IPv6 /64 limiter bypass; reputation self-reports).
Changes:
- Enforce stricter config schema handling: reject unknown TOML keys/sections, expand
${VAR}for[network.discovery], and warn when CLI/env--relay-urloverrides a non-emptynetwork.relay_urlslist. - Prevent sensitive credential leakage in
decdn config validateby redacting relay URL userinfo. - Harden node behavior: mask IPv6 to /64 for DHT per-IP rate limiting and reject reputation self-reports (
reporter == provider), with targeted tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/dispatch.rs | Exposes source_key for reuse so IPv6 /64 masking is consistent across limiters. |
| crates/node/src/dht/rate_limit.rs | Applies /64 IPv6 masking to DHT per-IP limiter keys and trusted IP handling; adds regression tests. |
| crates/gossip/src/reputation.rs | Rejects reputation self-reports and adds a stable reject label + unit test. |
| crates/config-types/src/retry.rs | Adds deny_unknown_fields to RetryPolicy to fail-fast on typos. |
| crates/common/src/config/types.rs | Adds deny_unknown_fields to top-level + section structs to reject unknown keys/sections. |
| crates/common/src/config/mod.rs | Warns on relay-url override of relay list and expands ${VAR} in [network.discovery] (including indexed ctx labels). |
| crates/cli/tests/config_validate.rs | Adds tests for unknown-field/unknown-section failures and relay URL credential redaction. |
| crates/cli/src/commands/config.rs | Redacts relay URL userinfo in validate summary output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 85.85% (was 85.77%, ▲ +0.08%) — 33491/39009 lines
History
|
`expand_env` expanded `network.relay_url`/`relay_urls` but had no leg for the `[network.discovery]` knobs added in #818/#829. An operator reusing the documented single-TOML-template-across-deployments pattern with `dns_origin = "${DNS_ORIGIN}"` got the literal string through resolution (only checked non-empty) and into bring-up, silently breaking peer resolution; `pkarr_url = "${PKARR_URL}"` failed with a confusing URL-parse error. Add a discovery block to `expand_env` mirroring the relay loop — `pkarr_url`, `dns_origin`, and each peer's `relay_url` + `addrs` — with indexed ctx labels `network.discovery.peers[<id>].{relay_url,addrs[idx]}`. While here, thread the entry index into the `relay_urls` ctx label (`network.relay_urls[idx]`), matching the `cache.origins[i]` convention (the #843 diagnosability nit). Closes #863 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`decdn config validate` printed each `relay_urls` entry verbatim while redacting `pkarr_url` (and fully hiding `rpc_url`/`otlp_endpoint`) two lines down in the same summary. An operator with `user:pass@` userinfo in a relay URL who pastes the summary into a GitHub issue or support channel — the exact share-the-summary use case the redaction exists for — leaks the credentials. Run each relay line through `decdn_common::redact::redact_userinfo` (host stays visible for diagnostics), matching the pkarr_url treatment, and correct the adjacent comment that claimed relays print unredacted. Adds a redaction test with a credentialed relay. Closes #862 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The DHT per-IP layer keyed buckets on the full `IpAddr`, so an attacker with a customer-grade IPv6 /64 (2^64 addresses) defeated the tier entirely by rotating source addresses — each request landed in a fresh bucket. The keyspace cap (#645) bounds memory but not the rate-limit bypass. The dispatch limiter already solved this with a /64 mask in `source_key`. Expose `dispatch::source_key` as `pub(crate)` and apply it in `DhtRateLimiter::try_admit_one` before both the `trusted_ips` membership test and `check_key`; mask trusted entries at construction so a configured IPv6 trusted address still matches a masked inbound key. Adds tests that two hosts in one /64 share a bucket (and a different /64 does not), and that a trusted IPv6 exempts its whole /64. Closes #841 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`validate_reputation_envelope` did not check `reporter == provider`, so a staked node could sign and gossip a report about itself: the self-report folded into the node's own network_score (weighted by its own settlement value, up to the 3x cap) AND counted as one of the three distinct reporters its score needs — dropping ADR 008's eclipse/Sybil external-identity cost from 3 to 2. Add a `SelfReport` variant (stable label `reputation_self_report`) and reject self-reports in the pure validation gate with a cheap 32-byte comparison, ahead of the recency and signature checks, so `record()` and the node sink never see one. Adds a `self_report_rejected` test and the variant to the label-stability test. Closes #861 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
58d5d2a to
403c6f8
Compare
Localized, Rust-only fixes surfaced by the 2026-06 full-repository reviews: - fix(config): deny unknown fields on FileConfig + section structs (#842) - fix(config): warn when DECDN_RELAY_URL overrides relay_urls list (#843) - fix(config): expand ${VAR} in [network.discovery] fields (#863) - fix(cli): redact relay credentials in config validate summary (#862) - fix(node): mask IPv6 /64 in DHT per-IP rate limiter (#841) - fix(reputation): reject reporter == provider self-reports (#861) Closes #841 Closes #842 Closes #843 Closes #861 Closes #862 Closes #863 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Batch of six small, independent MEDIUM bug fixes surfaced by the 2026-06-09/2026-06-10 full-repository reviews. Each is a localized, Rust-only fix (no Solidity/CI-gated surface) with test coverage; one conventional commit per issue.
Fixes
fix(config)(config: deny_unknown_fields missing on FileConfig and 7 section structs — typos in [blockchain]/[network]/[gossip]/[observability] silently no-op #842) — add#[serde(deny_unknown_fields)]toFileConfig, seven section structs, andRetryPolicy. A typo'd whole-section header ([netork]) or key (slash_judge_addres) now fails at load instead of silently running with wrong defaults. No struct uses#[serde(flatten)], so the attribute is compatible everywhere.fix(config)(config: stale DECDN_RELAY_URL env var silently collapses a multi-relay relay_urls list to one relay #843) — warn when--relay-url/DECDN_RELAY_URLoverrides a non-emptynetwork.relay_urlslist, so a stale exported env var no longer silently collapses the multi-relay failover list (iroh: support multiple relays + self-hosted discovery for isolated deployments #795/feat(node): multi-relay config + reachability-gated endpoint bring-up (#795) #817).fix(config)(common: [network.discovery] is skipped by ${VAR} env expansion, unlike its sibling relay_urls — dns_origin passes through as a literal string #863) — expand${VAR}in[network.discovery]fields (pkarr_url,dns_origin, per-peerrelay_url/addrs); previously they passed through as literal strings, silently breaking peer resolution. Also threads the entry index into therelay_urlsctx label.fix(cli)(cli: decdn config validate prints relay-URL user:pass@ credentials unredacted while redacting pkarr_url in the same summary #862) — redactuser:pass@userinfo in relay URLs printed bydecdn config validate, matching thepkarr_url/rpc_urltreatment in the same summary (the share-into-an-issue surface).fix(node)(node: DHT per-IP rate limiter keys on full IpAddr — IPv6 /64 rotation bypasses it (dispatch limiter already masks) #841) — mask IPv6 to its /64 prefix in the DHT per-IP rate limiter (reusingdispatch::source_key), closing the bypass where rotating within a customer-grade /64 minted a fresh bucket per request. Trusted IPv6 entries are masked at construction so they still match.fix(reputation)(reputation: self-reports are accepted — reporter == provider fills one of the three distinct-reporter slots and self-boosts the network score #861) — rejectreporter == providerself-reports invalidate_reputation_envelope, preventing a staked node from self-boosting its score and filling one of the three distinct-reporter slots (ADR 008 eclipse/Sybil cost).Verification
cargo fmt -- --check— cleancargo clippy --all-targets— clean (-D warnings)cargo nextest run— 1665/1665 passEach fix adds or updates targeted tests (config load failures, env-expansion, relay redaction, IPv6 /64 bucketing + trusted-IPv6 exemption, self-report rejection + label stability).
Closes #841
Closes #842
Closes #843
Closes #861
Closes #862
Closes #863
🤖 Generated with Claude Code