fix(rpc): stop get_output_distribution JSON-RPC panic#1
Open
orrinfrazier wants to merge 1 commit into
Open
Conversation
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.
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.
Closes #11
Summary
get_output_distributionJSON-RPC handler panicked on every call via atodo!(), exposing a remote DoS on any node with RPC enabled (the default restricted server).not_available(), matching the/get_output_distribution.binvariant, until the binary-string distribution encoding is implemented.Why
json_rpc.rsdispatchedGetOutputDistributiontoshared::get_output_distribution, which does real DB work and then builds its response withdistributions: todo!(\"...binary strings: monero-project/monero#9422\"). Thetodo!()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:GetOutputDistributionnow routes tonot_available()?(one match arm), mirroringbin.rs:53. The now-unreachablejson_rpc::get_output_distributionwrapper andshared::get_output_distributionare left in place (matching the existingbin::get_output_distributionprecedent; 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
Fixes the panic described in `issues/S02-1-get-output-distribution-panic.md` (survey TOP-5 #3).