Skip to content

fix(rpc): stop get_output_distribution JSON-RPC panic#1

Open
orrinfrazier wants to merge 1 commit into
mainfrom
fix/get-output-distribution-panic
Open

fix(rpc): stop get_output_distribution JSON-RPC panic#1
orrinfrazier wants to merge 1 commit into
mainfrom
fix/get-output-distribution-panic

Conversation

@orrinfrazier
Copy link
Copy Markdown
Owner

@orrinfrazier orrinfrazier commented May 24, 2026

Closes #11

Summary

  • The get_output_distribution JSON-RPC handler panicked on every call via a todo!(), exposing a remote DoS on any node with RPC enabled (the default restricted server).
  • Routes the dispatch arm to not_available(), matching the /get_output_distribution.bin variant, until the binary-string distribution encoding is implemented.

Why

json_rpc.rs dispatched GetOutputDistribution to shared::get_output_distribution, which does real DB work and then builds its response with distributions: todo!(\"...binary strings: monero-project/monero#9422\"). The todo!() unconditionally panics the RPC task. The only guard rejects non-RCT amounts, so a restricted/remote client requesting RCT outputs (amounts == [0]) passes it and reaches the panic.

Changes

  • binaries/cuprated/src/rpc/handlers/json_rpc.rs: GetOutputDistribution now routes to not_available()? (one match arm), mirroring bin.rs:53. The now-unreachable json_rpc::get_output_distribution wrapper and shared::get_output_distribution are left in place (matching the existing bin::get_output_distribution precedent; covered by the crate-wide #![allow(dead_code)]), preserving the partial impl for when [Proposal] Deprecate RPC binary strings monero-project/monero#9422 lands.

Testing

  • `cargo clippy -p cuprated --all-targets` — clean, exit 0 (workspace denies clippy warnings).
  • `cargo fmt -p cuprated --check` — clean.
  • No unit test added: `CupratedRpcHandler` cannot be constructed without launching a full node (its service handles have no public/test constructor) and the repo has no RPC test harness. The fix is verified by symmetry with the already-shipping `bin.rs:53` pattern and the ~20 sibling `not_available()?` arms in the same match.

Fixes the panic described in `issues/S02-1-get-output-distribution-panic.md` (survey TOP-5 #3).

The get_output_distribution JSON-RPC handler dispatched to the real
handler, which constructs its response with a todo!() (the distribution
type contains binary strings, monero-project/monero#9422). The todo!()
panicked the RPC task on every call. The only guard rejects non-RCT
amounts, so a restricted/remote client requesting RCT outputs
(amounts == [0]) reached it -- a remote DoS on any node with RPC enabled
(the default restricted server).

Route the dispatch arm to not_available(), matching the
/get_output_distribution.bin variant (bin.rs:53), until the binary-string
distribution encoding is implemented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cuprated: get_output_distribution JSON-RPC handler panics on todo!()

1 participant