fix(protocol): re-check operation size before propagation#5100
Open
damip wants to merge 1 commit into
Open
Conversation
The operation propagation loop accepted every `PropagateOperations(Storage)` command and marked all contained operations checked, stored, and announced them without re-checking `serialized_size() <= max_serialized_operations_size_per_block`. Locally submitted operations (JSON-RPC / gRPC) are not validated against this limit on submission, so an oversized-but-otherwise-valid operation could be advertised to peers, causing honest peers to ban/disconnect from this node. Filter operations through `operations_within_size_limit` before marking them checked / storing for propagation / announcing, mirroring the size check already enforced on the peer-received (retrieval) path. Oversized operations are dropped (and logged) instead of propagated. No wire/consensus format or API/gRPC surface change; only which locally supplied operations get gossiped. Addresses AI-report Finding 125. Co-authored-by: Cursor <cursoragent@cursor.com>
damip
marked this pull request as ready for review
July 21, 2026 13:56
| match internal_message { | ||
| OperationHandlerPropagationCommand::PropagateOperations(operations) => { | ||
| // Note operations as checked. | ||
| // Re-validate the protocol size limit before propagating. |
Member
There was a problem hiding this comment.
Is preventing propagation enough? Would it be possible to directly check this limit against submitted ops (JSON-RPC / gRPC) and return an error there?
Here I think we basically silently drop the operation, no?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The operation propagation loop accepted every
PropagateOperations(Storage)command and marked all contained operations checked, stored them, and announced them without re-checking the protocol ruleserialized_size() <= max_serialized_operations_size_per_block. Locally submitted operations (JSON-RPC / gRPC) are not validated against this limit on submission, so an oversized-but-otherwise-valid operation could be advertised to peers, causing honest peers to ban/disconnect from this node.Addresses AI-report Finding 125 (severity: medium).
Fix
Filter operations through the new
operations_within_size_limithelper before marking them checked / storing for propagation / announcing. This mirrors the size check already enforced on the peer-received (retrieval) path (note_operations_from_peer). Oversized operations are dropped (and logged), not propagated.Scope / safety
No wire/consensus format change and no JSON-RPC/gRPC interface change — only which locally supplied operations get gossiped. Operations that honest peers would reject as oversized are simply not advertised.
Testing
oversized_operations_are_filtered_out_of_propagation: with a generous limit an operation is kept; with a limit below its serialized size it is filtered out (so never marked checked/stored/announced).cargo test -p massa_protocol_worker --features test-exports: pass.cargo clippy --all-targets: clean.cargo fmt: clean.Checklist
Made with Cursor