aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol/cryptonote_protocol_handler.inl
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-06-14 16:08:58 +0200
committerRiccardo Spagni <ric@spagni.net>2019-06-14 16:08:59 +0200
commitc58255ec12491dbc4d8c363280ede7869f447bf9 (patch)
tree7301d251061d44106b1cc5a50778c8a1db86d230 /src/cryptonote_protocol/cryptonote_protocol_handler.inl
parentMerge pull request #5633 (diff)
parentrpc: restrict the recent cutoff size in restricted RPC mode (diff)
downloadmonero-c58255ec12491dbc4d8c363280ede7869f447bf9.tar.xz
Merge pull request #5640
542cab02 rpc: restrict the recent cutoff size in restricted RPC mode (moneromooo-monero) 434e617a ensure no NULL is passed to memcpy (moneromooo-monero) 279f1f2c abstract_tcp_server2: improve DoS resistance (moneromooo-monero) 756773e5 serialization: check stream good flag at the end (moneromooo-monero) e3f714aa tree-hash: allocate variable memory on heap, not stack (moneromooo-monero) 67baa3a6 cryptonote: throw on tx hash calculation error (moneromooo-monero) d6bb9ecc serialization: fail on read_varint error (moneromooo-monero) 19490e44 cryptonote_protocol: fix another potential P2P DoS (moneromooo-monero) fa4aa47e cryptonote_protocol: expand basic DoS protection (moneromooo-monero) 3c953d53 cryptonote_protocol_handler: prevent potential DoS (anonimal) b873b69d epee: basic sanity check on allocation size from untrusted source (moneromooo-monero)
Diffstat (limited to '')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 8958af7c7..b38407840 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -809,12 +809,27 @@ namespace cryptonote
NOTIFY_NEW_FLUFFY_BLOCK::request fluffy_response;
fluffy_response.b.block = t_serializable_object_to_blob(b);
fluffy_response.current_blockchain_height = arg.current_blockchain_height;
+ std::vector<bool> seen(b.tx_hashes.size(), false);
for(auto& tx_idx: arg.missing_tx_indices)
{
if(tx_idx < b.tx_hashes.size())
{
MDEBUG(" tx " << b.tx_hashes[tx_idx]);
+ if (seen[tx_idx])
+ {
+ LOG_ERROR_CCONTEXT
+ (
+ "Failed to handle request NOTIFY_REQUEST_FLUFFY_MISSING_TX"
+ << ", request is asking for duplicate tx "
+ << ", tx index = " << tx_idx << ", block tx count " << b.tx_hashes.size()
+ << ", block_height = " << arg.current_blockchain_height
+ << ", dropping connection"
+ );
+ drop_connection(context, true, false);
+ return 1;
+ }
txids.push_back(b.tx_hashes[tx_idx]);
+ seen[tx_idx] = true;
}
else
{
@@ -914,6 +929,17 @@ namespace cryptonote
int t_cryptonote_protocol_handler<t_core>::handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote_connection_context& context)
{
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_GET_OBJECTS (" << arg.blocks.size() << " blocks, " << arg.txs.size() << " txes)");
+
+ if (arg.blocks.size() + arg.txs.size() > CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT)
+ {
+ LOG_ERROR_CCONTEXT(
+ "Requested objects count is too big ("
+ << arg.blocks.size() + arg.txs.size() << ") expected not more then "
+ << CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT);
+ drop_connection(context, false, false);
+ return 1;
+ }
+
NOTIFY_RESPONSE_GET_OBJECTS::request rsp;
if(!m_core.handle_get_objects(arg, rsp, context))
{