fix(jsonrpc): enforce maxBlockRange on eth_getFilterLogs#6842
Merged
kuny0707 merged 2 commits intoJun 17, 2026
Merged
Conversation
bladehan1
approved these changes
Jun 16, 2026
7091ccd to
8b92075
Compare
317787106
approved these changes
Jun 17, 2026
bladehan1
approved these changes
Jun 17, 2026
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.
What does this PR do?
Applies the
jsonRpcMaxBlockRangecap toeth_getFilterLogs, closing a gap where the block-range limit could be bypassed via the filter path.eth_getLogsbuilds itsLogFilterWrapperwithcheckBlockRange=true, so the cap is enforced. Buteth_newFilterbuilds the wrapper withcheckBlockRange=false, andeth_getFilterLogsreuses that stored wrapper without re-checking — so the cap was never applied when querying logs through a filter. A client could create a filter with a wide range (e.g.fromBlock=0x0,toBlockfar ahead) and calleth_getFilterLogsto trigger an unbounded historical scan (CPU/IO pressure, potential OOM).Changes:
LogFilterWrapperconstructor into a reusablevalidateBlockRange(currentMaxBlockNum)method (logic and error message unchanged).eth_getFilterLogsnow callsvalidateBlockRangeagainst the current head before scanning, mirroringeth_getLogs.JsonRpcInvalidParamsExceptionon thegetFilterLogsimpl (the interface and its@JsonRpcError(code=-32602)mapping already declared it).Creation-time behavior is intentionally left unchanged:
eth_newFilterstill accepts wide ranges (no creation-time gate), matching geth's "creation accepts, query enforces" model and preserving forward polling viaeth_getFilterChanges(which does not scan a range).Why are these changes required?
Without this,
jsonRpcMaxBlockRangeonly protectseth_getLogs; theeth_newFilter+eth_getFilterLogspath silently bypasses it, leaving a DoS vector on full nodes with JSON-RPC enabled.This PR has been tested by:
Follow up
Extra details