diff options
author | luigi1111 <luigi1111w@gmail.com> | 2021-11-26 23:05:52 -0600 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2021-11-26 23:05:52 -0600 |
commit | dfb818a01b759d10504f4951af41e9b257c1cdf4 (patch) | |
tree | dc6487cbb2344a30cc637eb322b43838752660ca | |
parent | Merge pull request #8075 (diff) | |
parent | rpc: fix DoS vector in get_output_distribution (diff) | |
download | monero-dfb818a01b759d10504f4951af41e9b257c1cdf4.tar.xz |
Merge pull request #8084
a4954a9 rpc: fix DoS vector in get_output_distribution (moneromooo-monero)
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 62415fb43..757e73906 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -3055,6 +3055,14 @@ namespace cryptonote if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_OUTPUT_DISTRIBUTION>(invoke_http_mode::JON_RPC, "get_output_distribution", req, res, r)) return r; + const bool restricted = m_restricted && ctx; + if (restricted && req.amounts != std::vector<uint64_t>(1, 0)) + { + error_resp.code = CORE_RPC_ERROR_CODE_RESTRICTED; + error_resp.message = "Restricted RPC can only get output distribution for rct outputs. Use your own node."; + return false; + } + size_t n_0 = 0, n_non0 = 0; for (uint64_t amount: req.amounts) if (amount) ++n_non0; else ++n_0; @@ -3096,6 +3104,13 @@ namespace cryptonote if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_OUTPUT_DISTRIBUTION>(invoke_http_mode::BIN, "/get_output_distribution.bin", req, res, r)) return r; + const bool restricted = m_restricted && ctx; + if (restricted && req.amounts != std::vector<uint64_t>(1, 0)) + { + res.status = "Restricted RPC can only get output distribution for rct outputs. Use your own node."; + return false; + } + size_t n_0 = 0, n_non0 = 0; for (uint64_t amount: req.amounts) if (amount) ++n_non0; else ++n_0; |