Skip to content

fix(rpc): cap eth_getLogs filter addresses and topics#2712

Open
crazywriter1 wants to merge 2 commits into
base:mainfrom
crazywriter1:fix/rpc-cap-eth-getlogs-filter
Open

fix(rpc): cap eth_getLogs filter addresses and topics#2712
crazywriter1 wants to merge 2 commits into
base:mainfrom
crazywriter1:fix/rpc-cap-eth-getlogs-filter

Conversation

@crazywriter1
Copy link
Copy Markdown
Contributor

Problem

eth_getLogs is unauthenticated and accepts unbounded address and per-slot topics vectors. 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_getProof storage-key vector capped in #2596 (MAX_PROOF_KEYS = 1024).

Fix

Reject filters that exceed parameter-level caps before any DB access:

  • MAX_LOG_ADDRESSES = 1000
  • MAX_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 tests
  • crates/execution/flashblocks/src/rpc/mod.rs — module registration
  • crates/execution/flashblocks/src/rpc/eth.rs — call LogFilterLimit::check(&filter)? at the top of get_logs

Tests

  • accepts_empty_filter
  • accepts_at_address_limit / rejects_above_address_limit
  • accepts_at_topic_limit_in_each_slot / rejects_above_topic_limit_in_each_slot (all 4 slots)

All existing flashblocks integration get_logs tests (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.

@cb-heimdall
Copy link
Copy Markdown
Collaborator

cb-heimdall commented May 14, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

@crazywriter1 is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@crazywriter1 crazywriter1 force-pushed the fix/rpc-cap-eth-getlogs-filter branch from 829d2d9 to 9b22066 Compare May 14, 2026 22:04
`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.
@crazywriter1 crazywriter1 force-pushed the fix/rpc-cap-eth-getlogs-filter branch from 4df2e29 to f62e0af Compare May 15, 2026 18:47
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