From f14082fdbd1b576759788e28af87ab5ebbd81d6b Mon Sep 17 00:00:00 2001 From: selsta Date: Fri, 4 Sep 2026 18:42:03 +0200 Subject: [PATCH] rpc: reject deep block submissions on restricted RPC (cherry picked from commit 837c59bed10d06956ca7375a0e91619c0b77142e) --- src/rpc/core_rpc_server.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 75b4a1226..9367d8804 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2234,6 +2234,25 @@ namespace cryptonote return false; } + if (m_restricted && ctx) + { + block parent; + if (!m_core.get_block_by_hash(b.prev_id, parent)) + { + error_resp.code = CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED; + error_resp.message = "Unknown parent block"; + return false; + } + const uint64_t block_height = get_block_height(parent) + 1; + const uint64_t chain_height = m_core.get_current_blockchain_height(); + if (crypto::rx_seedheight(block_height) != crypto::rx_seedheight(chain_height)) + { + error_resp.code = CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED; + error_resp.message = "Block is too old for restricted RPC"; + return false; + } + } + block_verification_context bvc; if(!m_core.handle_block_found(b, bvc)) {