Every wallet, exchange, indexer and dApp backend trusts an RPC endpoint to tell it what the chain says and to carry its transactions, yet those endpoints are often an exposed node port or a provider API key pasted into front-end code. This guide covers the infrastructure between your applications and the blockchain: self-run execution and consensus nodes, the JSON-RPC, WebSocket, Engine and beacon APIs they expose, and third-party node providers reached with API keys. It explains which interfaces must stay private, how to treat provider keys as non-human identities, how to avoid trusting a single source of chain data, and what to monitor. It is written for Web3 platform, DevOps and security engineers. Examples use Ethereum clients (Geth and Lighthouse) because their documentation is explicit; the principles apply to other chains. For the wider ledger threat model see the Blockchain and Distributed Ledger Security Guide.
Key takeaways
- Node APIs are not internet services. Geth's maintainers state that the JSON-RPC, beacon and GraphQL endpoints are not designed to withstand hostile clients; keep them on loopback or a private network and front any necessary exposure with a hardened proxy.
- Namespaces decide the blast radius. Read-only
eth,netandweb3are very different fromadmin,debug,minerandtxpool; expose only what each consumer needs, per transport. - Provider API keys are NHI credentials. Give each application and environment its own key with an owner, allowlists, method restrictions and a rotation path, and never ship a privileged key in browser code.
- One RPC source is one point of truth and failure. For balances, deposits and anything that moves value, cross-check against an independent source and wait for an appropriate block tag such as
finalized. - Keys never live on RPC hosts. Signing belongs in a separate signer or remote signing service; validator keys, the Engine API JWT secret and provider keys each need their own custody.
Node and RPC architecture
Since the Merge an Ethereum node is two programs: an execution client (for example Geth) and a consensus client (for example Lighthouse), plus an optional validator client for staking. Each exposes interfaces with very different trust requirements.
| Interface | Default port (client documentation) | Default bind | Consumer | Exposure rule |
|---|---|---|---|---|
| P2P (devp2p) | 30303 TCP and UDP (Geth) | All interfaces | Other nodes | Public by design; the only port Geth recommends opening |
| JSON-RPC over HTTP | 8545 (Geth, off until --http) | 127.0.0.1 | Applications, wallets, indexers | Private; trusted machines only |
| JSON-RPC over WebSocket | 8546 (Geth, off until --ws) | Set with --ws.addr | Subscriptions, event listeners | Private; set --ws.origins |
| IPC | Unix socket or Windows named pipe | Local only | Local tools | All namespaces enabled; protect by file permissions |
| Engine API (authenticated) | 8551 (Geth) | localhost | Consensus client only | Never exposed; JWT authenticated |
| Beacon node API | 5052 (Lighthouse, with --http) | 127.0.0.1 | Validator client, monitoring | Private; Lighthouse warns against public exposure |
| Validator client API | Client specific | Local | Operators, key management | Private; bearer token required |
Third-party node providers replace the self-run node for many teams. They remove the operational burden but add three things to manage: an API key that authenticates you, a supplier whose answers your systems believe, and a dependency whose outage stops your service. Many organisations run both: their own nodes for sensitive reads and signing paths, and providers for scale and redundancy.
Choosing self-run, provider or both
| Factor | Self-run nodes | Node provider | Hybrid |
|---|---|---|---|
| Data trust | You verify the chain yourself | You trust the provider's response | Cross-check between sources |
| Main credential risk | Host access, Engine JWT, validator keys | Provider API keys | Both |
| Exposure risk | Misconfigured RPC binding or firewall | Key leaked in code or logs | Both, with more inventory to keep |
| Availability | Your operations team | Provider SLA and rate limits | Failover between sources |
| Fits | Validators, custodians, high-value settlement | Prototypes, read-heavy dApps, small teams | Exchanges, wallets, payment platforms |
Exposed RPC endpoints and admin APIs
Geth's security documentation is direct: block inbound traffic to the JSON-RPC port except from explicitly trusted machines, and allow only the P2P port. It warns that exposing JSON-RPC, beacon or GraphQL endpoints to untrusted networks risks out-of-memory crashes, falling behind the chain through resource starvation, and attempts to steal funds through spurious signing requests, depending on which namespaces are enabled. Geth's RPC documentation adds that bots actively scan for HTTP-enabled nodes.
Namespaces to keep private
| Namespace | What it exposes | Guidance |
|---|---|---|
eth, net, web3 | Chain data, transaction submission, network and client information | Geth's HTTP default set; acceptable for trusted application consumers behind a proxy |
txpool | Contents and status of the pending transaction pool | Internal only; reveals pending activity |
debug | Tracing, profiling and low-level node internals | Geth recommends against enabling it over HTTP; heavy calls are a denial of service vector |
admin | Peer management, node information, starting and stopping RPC servers | IPC only, never on a network transport |
miner | Block production settings | IPC only |
personal | Legacy account management and signing | Removed from Geth; on any client that still offers account signing over RPC, keep it off network transports |
engine | Consensus to execution control | Authenticated port only, never shared with applications |
Hardening settings (Geth examples)
- Bind address: leave
--http.addrat 127.0.0.1 unless a proxy on another host must reach it, and then bind to a private interface, never 0.0.0.0 on a public host. - API list: set
--http.apiand--ws.apiexplicitly to the minimum set; do not copy examples that enableadmin,debug. - Browser controls:
--http.corsdomain(browser enforced) and--ws.originsshould list specific origins, never*;--http.vhosts(server enforced, default localhost) should list the hostnames your proxy uses. - Account unlocking: Geth blocks account unlocking when HTTP or WS is enabled; do not override this with
--allow-insecure-unlock. - Resource caps: review
--rpc.gascap(cap on gas foreth_calland estimates),--rpc.txfeecap,--rpc.batch-request-limit(default 1,000) and--rpc.batch-response-max-sizeto bound expensive requests. - Replay protection: leave
--rpc.allow-unprotected-txsoff so the node rejects transactions not signed with EIP-155 chain protection. - Side ports: metrics and profiling servers (
--metrics.addr, pprof) and GraphQL should be bound locally or to a monitoring network only.
Engine API and beacon API
The Engine API specification requires execution clients to expose the authenticated engine namespace on a separate port (default 8551), authenticated with a JWT using HMAC SHA-256 from a shared 256-bit secret, and to reject the none algorithm. The specification says the scheme protects against an RPC port exposed to the internet or to a browser, but is not designed to stop an attacker who can sniff traffic from reading it or replaying earlier messages, and it only requires an iat claim within about 60 seconds. Keep the execution and consensus clients on the same host or a private link, store jwt.hex with owner-only permissions, and never reuse the secret across nodes. Lighthouse's documentation tells operators not to expose the beacon node API to the public internet because some endpoints trigger heavy processing, recommends an SSH tunnel, firewall allowlist or rate-limiting proxy for remote access, and warns that --http-allow-origin lets websites in the same browser reach the node.
If an endpoint must be reachable, Geth suggests a proxy with TLS termination, a web application firewall or application-level filtering, rate limiting, logging and monitoring. Filter by JSON-RPC method, not just by URL, because every call goes to the same path. See the OWASP API Top 10 API8 Security Misconfiguration Guide.
Node provider API keys as NHIs
A provider API key, or the token embedded in a provider URL, is a bearer credential: anyone holding it can spend your request quota, read through your account and, if the provider offers them, use management or transaction relay features. Treat it as a non-human identity with an owner, a purpose and a lifecycle. See the API Key Management Guide.
- One key per application and environment: separate keys for production backend, staging, CI and each front end, so one leak does not force a rotation everywhere and logs show which consumer misbehaved.
- Scope with every control the provider offers: typical controls in provider dashboards include allowed origins (for browser keys), allowed IP addresses or ranges (for server keys), allowed contract addresses, allowed JSON-RPC methods, per-key rate or spend limits, and a separate secret for request signing. Use all that apply; confirm the exact options in your provider's documentation.
- Browser keys are public: anything in front-end code can be read. Restrict such keys to origin allowlists and read-only methods, accept that they can be copied, and route sensitive calls through your own backend.
- Store server keys in a secrets manager: not in repositories, container images,
.envfiles committed by mistake or RPC URLs written to logs. Strip the key from URLs before logging. See the Secrets Management Guide. - Rotate on a schedule and on events: provision the new key, deploy it, confirm traffic has moved, then revoke the old key. Rotate immediately on suspected exposure, staff departure from the owning team or unexplained usage. See the API Key Leak Response Playbook.
- Protect the provider account itself: the dashboard login can mint new keys and remove restrictions. Use SSO or strong MFA, limit admin roles and review members.
Validator key separation
Validator, withdrawal and Engine JWT secrets must never sit on a host whose RPC is reachable by applications. Lighthouse describes remote signing as a validator client outsourcing signing to a separate server so the validator client does not hold private keys, while warning that remote signing adds its own security and slashing risks and suits enterprise users who understand them. The validator client API itself requires a bearer token stored in the validators directory; protect that file like a key. Use separate hosts or at least separate trust zones for RPC serving, consensus and execution clients, and signing. For key custody, slashing protection and migration see the Staking and Validator Key Security Guide.
Request integrity and data trust
An RPC response is a claim about chain state. A faulty, lagging, compromised or malicious endpoint can return a wrong balance, a missing log or a transaction that later disappears in a reorganisation. Design for that.
- Use the right block tag: the Ethereum JSON-RPC specification defines
latest,safe,finalizedandpending. Credit deposits and release withdrawals againstfinalized(or your chosen confirmation policy), notlatestorpending. - Cross-check value-moving reads: query at least two independent sources (two providers, or a provider and your own node) for deposits, balances and contract state that trigger payouts, and alert on disagreement rather than picking one.
- Check chain identity: verify
eth_chainIdat start-up and on reconnect so a misrouted endpoint cannot serve another network's data. - Watch freshness: compare head block number and timestamp across sources; a lagging endpoint silently serves stale state.
- Do not trust the RPC to sign: sign transactions locally or in a signer, then broadcast raw transactions. The endpoint should never hold keys or decide what is signed.
- Consider transaction privacy: transactions sent through a public endpoint are visible in the public mempool before inclusion; decide whether your use case needs a private submission route.
Failover between providers improves availability; cross-checking improves integrity. They are different designs. A client library that silently fails over to whichever endpoint answers first gives you neither assurance. See the OWASP API Top 10 API10 Unsafe Consumption of APIs Guide.
Monitoring and rate limiting
Log at the proxy or gateway in front of your nodes and in each provider dashboard. What to watch:
- Method mix: calls to namespaces outside the allowed set, sudden growth in
debug_*,eth_getLogsover wide ranges oreth_callwith high gas. - Sources: requests from outside the IP allowlist, unexpected origins on browser keys, and traffic to node ports from the internet at the firewall.
- Usage anomalies: provider usage or spend per key against baseline; a spike often means a leaked key.
- Node health: peer count, sync status, head lag, memory and disk, and the Engine API connection between clients.
- Data disagreement: cross-check failures between sources.
Apply rate limits per key, per source IP and per method, with lower limits on expensive methods. OWASP API4:2023 Unrestricted Resource Consumption describes exactly this class of risk. See the OWASP API Top 10 API4 Unrestricted Resource Consumption Guide.
Metrics that show it is working
- Node RPC, Engine and beacon ports reachable from the internet: target zero, verified by external scan.
- Share of provider keys with an owner, an allowlist and a rotation in the last 90 days.
- Provider keys found in code or logs by secret scanning, and time to revoke.
- Cross-source disagreement events per month, and time to resolve.
- Head lag of each RPC source against the best source.
Implementation, failure patterns and framework mapping
- Inventory: list every node, every exposed port, every provider account and every key, with owner and consumer.
- Scan from outside: confirm which node ports answer from the internet; close anything except P2P.
- Minimise namespaces: set API lists explicitly per transport and restart in a staging environment first; confirm applications still work.
- Introduce a proxy: TLS, method allowlist, rate limits and logging in front of any shared RPC; run in log-only mode for a week, then enforce. Keep the previous configuration for rollback.
- Re-issue provider keys: one per consumer with restrictions, moved into the secrets manager; revoke legacy shared keys once traffic has moved.
- Separate signing: move any key material off RPC hosts into a signer or remote signer.
- Add cross-checks and alerts: second data source for value-moving reads, and the monitoring above.
Common failure patterns
- Binding to 0.0.0.0 for convenience: a node started with HTTP on all interfaces and a permissive firewall becomes a public RPC that scanners find.
- Copied flags: tutorials that enable
admin,debug,txpooland wildcard CORS end up in production. - One provider key everywhere: the same unrestricted key in the front end, backend and CI means a leak forces a disruptive rotation and hides which system was abused.
- Keys in URLs in logs: provider URLs containing the key are written to application logs, error trackers and support tickets.
- Single source of truth: deposits credited on one provider's
latestview without confirmation policy or cross-check. - Signing on the RPC host: unlocked accounts or keystores on a node that also serves applications.
| Framework | Reference | Where it applies |
|---|---|---|
| NIST SP 800-53 Rev. 5 | SC-7 Boundary Protection; SC-5 Denial-of-service Protection | Private RPC, proxies, rate limiting |
| NIST SP 800-53 Rev. 5 | IA-5 Authenticator Management; SC-12 Cryptographic Key Establishment and Management | Provider keys, Engine JWT secret, signer keys |
| NIST SP 800-53 Rev. 5 | AU-6 Audit Record Review, Analysis, and Reporting; SR-3 Supply Chain Controls and Processes | RPC logging and provider dependency |
| NIST CSF 2.0 | PR.AA-01; PR.IR-01; DE.CM-01 | Credential management, network protection, monitoring |
| OWASP API Security Top 10 2023 | API2 Broken Authentication; API4 Unrestricted Resource Consumption; API8 Security Misconfiguration; API10 Unsafe Consumption of APIs | Keys, resource abuse, exposed namespaces, trusting provider data |
| MITRE ATT&CK v20 | T1190 Exploit Public-Facing Application; T1552.001 Credentials In Files; T1496 Resource Hijacking; T1499 Endpoint Denial of Service | Exposed endpoints, keys in code and config, quota abuse, heavy-call exhaustion |
Practitioner checklist
- Confirm by external scan that only the P2P port of each node is reachable from the internet.
- Set HTTP and WS API lists explicitly; keep
admin,debug,minerandtxpooloff network transports. - Replace wildcard CORS, origins and vhosts with specific values.
- Keep the Engine API on localhost or a private link with an owner-only JWT secret per node pair.
- Issue one restricted provider key per application and environment, stored in a secrets manager, with an owner and rotation date.
- Strip keys from logged RPC URLs and add provider key patterns to secret scanning.
- Cross-check value-moving reads against a second source and use
finalizedor an explicit confirmation policy. - Keep all signing keys off RPC hosts, in a signer or remote signer.
- Rate limit per key, IP and method, and alert on usage spikes and head lag.
Standards and references
- Go Ethereum: Security
- Go Ethereum: JSON-RPC Server
- Ethereum execution-apis: Engine API Authentication
- ethereum.org: JSON-RPC API
- Lighthouse Book: Beacon Node API
- Lighthouse Book: Remote Signing with Web3Signer
- OWASP: API Security Top 10 2023
Related NHI Mgmt Group resources: Blockchain and Distributed Ledger Security Guide · Staking and Validator Key Security Guide · API Key Management Guide · Web3 and Crypto Security Guide