Skip to content
DoS Audit finding Intermediate

JSON-RPC FilterCriteria.Addresses are unbound and can be used to DoS the RPC

The eth_getLogs JSON-RPC method did not limit the number of addresses in the filter criteria, unlike topics. An attacker could send a request with a very large number of addresses, causing the server to spend excessive time processing and potentially leading to a denial of service.

berndartmueller Follow

Originally disclosed on Code4rena

Submitted by berndartmueller

The eth_getLogs ETH JSON-RPC method returns an array of all logs matching a given filter criteria, e.g., a topic list Topics and/or a list of addresses (Addresses) that restricts matches to events created by specific contracts.

While Topics is limited to maxTopics = 4, Addresses in unbounded.

minievm:jsonrpc/namespaces/eth/filters/api.go#L366

358: // GetLogs returns logs matching the given argument that are stored within the state.
359: func (api *FilterAPI) GetLogs(ctx context.Context, crit ethfilters.FilterCriteria) ([]*coretypes.Log, error) {
360: 	if len(crit.Topics) > maxTopics {
361: 		return nil, errExceedMaxTopics
362: 	}
363: 	var filter *Filter
364: 	if crit.BlockHash != nil {
365: 		// Block filter requested, construct a single-shot filter
366: ❌ filter = newBlockFilter(api.logger, api.backend, *crit.BlockHash, crit.Addresses, crit.Topics)
367: 	} else {

This can be exploited to DoS the RPC server and bring it to a halt by sending eth_getLogs requests with a large number of addresses in the Addresses field, which takes a considerable amount of time to process.

It should be noted that the JSON-RPC server has a default request body limit of ~10MB, which can be adjusted via the max-recv-msg-size configuration option. This at least limits the Addresses field to a certain extent. However, the below the PoC demonstrates that this is not sufficient and it is still possible to DoS the server.

The same issue, not having an upper bound on the Addresses, is also observed in:

Proof of Concept

The following estimation shows how many addresses we can fit within a ~10MB JSON-RPC request limit:

  1. Each Ethereum address is 20 bytes

  2. In JSON-RPC format, each address needs to be hex-encoded with “0x” prefix:

    • 20 bytes becomes 40 hex characters
    • Plus “0x” prefix = 42 characters
  3. In JSON array format, we need:

    • Quotes around each address: +2 characters = 44 chars per address
    • Commas between addresses: +1 character
    • Square brackets: +2 characters for the whole array
  4. Each character in JSON is 1 byte

So for n addresses:

  • Total bytes = 44n + (n-1) + 2
  • Simplified: 45n + 1 bytes

With a 10MB (10,485,760 bytes) limit:

10,485,760 = 45n + 1
n = (10,485,760 - 1) / 45
n ≈ 232,905 addresses

To account for some request overhead, a more conservative estimate would be around 200,000 addresses.

The following test case demonstrates that by providing 200,000 addresses to the GetLogs function, the request takes more than 5 seconds to complete. This opens up the possibility of a DoS attack by sending a large number of addresses to the GetLogs function and repeating the request to bring the RPC to a halt.

Apply the following git diff and run the Test_GetLogs test with go test -timeout 30s -run ^Test_GetLogs$ ./jsonrpc/namespaces/eth/filters

diff --git a/jsonrpc/namespaces/eth/filters/api_test.go b/jsonrpc/namespaces/eth/filters/api_test.go
index e1ad746..7c27536 100644
--- a/jsonrpc/namespaces/eth/filters/api_test.go
+++ b/jsonrpc/namespaces/eth/filters/api_test.go
@@ -392,10 +392,27 @@ func Test_GetLogs(t *testing.T) {
 		}
 	}

+	// create a massive number of addresses and populate them into `Addresses`
+	numAddresses := 200_000
+	addresses := make([]common.Address, 0, numAddresses)
+	for i := 0; i < numAddresses; i++ {
+		addresses = append(addresses, common.BytesToAddress(contractAddr))
+	}
+
+	// time how long it takes
+	start := time.Now()
+
 	logs, err := input.filterAPI.GetLogs(context.Background(), ethfilters.FilterCriteria{
 		FromBlock: big.NewInt(tx2Height),
+		Addresses: addresses,
 	})
 	require.NoError(t, err)
+
+	elapsed := time.Since(start)
+
+	// assert that it takes at least 5 seconds
+	require.GreaterOrEqual(t, elapsed.Milliseconds(), int64(5_000))
+
 	for _, log := range logs {
 		if log.BlockNumber == uint64(tx3Height) {
 			require.Equal(t, txHash3, log.TxHash)

Recommended mitigation steps

Consider enforcing an upper limit on the number of Addresses, similar to how it’s done for Topics.

beer-1 (Initia) confirmed and commented:

This is valid finding, but only consensus breaking and taking over funding related findings can be critical.

Would like to lower severity to medium.

LSDan (judge) commented:

I disagree. This is a direct DDOS vector with next to zero cost. The ease of execution and the potential for overloading every JSON-RPC server simultaneously with a small botnet is enough to justify high risk.

beer-1 (Initia) commented:

Fixed here.

Initia mitigated:

Added a max addresses limit.

Status: Mitigation confirmed. Full details in reports from 0xAlix2, berndartmueller and Franfran.


The original report as published on Code4rena, by berndartmueller. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The GetLogs function (and similar functions) did not enforce an upper bound on the number of addresses in the filter criteria, unlike the limit on topics.

Impact

An attacker could send repeated requests with many addresses to exhaust server resources and cause a denial of service, though the default 10MB request body limit provides some restriction.

What the attacker needed

Ability to send JSON-RPC requests to the server

The fix

The issue was fixed by adding a maximum limit on the number of addresses.

How it was found

  1. Estimate how many addresses fit in a 10MB request (about 200,000).
  2. Modify the test to create 200,000 addresses and pass them to GetLogs.
  3. Run the test and observe that the request takes more than 5 seconds.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A JSON-RPC server lets programs talk to a blockchain node. The eth_getLogs method asks for event logs that match certain filters, such as which contract addresses to include. The code did not limit how many addresses you could ask for, so someone could send a request with hundreds of thousands of addresses. The server would then spend a long time checking each one, making it slow or unresponsive for other users.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by berndartmueller

View all

97 more disclosed reports, best first.

More from Initia Cosmos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.