Skip to content

feat: secure transport foundation - #205

Open
Migorithm wants to merge 87 commits into
mainfrom
feat/sec-2
Open

Migorithm wants to merge 87 commits into
mainfrom
feat/sec-2

Conversation

@Migorithm

Copy link
Copy Markdown
Collaborator

Summary

Establish the S0 security foundation:

  • add secure and trusted-development modes
  • load mutual TLS 1.3 certificate, key, and trust-root configuration
  • fail secure-mode startup before opening plaintext listeners
  • use ring as the rustls cryptographic provider
  • add Quinn for secure SWIM datagrams
  • split the network abstraction into TCP and UDP modules
  • adapt Quinn to EastGuard's Tokio/turmoil UDP abstraction
  • verify Quinn deterministically under turmoil

Quinn feasibility

The turmoil test verifies:

  • mutual certificate authentication
  • QUIC Retry address validation
  • QUIC datagram delivery
  • disabled 0-RTT early data
  • bounded pending handshakes and datagram buffers
  • disabled QUIC streams
  • a 1200-byte UDP payload limit
  • deterministic operation under virtual time

Quinn's Bloom-backed Retry-token log provides replay protection.

Current behavior

  • Trusted-development mode retains the existing plaintext transports.
  • Secure mode validates credential configuration and then fails closed.
  • Secure listeners are intentionally deferred to later security phases.

- Secure is the default.
- Trusted development requires --security-mode trusted-development or SECURITY_MODE=trusted-development.
- Integration environments opt in explicitly.
- The example YAML documents the mode.
QuinnUdpSocket and its turmoil test
  The deterministic turmoil test now proves:

  client Initial
        │
        ▼
  server Retry token
        │
        ▼
  client retries
        │
        ▼
  server confirms address validated
        │
        ▼
  mutual TLS handshake + QUIC datagram
  - Maximum 128 pending handshakes.
  - No bidirectional or unidirectional QUIC streams.
  - 64 × 1200-byte send and receive datagram buffers.
  - 1200-byte maximum UDP payload.
  - TLS early data/0-RTT confirmed disabled.
  - Required Retry address validation.
@Migorithm Migorithm self-assigned this Jul 27, 2026
@Migorithm Migorithm added documentation Improvements or additions to documentation feat labels Jul 27, 2026
Migorithm added 20 commits July 28, 2026 08:14
  turmoil TCP socket
        ↓
  TLS 1.3 mutual authentication
        ↓
  AuthenticatedTcpStream
        ├── encrypted byte stream
        └── authenticated peer principal

  - Added tokio-rustls.
  - Supports inbound and outbound mutual TLS.
  - Extracts both peers’ Node Certificate Principals.
  - Deterministic turmoil test exchanges ping/pong.
  - Not yet used by production actors; the explicit dead_code allowance will be removed when Raft/data transports adopt it in the next slice.
  - Focused turmoil test and all-target/all-feature clippy pass.
  - Formatting and diff checks pass.
  - RaftRpcListener now has one constructor taking the read half and explicit transport identity.
  - Raft transport uses shared node-stream halves.
  - Secure streams retain the certificate principal at the connection boundary.
  - Trusted-development tests name their mode explicitly.
  - Large TLS stream variant is boxed.
  - Mutual-TLS turmoil test and five Raft transport tests pass.
  - All-target/all-feature clippy, formatting, and diff checks pass.
  NodeTransportSecurity
          │
          ├── Raft TCP
          └── Data TCP
                ↓
          NodeTcpStream
                ├── Secure: mutual TLS + certificate principal
                └── TrustedDevelopment: plaintext

  Changes:

  - Data readers/writers now use shared node-stream halves.
  - Inbound and outbound data connections explicitly select the configured security mode.
  - Connection identity stays attached to each reader for later admission authorization.
  - No optional TLS configuration.
  - Secure startup remains fail-closed because SWIM and client listeners are not secured yet.
  - Fixed asymmetric bootstrap voter sets by reasserting known voters through the Raft log during takeover.
  - Kept strict committed-voter RPC authorization.
  - Added a focused regression test.
  - Exact failing turmoil seed now passes.
  - Full clippy, formatting, and diff checks pass.
TLS client principal
          ↓
  TransportIdentity
          ↓
  ClientController
          ↓
  future ACL checks

  Changes:

  - Renamed NodeTransportIdentity to shared TransportIdentity.
  - Captures identity before splitting the stream.
  - Stores identity on ClientController.
  - Trusted-development tests explicitly use TrustedDevelopment.
  - No ACL behavior added yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant