Skip to content

Commit e4b8058

Browse files
NathanBSCzlacfzy
andauthored
eth/gasprice: add query limit for FeeHistory to defend DDOS attack (ethereum#29644)
* eth/gasprice: add query limit for FeeHistory to defend DDOS attack * fix return values after cherry-pick --------- Co-authored-by: Eric <[email protected]>
1 parent 3e896c8 commit e4b8058

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

eth/gasprice/feehistory.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
// maxBlockFetchers is the max number of goroutines to spin up to pull blocks
4545
// for the fee history calculation (mostly relevant for LES).
4646
maxBlockFetchers = 4
47+
maxQueryLimit = 100
4748
)
4849

4950
// blockFees represents a single block for processing
@@ -240,6 +241,9 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks uint64, unresolvedL
240241
if len(rewardPercentiles) != 0 {
241242
maxFeeHistory = oracle.maxBlockHistory
242243
}
244+
if len(rewardPercentiles) > maxQueryLimit {
245+
return common.Big0, nil, nil, nil, nil, nil, fmt.Errorf("%w: over the query limit %d", errInvalidPercentile, maxQueryLimit)
246+
}
243247
if blocks > maxFeeHistory {
244248
log.Warn("Sanitizing fee history length", "requested", blocks, "truncated", maxFeeHistory)
245249
blocks = maxFeeHistory

0 commit comments

Comments
 (0)