Skip to content

security: chain RPC transport errors leak the full rpc_url (path/query API keys) to operator output #954

Closed

Description

@thiras

Summary

Any failed chain-RPC call surfaces the full rpc_url — including the path/query where Infura/Alchemy-style API keys live — in operator-facing error output. This is pre-existing and codebase-wide, surfaced during the PR #953 review (silent-failure-hunter).

Mechanism (verified)

  • reqwest 0.13.4 Error Display writes " for url ({url})" (reqwest/src/error.rs:268), and url::Url's Display emits scheme + authority + path + query. reqwest provides Error::without_url() precisely to strip it.
  • alloy's TransportErrorKind is #[error("{0}")]-transparent, forwarding the inner reqwest::Error.
  • CLI commands wrap these via anyhow .with_context(...) / .context(...), and main() returns anyhow::Result<()>, so the entire source chain is printed on failure — exposing the raw URL.

Affected (non-exhaustive)

  • crates/cli/src/commands/setup.rs — get_chain_id, get_balance, get_gas_price, balance reads (the "rpc_url is not reachable" path and others)
  • crates/cli/src/commands/bond.rs — build_plan contract reads (minCapacityMbps, bondRequired, activeBond, …) wrapped with .with_context(ctx)
  • crates/cli/src/commands/register.rs — nonce reads + registerNode
  • Likely the decdn-node daemon's chain-interaction paths as well

Fires on the common failure modes: DNS failure, connection refused, TLS error, timeout against the RPC endpoint.

Established policy this violates

config validate already hides rpc_url as <redacted> ({} chars) (crates/cli/src/commands/config.rs:131) "because the secret commonly lives in the path or query." Transport-error paths bypass that policy.

Proposed fix

A shared sanitizer applied at every chain-RPC error site (a single helper, applied uniformly), e.g.:

  • Downcast the error source to reqwest::Error and call .without_url() before it propagates; or
  • Map the transport error to a message that drops the URL-bearing source chain (.map_err(|_| anyhow!("RPC call failed against the configured endpoint; check blockchain.rpc_url"))), preserving the transport error class via a sanitized formatter that strips the for url (...) tail.

Apply consistently across cli (bond/register/setup) and node so no chain-RPC site echoes the raw URL.

Scope note

PR #953 (decdn setup) aligned its two malformed-URL parse error sites to the <redacted> (N chars) policy, but deliberately did not patch the transport-error leak piecemeal — it predates that PR and spans the whole chain-interacting surface. This issue tracks the comprehensive fix.

References

  • reqwest Error::without_url, error.rs:268
  • crates/cli/src/commands/config.rs:108-133 (the <redacted> (N chars) policy to match)
  • crates/cli/src/main.rs (anyhow Debug print walks the full source chain)

Activity

  1. self-assigned this
    on Jun 18, 2026
  2. added
    kind:bug
    area:cli
    prio:high
    rust
    kind:security
    on Jun 18, 2026
  3. github-actions commented on Jun 18, 2026

    @github-actions

    🎯 Triage report

    A confirmed security bug: failed chain-RPC calls emit the full rpc_url — including Infura/Alchemy API keys embedded in the path/query — through reqwest::Error's Display impl, which propagates transparently through alloy's TransportErrorKind and then up the full anyhow source chain printed by main(). This directly violates the existing <redacted> (N chars) policy already enforced in config validate, making it a regression-in-policy rather than a new design choice. Affected call sites span cli (bond/register/setup) and likely the node daemon's chain-interaction paths.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Violation of existing redaction policy; no new feature needed
    Labels security, bug, high, cli, rust Credential leak on common failure modes (DNS, TLS, timeout); high impact
    Coding agent Suitable Mechanism fully explained, affected files listed, concrete fix approaches given, no design decisions required

    🔗 Similar issues

    💡 Notes and suggestions

    Recommended implementation approach

    The cleanest fix is a single shared helper in crates/common/src/ (e.g., sanitize_rpc_error) applied uniformly at every chain-RPC call site:

    // Option A — downcast and strip URL from the reqwest source
    pub fn sanitize_rpc_error(err: anyhow::Error) -> anyhow::Error {
        // Walk the source chain; if we find a reqwest::Error, replace it
        // with its .without_url() variant so the URL never reaches Display.
        // alloy's TransportErrorKind is #[error("{0}")]-transparent, so this
        // is sufficient.
        ...
    }
    // Option B — simpler: suppress the source chain at the call site
    .map_err(|e| anyhow!("RPC call failed ({}); check blockchain.rpc_url in config", e.kind_label()))?

    Option B is easier to audit and avoids downcasting through alloy's error chain.

    Files to touch (non-exhaustive)

    • crates/cli/src/commands/bond.rs — all .with_context(...) wrapping alloy provider calls in build_plan
    • crates/cli/src/commands/register.rs — nonce reads + registerNode
    • crates/cli/src/commands/setup.rs — get_chain_id, get_balance, get_gas_price
    • crates/node/src/... — any chain-interaction paths that propagate to tracing or operator-visible output

    Don't forget decdn-node: If the daemon logs chain errors via tracing, those log lines also need the sanitizer — tracing's %err and ?err formats both walk the source chain.

    Testing: Add an integration test that triggers a connection-refused error against a dummy endpoint and asserts the output does not contain the configured RPC URL string.

    Checklist

    • Add sanitize_rpc_error (or equivalent) helper to crates/common/src/
    • Apply to all alloy provider call sites in cli (bond, register, setup)
    • Audit node crate for chain-interaction paths; apply same sanitizer
    • Confirm tracing log sites don't leak via %err/?err
    • Add regression test asserting URL absent from error output
    • Update existing error-message tests that may pin the raw URL form

    Generated by Agentic Triage for issue #954 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:bugkind:securityprio:highrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions