Skip to content

rpc: add method name length limit #31711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MatusKysel
Copy link

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
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.

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