Skip to content

Latest commit

 

History

History
88 lines (70 loc) · 2.57 KB

File metadata and controls

88 lines (70 loc) · 2.57 KB

Security Fixes - March 4, 2026

Completed ✅

1. API Authentication Middleware

  • Commit: 8445809
  • Status: Complete and tested
  • All /api/v1/* endpoints require X-API-Key header
  • /health endpoint remains public
  • Returns 401 for missing/invalid keys
  • Test Results: All 6 endpoints tested successfully

2. API Keys in Logs

  • Status: Safe
  • API keys only shown once during api-keys create command
  • Never logged in daemon output
  • No exposure in error messages

3. Replay Protection

  • Status: Already implemented
  • 5-minute timestamp window for messages
  • 32-byte random nonce per message
  • Located in auth.rs:494

4. DNS Poisoning Protection

  • Commit: 92386f2
  • Status: Complete and tested
  • Hardcoded fallback relays when DNS fails
  • Peer ID validation against trusted list
  • Automatic fallback to Railway relay
  • Test Results: Daemon successfully uses fallback when DNS unavailable

In Progress ⏸️

5. auth.rs Refactoring

  • Status: Reverted - too complex for quick fix
  • Current Size: 2202 lines
  • Recommendation: Split into modules during dedicated refactoring session
  • Proposed Structure:
    • auth/trust.rs (198 lines) - Trust scoring system
    • auth/peer.rs (1097 lines) - Peer authentication
    • auth/message.rs (302 lines) - P2P messages
    • auth/mod.rs - Re-exports and common types

6. Certificate Revocation List (CRL)

  • Status: Not implemented
  • Priority: Low
  • Mitigation: 24-hour certificate expiry limits exposure
  • Recommendation: Add on-chain revocation registry when needed

Test Commands

# Test API authentication
rm -rf ~/.gork-agent
./target/release/gork-agent init --account test.testnet --dev-mode
API_KEY=$(sqlite3 ~/.gork-agent/agent.db "SELECT value FROM kv_store WHERE key='internal_api_key';")

# Start daemon
./target/release/gork-agent daemon --port 4001 &
sleep 2

# Test without auth (should return 401)
curl -s http://127.0.0.1:4002/api/v1/status

# Test with auth (should return 200)
curl -s -H "X-API-Key: $API_KEY" http://127.0.0.1:4002/api/v1/status

# Test DNS fallback
# (Disconnect internet or block DNS, daemon will use fallback relay)

Security Recommendations

  1. Short-term:

    • ✅ API authentication
    • ✅ DNS poisoning protection
    • ⏸️ Split auth.rs for easier auditing
  2. Medium-term:

    • Add CRL for certificate revocation
    • Implement DNS-over-HTTPS for relay discovery
    • Add rate limiting per API key (not just per IP)
  3. Long-term:

    • Formal security audit
    • Penetration testing
    • Bug bounty program