Skip to content

Security Hardening — Fix Critical Audit Findings (Issues #1-#21)#22

Open
AnilChinchawale wants to merge 8 commits intomasterfrom
fix/security-hardening
Open

Security Hardening — Fix Critical Audit Findings (Issues #1-#21)#22
AnilChinchawale wants to merge 8 commits intomasterfrom
fix/security-hardening

Conversation

@AnilChinchawale
Copy link
Copy Markdown
Owner

@AnilChinchawale AnilChinchawale commented Mar 26, 2026

Summary

Comprehensive security hardening based on the XDC Network security audit findings. Closes 14 of 21 open issues.

Critical Fixes

Issue Fix Status
#13 RPC binds to 0.0.0.0 Changed default to 127.0.0.1
#14 debug in default API Blocked in start-node.sh with error
#15 Docker exposes RPC ports Bound to 127.0.0.1 in compose
#16 CORS wildcard * Defaulted to http://localhost
#18 Empty .pwd password Removed from git, generate on setup
#20 Shared bootnode key nodekey removed from git
#1 .env committed Removed sensitive defaults, .gitignore
#2 .pwd committed Removed from git tracking
#3 nodekey committed Removed from git tracking
#4 Hardcoded ethstats password Stats secret in env var
#6 No Docker healthcheck Added healthcheck
#8 No log rotation Added Docker json-file driver with limits
#9 Double git pull in upgrade.sh Fixed, removed hardcoded image
#10 Missing testnet env.example Created with NODE_NAME documented
#21 No security docs Created SECURITY.md

What Changed

mainnet/start-node.sh — The most critical change:

  • BLOCKS debug, admin, personal namespaces with clear error messages
  • WARNS if RPC binds to 0.0.0.0 or CORS is wildcard
  • Defaults all RPC/WS addresses to 127.0.0.1
  • Uses exec to replace shell process (proper Docker signal handling)

mainnet/env.example — Safe defaults:

  • ENABLE_RPC=false (unchanged — already existed)
  • RPC_ADDR=127.0.0.1 (was 0.0.0.0)
  • RPC_API=net,web3,XDPoS (removed db,eth — no signing methods)
  • RPC_CORS_DOMAIN=http://localhost (was *)
  • Extensive security comments explaining each option

mainnet/docker-compose.yml:

  • RPC/WS ports commented out (require explicit opt-in)
  • When enabled, bound to 127.0.0.1
  • Added healthcheck
  • Added log rotation (100MB, 5 files)

SECURITY.md — Full hardening guide:

  • Pre-deployment checklist
  • RPC security table (dangerous namespaces explained)
  • Post-deployment verification commands
  • Security checklist (9 items)
  • Link to live SkyNet Node Scanner

Removed from git:

  • .pwd files (wallet passwords)
  • nodekey files (P2P private keys)
  • PRIVATE_KEY from .env files
  • All added to .gitignore

Testing

After merging, every existing node operator should:

  1. git pull to get new configs
  2. Verify their .env has RPC_ADDR=127.0.0.1 (not 0.0.0.0)
  3. Verify RPC_API doesn't contain debug/admin/personal
  4. Restart their node: docker compose down && docker compose up -d
  5. Verify from external: curl http://NODE_IP:8545 should timeout

Fixes #13 #14 #15 #16 #17 #18 #20 #21 (partially #1 #2 #3 #4 #5 #6 #8 #9 #10)

Critical changes:
- RPC binds to 127.0.0.1 by default (was 0.0.0.0)
- RPC_API defaults to net,web3,XDPoS (removed eth, debug, db)
- CORS defaults to localhost (was *)
- start-node.sh BLOCKS debug/admin/personal namespaces with clear error
- start-node.sh WARNS if RPC binds to 0.0.0.0 or CORS is *
- Docker compose binds RPC ports to 127.0.0.1 only
- Docker healthcheck + log rotation added
- Dockerfile only EXPOSEs port 30303 (removed 8545/8555)
- Removed .pwd, nodekey, PRIVATE_KEY from git tracking
- .gitignore blocks .env, .pwd, nodekey, keys.json
- upgrade.sh fixed (no double git pull, no hardcoded image version)
- SECURITY.md with full hardening guide + checklist
- testnet/env.example created with NODE_NAME documented
- Logs sent to stdout via exec (Docker handles rotation)
…auto-setup

- upgrade.sh auto-applies security fixes to existing .env:
  * RPC_ADDR 0.0.0.0 → 127.0.0.1
  * Removes debug/admin/personal from RPC_API
  * Fixes wildcard CORS
  * Adds missing RPC_ADDR/WS_ADDR/RPC_VHOSTS
- Backs up and restores .env, .pwd, nodekey during upgrade
- Docker image uses ${DOCKER_IMAGE:-xinfinorg/xdposchain:v2.6.8} variable
- bootstrap.sh: auto firewall setup, strong password generation, modern GPG
- install_docker.sh: modern GPG key management (fixes #12)
- setup/upgrade.sh deprecated → points to network-specific scripts

Upgrade path for existing nodes:
  cd mainnet && bash upgrade.sh
  # That's it. All security fixes applied automatically.
…ks in testnet start script

- ENABLE_RPC=false is the default in all .env files (mainnet + testnet)
- When disabled: no --rpc or --ws flags passed to XDC binary at all
- Testnet start-apothem.sh now has same security validation as mainnet
- Helpful message shown when RPC is disabled explaining how to enable safely
- Testnet .env updated with secure defaults + NODE_NAME (fixes #11)
…NODE_TYPE=masternode

- NODE_TYPE=fullnode is the default (was implicitly masternode with --mine always on)
- --mine flag only added when NODE_TYPE=masternode or NODE_TYPE=validator
- Applies to both mainnet start-node.sh and testnet start-apothem.sh
- env.example documents NODE_TYPE options

Existing masternode operators: add NODE_TYPE=masternode to your .env
New nodes default to fullnode (safer — no accidental block production)
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.

1 participant