diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h index e9c846bf414..353c69df122 100755 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.h +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h @@ -55,6 +55,8 @@ DISABLE_VS_WARNINGS(4355) #define CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT 500 #define CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT 5000 +#define CURRENCY_PROTOCOL_MAX_VOTES_COUNT 1000 +#define CURRENCY_PROTOCOL_MAX_FLASHES_COUNT 1000 namespace cryptonote { diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 06306fd6e0d..30c23240660 100755 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -938,6 +938,13 @@ namespace cryptonote { MTRACE("Received NOTIFY_NEW_MASTER_NODE_VOTE (" << arg.votes.size() << " txes)"); + if (arg.votes.size() > CURRENCY_PROTOCOL_MAX_VOTES_COUNT) + { + LOG_ERROR_CCONTEXT("Too many votes (" << arg.votes.size() << ") in NOTIFY_NEW_MASTER_NODE_VOTE (max " << CURRENCY_PROTOCOL_MAX_VOTES_COUNT << "), dropping connection"); + drop_connection(context, false, false); + return 1; + } + if(context.m_state != cryptonote_connection_context::state_normal) return 1; @@ -981,6 +988,13 @@ namespace cryptonote { MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_FLUFFY_MISSING_TX (" << arg.missing_tx_indices.size() << " txes), block hash " << arg.block_hash); + if (arg.missing_tx_indices.size() > CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT) + { + LOG_ERROR_CCONTEXT("Too many missing_tx_indices (" << arg.missing_tx_indices.size() << "), dropping connection"); + drop_connection(context, false, false); + return 1; + } + std::vector> local_blocks; std::vector local_txs; @@ -1081,6 +1095,13 @@ namespace cryptonote int t_cryptonote_protocol_handler::handle_notify_new_transactions(int command, NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& context) { MLOG_P2P_MESSAGE("Received NOTIFY_NEW_TRANSACTIONS (" << arg.txs.size() << " txes w/ " << arg.flashes.size() << " flashes)"); + + if (arg.txs.size() > CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT || arg.flashes.size() > CURRENCY_PROTOCOL_MAX_FLASHES_COUNT) + { + LOG_ERROR_CCONTEXT("Oversized NOTIFY_NEW_TRANSACTIONS (txs=" << arg.txs.size() << ", flashes=" << arg.flashes.size() << "), dropping connection"); + drop_connection(context, false, false); + return 1; + } for (const auto &blob: arg.txs) MLOGIF_P2P_MESSAGE(cryptonote::transaction tx; crypto::hash hash; bool ret = cryptonote::parse_and_validate_tx_from_blob(blob, tx, hash);, ret, "Including transaction " << hash);