Skip to content

fix(p2p): bound peer-supplied vector sizes in three NOTIFY handlers#194

Open
raw391 wants to merge 1 commit into
Beldex-Coin:devfrom
raw391:fix/p2p-notify-vector-bounds
Open

fix(p2p): bound peer-supplied vector sizes in three NOTIFY handlers#194
raw391 wants to merge 1 commit into
Beldex-Coin:devfrom
raw391:fix/p2p-notify-vector-bounds

Conversation

@raw391

@raw391 raw391 commented Jun 3, 2026

Copy link
Copy Markdown

Three NOTIFY handlers in cryptonote_protocol_handler.inl iterate a peer-supplied vector without checking its size first:

  • handle_notify_new_master_node_vote at line 937 walks arg.votes doing signature verification per element
  • handle_notify_new_transactions at line 1081 parses arg.txs under incoming_tx_lock
  • handle_request_fluffy_missing_tx at line 980 does per-index dup check + block tx lookup over arg.missing_tx_indices

The codebase already defines CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT and CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT at cryptonote_protocol_handler.h:56-57 and uses them in handle_request_get_blocks (line 1190) and handle_notify_request_get_txs (line 1737). This PR adds the same pattern to the three vote/tx/fluffy handlers, plus CURRENCY_PROTOCOL_MAX_FLASHES_COUNT for the flash batch size in handle_notify_new_transactions.

Cap values: 1000 votes (50x current max quorum), 5000 txs and 500 missing-tx indices reuse existing constants, 1000 flashes matches the votes ceiling. LOG_ERROR_CCONTEXT matches the existing sibling pattern at lines 1190 and 1737.

handle_notify_new_master_node_vote, handle_notify_new_transactions
and handle_request_fluffy_missing_tx iterate a peer-supplied vector
without a size cap. The codebase already defines
CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT and
CURRENCY_PROTOCOL_MAX_TXS_REQUEST_COUNT for the same pattern in
handle_request_get_blocks and handle_notify_request_get_txs.

Adds CURRENCY_PROTOCOL_MAX_VOTES_COUNT and
CURRENCY_PROTOCOL_MAX_FLASHES_COUNT, drops oversized messages with
LOG_ERROR_CCONTEXT matching the existing sibling pattern.
@raw391 raw391 force-pushed the fix/p2p-notify-vector-bounds branch from e72939d to c96063c Compare June 5, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants