What changed, and why it matters
This change is a logging cleanup, not a fix for a code vulnerability. It moves full hex dumps of malformed network blobs from regular error logs to a special low-level 'trace' log category. The goal is to stop normal node logs from filling up with huge binary dumps when a peer sends bad data. The underlying behavior—rejecting malformed blocks and dropping the peer—stays exactly the same.
No security action required. This is a maintainability/diagnostics improvement. Operators who need full malformed blob dumps can enable the net.p2p.msg.dump trace log category.
Security signals we found
Logging of potentially sensitive or large peer-provided blobs moved from default error logs to trace-level logs
No change to validation, parsing, or peer-punishment logic
Error metadata added to aid diagnostics without exposing full blobs by default
Log message typo correction (NOTIFY_HAVE_OBJECTS -> NOTIFY_RESPONSE_GET_OBJECTS)
Evidence from the diff
The patch refactors error logging in cryptonote_protocol_handler.inl and block_entry_utils.h. Full blob hex dumps are removed from MCERROR/MERROR/LOG_ERROR_CCONTEXT messages and emitted instead via MCTRACE(“net.p2p.msg.dump”, …). Error messages now include metadata such as blob_size, block_hash, tx counts, and response_index. It also corrects two mislabeled log strings from NOTIFY_HAVE_OBJECTS to NOTIFY_RESPONSE_GET_OBJECTS. No parsing, validation, or network handling logic is changed.
Changed components
src/cryptonote_protocol/block_entry_utils.hsrc/cryptonote_protocol/cryptonote_protocol_handler.inlInspect captured patch +42 / −19
### src/cryptonote_protocol/block_entry_utils.h
@@ -78,9 +78,10 @@ namespace cryptonote
if (!parse_success)
{
- MCERROR("verify", "failed to parse and/or validate transaction: "
- << epee::string_tools::buff_to_hex_nodelimer(tx_entry.blob)
- );
+ MCERROR("verify", "failed to parse and/or validate transaction: blob_size=" << tx_entry.blob.size()
+ << ", pruned=" << is_pruned);
+ MCTRACE("net.p2p.msg.dump", "Malformed transaction blob: "
+ << epee::string_tools::buff_to_hex_nodelimer(tx_entry.blob));
return false;
}
else if (!blk_tx_hashes.count(tx_hash))
@@ -106,24 +107,31 @@ namespace cryptonote
cryptonote::block blk;
if (!cryptonote::parse_and_validate_block_from_blob(blk_entry.block, blk))
{
- MCERROR("verify", "sent bad block: failed to parse and/or validate block: "
- << epee::string_tools::buff_to_hex_nodelimer(blk_entry.block)
- );
+ MCERROR("verify", "sent bad block: failed to parse and/or validate block: blob_size=" << blk_entry.block.size());
+ MCTRACE("net.p2p.msg.dump", "Malformed block blob: "
+ << epee::string_tools::buff_to_hex_nodelimer(blk_entry.block));
return false;
}
const std::unordered_set<crypto::hash> blk_tx_hashes(blk.tx_hashes.cbegin(), blk.tx_hashes.cend());
if (blk_tx_hashes.size() != blk_entry.txs.size())
{
- MCERROR("verify", "sent bad block entry: number of hashes is not equal number of tx blobs: "
- << epee::string_tools::buff_to_hex_nodelimer(blk_entry.block)
- );
+ MCERROR("verify", "sent bad block entry: number of hashes is not equal number of tx blobs: block_hash="
+ << cryptonote::get_block_hash(blk) << ", blob_size=" << blk_entry.block.size()
+ << ", tx_hashes=" << blk.tx_hashes.size()
+ << ", unique_tx_hashes=" << blk_tx_hashes.size()
+ << ", tx_blobs=" << blk_entry.txs.size());
+ MCTRACE("net.p2p.msg.dump", "Block blob with mismatched transaction counts: "
+ << epee::string_tools::buff_to_hex_nodelimer(blk_entry.block));
return false;
}
else if (blk_tx_hashes.size() != blk.tx_hashes.size())
{
- MCERROR("verify", "sent bad block entry: there are duplicate tx hashes in parsed block: "
+ MCERROR("verify", "sent bad block entry: there are duplicate tx hashes in parsed block: block_hash="
+ << cryptonote::get_block_hash(blk) << ", blob_size=" << blk_entry.block.size()
+ << ", tx_hashes=" << blk.tx_hashes.size() << ", unique_tx_hashes=" << blk_tx_hashes.size());
+ MCTRACE("net.p2p.msg.dump", "Block blob with duplicate transaction hashes: "
<< epee::string_tools::buff_to_hex_nodelimer(blk_entry.block));
return false;
}
### src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -70,6 +70,7 @@
} \
} \
} while(0)
+#define MLOG_P2P_MESSAGE_DETAILS(x) MCTRACE("net.p2p.msg.dump", x)
#define MLOG_PEER_STATE(x) \
MCINFO(MONERO_DEFAULT_LOG_CATEGORY, context << "[" << epee::string_tools::to_string_hex(context.m_pruning_seed) << "] state: " << x << " in state " << cryptonote::get_protocol_state_string(context.m_state))
@@ -541,10 +542,13 @@ namespace cryptonote
{
LOG_ERROR_CCONTEXT
(
- "sent wrong block: failed to parse and validate block: "
- << epee::string_tools::buff_to_hex_nodelimer(arg.b.block)
+ "sent wrong block: failed to parse and validate block: blob_size=" << arg.b.block.size()
+ << ", current_blockchain_height=" << arg.current_blockchain_height
+ << ", supplied_txs=" << arg.b.txs.size()
<< ", dropping connection"
);
+ MLOG_P2P_MESSAGE_DETAILS(context << "Malformed fluffy block blob: "
+ << epee::string_tools::buff_to_hex_nodelimer(arg.b.block));
drop_connection(context, false, false);
return LEVIN_ERROR_CONNECTION;
@@ -574,7 +578,10 @@ namespace cryptonote
// Check for duplicate txids in parsed block blob
if (blk_txids_set.size() != new_block.tx_hashes.size())
{
- MERROR("sent bad block entry: there are duplicate tx hashes in parsed block: "
+ MERROR("sent bad block entry: there are duplicate tx hashes in parsed block: block_hash="
+ << new_block_hash << ", blob_size=" << arg.b.block.size()
+ << ", tx_hashes=" << new_block.tx_hashes.size() << ", unique_tx_hashes=" << blk_txids_set.size());
+ MLOG_P2P_MESSAGE_DETAILS(context << "Fluffy block blob with duplicate transaction hashes: "
<< epee::string_tools::buff_to_hex_nodelimer(arg.b.block));
drop_connection(context, false, false);
return LEVIN_ERROR_CONNECTION;
@@ -1025,14 +1032,14 @@ namespace cryptonote
if(arg.blocks.empty())
{
- LOG_ERROR_CCONTEXT("sent wrong NOTIFY_HAVE_OBJECTS: no blocks");
+ LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_GET_OBJECTS: no blocks");
drop_connection(context, true, false);
++m_sync_bad_spans_downloaded;
return LEVIN_ERROR_CONNECTION;
}
if(context.m_last_response_height > arg.current_blockchain_height)
{
- LOG_ERROR_CCONTEXT("sent wrong NOTIFY_HAVE_OBJECTS: arg.m_current_blockchain_height=" << arg.current_blockchain_height
+ LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_GET_OBJECTS: arg.m_current_blockchain_height=" << arg.current_blockchain_height
<< " < m_last_response_height=" << context.m_last_response_height << ", dropping connection");
drop_connection(context, false, false);
++m_sync_bad_spans_downloaded;
@@ -1066,16 +1073,24 @@ namespace cryptonote
crypto::hash block_hash;
if(!parse_and_validate_block_from_blob(arg.blocks[i].block, b, block_hash))
{
- LOG_ERROR_CCONTEXT("sent wrong block: failed to parse and validate block: "
- << epee::string_tools::buff_to_hex_nodelimer(arg.blocks[i].block) << ", dropping connection");
+ LOG_ERROR_CCONTEXT("sent wrong block: failed to parse and validate block: blob_size="
+ << arg.blocks[i].block.size() << ", response_index=" << i
+ << ", expected_height=" << context.m_expect_height
+ << ", peer_tip=" << arg.current_blockchain_height << ", dropping connection");
+ MLOG_P2P_MESSAGE_DETAILS(context << "Malformed sync response block blob: "
+ << epee::string_tools::buff_to_hex_nodelimer(arg.blocks[i].block));
drop_connection(context, false, false);
++m_sync_bad_spans_downloaded;
return LEVIN_ERROR_CONNECTION;
}
if (b.miner_tx.vin.size() != 1 || b.miner_tx.vin.front().type() != typeid(txin_gen))
{
- LOG_ERROR_CCONTEXT("sent wrong block: block: miner tx does not have exactly one txin_gen input"
- << epee::string_tools::buff_to_hex_nodelimer(arg.blocks[i].block) << ", dropping connection");
+ LOG_ERROR_CCONTEXT("sent wrong block: miner tx does not have exactly one txin_gen input: block_hash="
+ << block_hash << ", blob_size=" << arg.blocks[i].block.size()
+ << ", tx_hashes=" << b.tx_hashes.size() << ", tx_blobs=" << arg.blocks[i].txs.size()
+ << ", response_index=" << i << ", dropping connection");
+ MLOG_P2P_MESSAGE_DETAILS(context << "Sync response block blob with invalid miner tx: "
+ << epee::string_tools::buff_to_hex_nodelimer(arg.blocks[i].block));
drop_connection(context, false, false);
++m_sync_bad_spans_downloaded;
return LEVIN_ERROR_CONNECTION;Why this scored 23/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.