From 7b0968b7e15b565e56bc2d17126ebeb898b4628f Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Mon, 27 Jul 2020 11:40:06 +0900 Subject: [PATCH] rpcserver: Add exists upper bounds TODOs. Although permissioned, the RPC server will allow for checking any number of values for its various exists commands. It would be reasonable to limit unreasonable requests that could exhaust dcrd's available memory and cause node failure. Changes will come with a major RPC version bump. --- internal/rpcserver/rpcserver.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/rpcserver/rpcserver.go b/internal/rpcserver/rpcserver.go index 07acd8bc..41cc5eef 100644 --- a/internal/rpcserver/rpcserver.go +++ b/internal/rpcserver/rpcserver.go @@ -1458,6 +1458,9 @@ func handleExistsAddress(_ context.Context, s *Server, cmd interface{}) (interfa } // handleExistsAddresses implements the existsaddresses command. +// +// TODO: Add an upper bound to the number of addresses that can be checked. +// This will come with a major RPC version bump. func handleExistsAddresses(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { if s.cfg.ExistsAddresser == nil { return nil, rpcInternalError("Exists address index disabled", @@ -1523,6 +1526,9 @@ func decodeHashPointers(strs []string) ([]*chainhash.Hash, error) { } // handleExistsMissedTickets implements the existsmissedtickets command. +// +// TODO: Add an upper bound to the number of hashes that can be checked. This +// will come with a major RPC version bump. func handleExistsMissedTickets(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { c := cmd.(*types.ExistsMissedTicketsCmd) @@ -1549,6 +1555,9 @@ func handleExistsMissedTickets(_ context.Context, s *Server, cmd interface{}) (i } // handleExistsExpiredTickets implements the existsexpiredtickets command. +// +// TODO: Add an upper bound to the number of hashes that can be checked. This +// will come with a major RPC version bump. func handleExistsExpiredTickets(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { c := cmd.(*types.ExistsExpiredTicketsCmd) @@ -1587,6 +1596,9 @@ func handleExistsLiveTicket(_ context.Context, s *Server, cmd interface{}) (inte } // handleExistsLiveTickets implements the existslivetickets command. +// +// TODO: Add an upper bound to the number of hashes that can be checked. This +// will come with a major RPC version bump. func handleExistsLiveTickets(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { c := cmd.(*types.ExistsLiveTicketsCmd) @@ -1613,6 +1625,9 @@ func handleExistsLiveTickets(_ context.Context, s *Server, cmd interface{}) (int } // handleExistsMempoolTxs implements the existsmempooltxs command. +// +// TODO: Add an upper bound to the number of hashes that can be checked. This +// will come with a major RPC version bump. func handleExistsMempoolTxs(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { c := cmd.(*types.ExistsMempoolTxsCmd)