Skip to content

Conversation

@MatusKysel
Copy link
Contributor

rpc: add method name length limit

This change adds a limit of 256 characters for RPC method names to prevent potential abuse where large method names could lead to large response sizes.

The limit is enforced in:

  • handleCall for regular RPC method calls
  • handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit functionality for both regular method calls and subscriptions.

@MatusKysel MatusKysel requested a review from fjl as a code owner April 25, 2025 08:57
@jwasinger
Copy link
Contributor

We control which RPC methods are registered in Geth. I don't see the practical gain from including this PR.

@MatusKysel
Copy link
Contributor Author

We control which RPC methods are registered in Geth. I don't see the practical gain from including this PR.

Even though Geth only registers a fixed set of RPC methods, the error handler currently echoes the entire (unknown) method name back to the caller. An attacker can exploit this by sending a request whose method field is arbitrarily long; Geth will then include that same string verbatim in the error payload. The result is roughly a 2 × bandwidth amplification (request bytes + reflected bytes) that can be repeated at scale to waste network and CPU resources. Returning a constant error message—or at least truncating the reflected method name—would close this vector with virtually no downside.

@fjl fjl added this to the 1.15.11 milestone May 5, 2025
@fjl fjl merged commit b135da2 into ethereum:master May 5, 2025
1 of 2 checks passed
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Jul 3, 2025
This change adds a limit for RPC method names to prevent potential abuse
where large method names could lead to large response sizes.

The limit is enforced in:
- handleCall for regular RPC method calls
- handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit
functionality for both regular method calls and subscriptions.

---------

Co-authored-by: Felix Lange <[email protected]>
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
This change adds a limit for RPC method names to prevent potential abuse
where large method names could lead to large response sizes.

The limit is enforced in:
- handleCall for regular RPC method calls
- handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit
functionality for both regular method calls and subscriptions.

---------

Co-authored-by: Felix Lange <[email protected]>
gzliudan pushed a commit to gzliudan/XDPoSChain that referenced this pull request Sep 1, 2025
This change adds a limit for RPC method names to prevent potential abuse
where large method names could lead to large response sizes.

The limit is enforced in:
- handleCall for regular RPC method calls
- handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit
functionality for both regular method calls and subscriptions.

---------

Co-authored-by: Felix Lange <[email protected]>
gzliudan added a commit to XinFinOrg/XDPoSChain that referenced this pull request Sep 3, 2025
This change adds a limit for RPC method names to prevent potential abuse
where large method names could lead to large response sizes.

The limit is enforced in:
- handleCall for regular RPC method calls
- handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit
functionality for both regular method calls and subscriptions.

---------

Co-authored-by: Matus Kysel <[email protected]>
Co-authored-by: Felix Lange <[email protected]>
gballet pushed a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
This change adds a limit for RPC method names to prevent potential abuse
where large method names could lead to large response sizes.

The limit is enforced in:
- handleCall for regular RPC method calls
- handleSubscribe for subscription method calls

Added tests in websocket_test.go to verify the length limit
functionality for both regular method calls and subscriptions.

---------

Co-authored-by: Felix Lange <[email protected]>
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.

3 participants