fix(rpc): cap eth_getLogs filter addresses and topics#2712
Open
crazywriter1 wants to merge 2 commits into
Open
fix(rpc): cap eth_getLogs filter addresses and topics#2712crazywriter1 wants to merge 2 commits into
crazywriter1 wants to merge 2 commits into
Conversation
Collaborator
🟡 Heimdall Review Status
|
|
@crazywriter1 is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
829d2d9 to
9b22066
Compare
`eth_getLogs` is unauthenticated and accepts an unbounded `address` vector and per-slot `topics` vectors. Each address is a separate index lookup the EL resolves per matched block, and each topic entry multiplies per-block work. A single malicious request with thousands of entries can spend tens of seconds on the executor thread the EL also uses for the engine API, with the potential to cascade into missed sequencer block production windows. Same DoS class as `eth_getProof` storage keys (capped in base#2596 via `MAX_PROOF_KEYS`). Reject filters with more than `MAX_LOG_ADDRESSES = 1000` addresses or more than `MAX_LOG_TOPICS_PER_SLOT = 1000` topic values in any of the four topic slots, before any DB access. Legitimate dApp queries (typically a handful of contracts and a few topic values) are unaffected. Block-range capping is handled separately by reth's existing filter settings and is intentionally out of scope here.
4df2e29 to
f62e0af
Compare
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.
Problem
eth_getLogsis unauthenticated and accepts unboundedaddressand per-slottopicsvectors. Each address triggers a separate index lookup the EL resolves per matched block, and each topic entry multiplies the per-block work. A single malicious request with thousands of entries can monopolize the executor thread the EL also uses for the engine API, with the potential to cascade into missed sequencer block production windows.This is the same DoS class as the
eth_getProofstorage-key vector capped in #2596 (MAX_PROOF_KEYS = 1024).Fix
Reject filters that exceed parameter-level caps before any DB access:
MAX_LOG_ADDRESSES = 1000MAX_LOG_TOPICS_PER_SLOT = 1000(applied to each of the 4 topic slots)Legitimate dApp traffic — typically a handful of contracts and a few topic values — is unaffected. Block-range capping is handled separately by reth's filter settings and is intentionally out of scope here.
Files
crates/execution/flashblocks/src/rpc/log_filter_limit.rs(new) —LogFilterLimit::check()+ 5 unit testscrates/execution/flashblocks/src/rpc/mod.rs— module registrationcrates/execution/flashblocks/src/rpc/eth.rs— callLogFilterLimit::check(&filter)?at the top ofget_logsTests
accepts_empty_filteraccepts_at_address_limit/rejects_above_address_limitaccepts_at_topic_limit_in_each_slot/rejects_above_topic_limit_in_each_slot(all 4 slots)All existing flashblocks integration
get_logstests (test_get_logs_pending,test_get_logs_filter_by_address,test_get_logs_topic_filtering, …) continue to pass — they use single-address / single-topic filters far below the cap.Pattern reference
Follows the parameter-validation pattern established in #2596 (
ProofKeyLimit) and matches go-ethereum's defense against pathological RPC inputs.