What changed, and why it matters
This Monero update tightens how a node checks another node's claims about being fully synced. Previously, a peer could trick a node into thinking it was synchronized by simply claiming a high block height. The patch now verifies that the peer's claimed top block actually matches the local node's known blockchain tip, and rejects absurdly large height values. This reduces the risk of a malicious or buggy peer prematurely ending a node's initial sync, which could leave the node on a stale or forked view of the network.
Nodes should upgrade to a build containing this commit to reduce the risk of premature sync termination caused by malicious or misconfigured peers. Operators relying on initial sync completion for wallet or service readiness should verify they are running the patched code.
Security signals we found
Validation added for peer-supplied blockchain height against CRYPTONOTE_MAX_BLOCK_NUMBER
Initial sync completion now requires matching top block hash or resolvable block at local top height
Prevents premature on_connection_synchronized() based solely on claimed height
Adds disconnect/drop logic for invalid sync data
Evidence from the diff
The commit modifies cryptonote_protocol_handler.inl to add validation in process_payload_sync_data and handle_response_get_objects. It rejects hshd.current_height and arg.current_blockchain_height values >= CRYPTONOTE_MAX_BLOCK_NUMBER. More importantly, it changes the initial-sync completion check: instead of accepting hshd.current_height >= target when target equals the local blockchain height, it now fetches the local top height/hash, computes local_height = local_top_height + 1, and only calls on_connection_synchronized() if target == local_height, hshd.current_height == local_height, and either hshd.top_id matches the local top id or the peer’s top_id resolves to the local top height. This prevents a peer from forcing a false ‘synchronized’ state.
Changed components
src/cryptonote_protocol/cryptonote_protocol_handler.inlprocess_payload_sync_datahandle_response_get_objectson_connection_synchronizedInspect captured patch +27 / −2
### src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -371,6 +371,12 @@ namespace cryptonote
template<class t_core>
bool t_cryptonote_protocol_handler<t_core>::process_payload_sync_data(const CORE_SYNC_DATA& hshd, cryptonote_connection_context& context, bool is_inital)
{
+ if (hshd.current_height >= CRYPTONOTE_MAX_BLOCK_NUMBER)
+ {
+ MWARNING(context << " peer claims an invalid height of " << hshd.current_height << ", disconnecting");
+ return false;
+ }
+
if(context.m_state == cryptonote_connection_context::state_before_handshake && !is_inital)
return true;
@@ -445,8 +451,20 @@ namespace cryptonote
if (have_top)
{
context.set_state_normal();
- if(is_inital && hshd.current_height >= target && target == m_core.get_current_blockchain_height())
- on_connection_synchronized();
+ if (is_inital)
+ {
+ uint64_t local_top_height;
+ crypto::hash local_top_id;
+ m_core.get_blockchain_top(local_top_height, local_top_id);
+ const uint64_t local_height = local_top_height + 1;
+ if (target == local_height && hshd.current_height == local_height)
+ {
+ block top_block;
+ if (hshd.top_id == local_top_id ||
+ (m_core.get_block_by_hash(hshd.top_id, top_block) && get_block_height(top_block) == local_top_height))
+ on_connection_synchronized();
+ }
+ }
return true;
}
@@ -1065,6 +1083,13 @@ namespace cryptonote
++m_sync_bad_spans_downloaded;
return LEVIN_ERROR_CONNECTION;
}
+ if (arg.current_blockchain_height >= CRYPTONOTE_MAX_BLOCK_NUMBER)
+ {
+ LOG_ERROR_CCONTEXT("sent wrong NOTIFY_HAVE_OBJECTS: invalid current_blockchain_height=" << arg.current_blockchain_height);
+ drop_connection(context, false, 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_RESPONSE_GET_OBJECTS: arg.m_current_blockchain_height=" << arg.current_blockchain_heightWhy this scored 59/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.