security: harden gRPC server — disable by default, bind to localhost#2078
Open
harshinsecurity wants to merge 1 commit into0xPolygon:developfrom
Open
security: harden gRPC server — disable by default, bind to localhost#2078harshinsecurity wants to merge 1 commit into0xPolygon:developfrom
harshinsecurity wants to merge 1 commit into0xPolygon:developfrom
Conversation
- Add 'Enabled' field to GRPCConfig (default: false), requiring explicit --grpc.enabled flag to start the gRPC server - Change default bind address from 0.0.0.0:3131 to 127.0.0.1:3131 - Guard gRPC server startup with Enabled check in NewServer() - Add --grpc.enabled CLI flag in flags.go - Fix GetGrpcAddr() to use net.SplitHostPort instead of string slice - Update docs and test helper for compatibility The gRPC server currently starts unconditionally on all interfaces (0.0.0.0:3131) with no authentication, no TLS, and no way to disable it. This is inconsistent with HTTP-RPC and WS-RPC which are disabled by default. An attacker with network access can invoke sensitive RPCs including ChainSetHead (reorg), PeersAdd/Remove (eclipse attacks), and StatusBorStatus (reconnaissance) without credentials.
|
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.



Summary
The gRPC server in Bor currently starts unconditionally on all network interfaces (
0.0.0.0:3131) with:This is inconsistent with HTTP-RPC and WS-RPC, which are disabled by default and bind to
localhost. Any node with port 3131 reachable from the network exposes sensitive RPCs without credentials.Impact
An unauthenticated attacker with network access to port 3131 can:
ChainSetHead(number)PeersAdd(enode)/PeersRemove(enode)PeersList/PeersStatusStatusBorStatusDebugPprofThe most significant risk is Denial of Service: repeatedly calling
ChainSetHead(0)forces the node to re-sync from genesis, effectively taking it offline. While this cannot steal funds or halt the Polygon network (requires multiple validators), it can degrade individual node availability.CVSS 3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H → 8.6 High
Changes
internal/cli/server/config.goEnabled boolfield toGRPCConfig; default tofalse; change bind address from:3131to127.0.0.1:3131internal/cli/server/server.goconfig.GRPC.Enabledcheck; fixGetGrpcAddr()to usenet.SplitHostPortinstead of brittle[1:]string sliceinternal/cli/server/flags.go--grpc.enabledCLI boolean flaginternal/cli/server/helper.goconfig.GRPC.Enabled = truein test mock so existing tests passdocs/cli/server.md--grpc.enabledflag and updated default addressBehavior Change
--grpc.enabled0.0.0.0:3131(all interfaces)127.0.0.1:3131(localhost only)--grpc.enabledThis is a breaking change for anyone relying on the gRPC server being on by default. Operators who need gRPC must now explicitly pass
--grpc.enabled. This is the same pattern used by--httpand--wsand is the secure default.How to Test
For questions or discussion, feel free to reach out: hi@harshinsecurity.in