vagusQUIC and WebTransport relay for services behind NAT

☰ Contents · Reference › Security and threat model

Security and threat model

Trust boundaries, cryptographic controls, threats, and residual risks of vagus. To report a vulnerability, follow neuroplastio's security policy: email security@neuroplast.io instead of opening a public issue.

Browser admission layers origin checks, single-use tickets, per-source rate limits, passes/clearances, and optional Turnstile verification onto this baseline model.

Security goals and non-goals

With certificate pinning enabled:

  1. Each service hostname (<route-id>.<domain>) embeds the base32 SHA-256 hash of its Ed25519 identity key. That key signs the service's leaf certificates, so any client knowing only the hostname can distinguish the real service from anyone else, including the relay operator. vagus clients enforce pinning by default.
  2. Application TLS (QUIC/WebTransport) and Noise NKhfs (WebSocket fallback) terminate at the service using hybrid post-quantum key exchange (X25519MLKEM768 / ML-KEM-1024). The relay never has leaf or Noise private keys and cannot decrypt traffic or impersonate the service.
  3. A connector claims a route ID only by signing a channel-bound transcript over its control TLS session with the matching identity key.
  4. vagus connect forwards datagrams only to the single fixed UDP address in -backend. A compromised relay cannot redirect traffic to other hosts or ports.

Guarantees 1 and 2 require pinning. Clients that opt out of pinning trust the relay operator, just as any TLS client trusts a domain's DNS operator.

Out of scope:

  • Metadata privacy: the relay sees server names, client and connector IP addresses and ports, packet sizes, counts, direction, timing, WebSocket Origin headers, and pass/clearance client keys.
  • Application authentication: user login, authorization, and device pairing stay in your service. A route ID appears in DNS and plaintext SNI, so it is public, never a secret.
  • Connector allowlisting: the relay verifies that a connector owns the key for the route ID it claims, not whether that key is permitted on the relay. Firewall -control for a private relay.

Post-quantum key exchange

Every key exchange that protects vagus traffic uses hybrid ML-KEM (FIPS 203), so recorded ciphertext remains confidential against harvest-now-decrypt-later attacks unless both the classical and ML-KEM components are broken:

  • The vagus/1 control tunnel (vagus relay -control, vagus connect, connector.Dial, connector.Probe) requires hybrid P-384 + ML-KEM-1024 (SecP384r1MLKEM1024, IANA 0x11ED, protocol.KeyExchange). The relay rejects connectors that offer only X25519MLKEM768.
  • Browser-facing and service-facing TLS 1.3 (vagus relay -https, vagus handoff serve, pintls.ClientConfig, and the bundled examples) require hybrid X25519 + ML-KEM-768 (X25519MLKEM768). For relayed QUIC/WebTransport, vagus does not terminate application TLS, so post-quantum negotiation depends on the client and service: Chrome 131+, Firefox 132+, Safari 26+, and Go 1.24+ negotiate X25519MLKEM768 by default, and services can require it via CurvePreferences. The relay buffers up to 8 QUIC Initial packets (16 KiB) to reassemble multi-packet post-quantum ClientHello flights.
  • WebSocket fallback sessions run Noise_NKhfs_25519+MLKEM1024_ChaChaPoly_SHA256 end to end between browser and connector, generating a fresh ephemeral ML-KEM-1024 key per session and sending the request path in the first transport message so both the path and stream data are sealed under ML-KEM-1024 + X25519 (even against a malicious relay recording WebSocket frames).
  • Native handoff uses symmetric AES-256-GCM with a random 256-bit key and no key exchange.
  • Authentication remains classical: Ed25519 (identity keys, statements, leaf extensions, admission proofs, passes, clearance keys), ECDSA P-256 (leaf certificates, as required by WebTransport serverCertificateHashes), the X25519 static Noise key authenticating the service in WebSocket sessions, and Web PKI relay certificates. These matter only against an attacker with a quantum computer during a live connection, not against recorded ciphertext.

Certificate pinning

The service's Ed25519 identity key vouches for its leaf certificates in two ways (pkg/pin and pkg/pin/pintls):

  • Signed statements: the identity key signs the SHA-256 hashes and validity windows of up to 4 current and upcoming leaf certificates, up to 4 X25519 Noise static keys, and up to 2 KiB of optional application data. The connector publishes this statement to the relay (GET /v1/statements/<route-id>). Because statements are self-authenticating, any channel can deliver them. Browsers verify the signature and key hash against the route ID and pass the leaf hashes to WebTransport's serverCertificateHashes (see Browser client for refusal codes).
  • Leaf certificate extension: each leaf embeds the identity key's signature over its SubjectPublicKeyInfo in a non-critical X.509 extension (pintls.ExtensionOID, 1.3.6.1.4.1.67949.1.1, under neuroplastio's IANA Private Enterprise Number). Go clients verify this extension during the TLS handshake via pintls.ClientConfig(routeID, base) without fetching a statement.

Distinct domain-separation prefixes ("vagus statement v1\x00", "vagus leaf v1\x00", "vagus pass v1\x00", "vagus admission v1\x00", "vagus clearance v1\x00", and the TLS exporter labels) prevent signatures from one context being replayed in another.

Leaves are self-signed ECDSA P-256 certificates valid for 13 days, staying below the 14-day browser cap on hash-pinned WebTransport certificates. The keyring (vagus connect -leaf-dir or pintls.Keyring) generates the next leaf when the newest has under 6 days left and advertises it immediately, then switches to serving it when the active leaf has under 24 hours left. A browser offline for two weeks must fetch a fresh statement.

Statements have no built-in sequence number, so a malicious relay can replay an older signed statement. Because the relay lacks leaf private keys, replaying an old statement causes denial of service rather than interception unless a listed leaf's private key also leaked (in which case exposure ends when that leaf expires). Applications needing strict freshness can embed a sequence number or timestamp in the statement's signed data field.

In browsers, pinning runs inside page JavaScript or Wasm. Serve your web app from a trusted origin, never from an untrusted relay.

Opting out of pinning

Setting trustRelayOperator: true in the browser client (or relying on standard CA verification in a native client) delegates trust to Web PKI. Whoever controls DNS for the relay domain can obtain a CA certificate for <route-id>.<domain> and impersonate the service. Only opt out when you operate or fully trust the relay.

Trust boundaries and TLS separation

Application TLS (or Noise NKhfs over WebSocket fallback) runs unbroken between client and service, riding inside the connector's outbound vagus/1 control tunnel across NAT. The two TLS connections share no keys:

Property Application TLS (client ↔ service) Control TLS (connector ↔ relay)
Terminates at Client and service vagus connect and vagus relay
Minimum version TLS 1.3 when pinned TLS 1.3
Key exchange Hybrid PQ (X25519MLKEM768 in pintls and modern browsers) Hybrid PQ (SecP384r1MLKEM1024 enforced)
ALPN Application protocol (e.g., h3) vagus/1
Server auth Leaf certificate pinned to route ID Relay cert verified against system roots or -ca
Client auth Application-defined Ed25519 signature over TLS exporter transcript

Keys and credentials

Key Location Role
Identity key (endpoint.pem) Connector host (0600) SHA-256 derives the route ID; proves route ownership and signs statements, leaves, and passes.
Leaf and Noise keys (-leaf-dir: key.pem, keyring.msgp) Connector host (keyring.msgp 0600; cert.pem/key.pem 0640; dir 0750) ECDSA P-256 private keys for active/upcoming leaves, plus X25519 Noise keys in keyring.msgp.
Relay TLS key Relay host Authenticates -control and -https for the relay's own hostnames only.
Relay ACME account key Relay host (if using ACME) Issues and revokes the relay certificate.
Turnstile secret Relay host (if enabled) Verifies browser challenge tokens with Cloudflare Siteverify.
Pass / clearance client key Client (browser non-extractable WebCrypto key) Signs ticket requests so a stolen pass or clearance cannot be used without the key.
Clearance HMAC key Relay RAM (random per start) Authenticates relay-issued clearances; cleared on restart.

Channel-bound admission

During vagus/1 admission (pkg/connector/protocol/link.go), the relay sends a 32-byte random nonce and both sides export a 32-byte transcript via TLS 1.3 ExportKeyingMaterial with label "EXPORTER-vagus-admission-" + mode (stream or datagram) and the nonce as context. Signing that transcript prevents replaying a proof on another connection, relaying a proof from an attacker-terminated session to the real relay, or tampering with the framing mode.

Threat scenarios

1. Compromised or malicious relay

A compromised relay sees server names (<route-id>.<domain>), client and connector IPs and ports, packet sizes, counts, direction, timing, public statements, WebSocket Origin headers and URLs, and pass/clearance client keys (linkable across requests). It can drop, delay, reorder, duplicate, or corrupt traffic, disconnect connectors, withhold or replay older signed statements, and send junk datagrams to -backend (capped at 1,024 active client routes per connector).

Against pinning clients, it cannot decrypt application TLS or Noise NKhfs traffic (including against future quantum decryption), impersonate the service, forge statements, or reach any address other than -backend.

2. Network attacker

Between client and relay, a network observer sees plaintext SNI and packet metadata (standard for QUIC without ECH). Modified packets fail inner QUIC authentication, and hybrid X25519MLKEM768 protects confidentiality against harvest-now-decrypt-later. Distributed spoofed Initials can compete for relay table slots (see threat 4). Between connector and relay, control TLS 1.3 (SecP384r1MLKEM1024) protects traffic and the connector validates the relay certificate against system roots or -ca.

3. Unauthorized connector

Anyone able to reach -control with an Ed25519 key can claim their own route ID and consume relay slots and bandwidth, but cannot claim another service's route ID. Firewall UDP -control to authorized connector IPs on private relays.

4. Abusive clients and floods

The relay enforces pre-allocation bounds on control messages (max 4 KiB, 10s deadline), rejects unknown UDP packets under 1,200 bytes or without QUIC v1/v2 Initial headers before cryptography, caps pending Initial reassembly (128 total, 4 per IPv4 or IPv6 /64, 8 packets / 16 KiB CRYPTO), bounds per-connector queues (128 packets), and caps connectors, routes, WebSocket sessions, statement reads, and pass/clearance requests (see Built-in limits and Browser admission limits).

-disable-per-source-limits lifts per-IP and per-key limits for load testing only; never run a public relay with it. Because pending and active route tables are shared across routes, apply edge UDP rate limiting on public relays.

5. Stolen identity key

An attacker with endpoint.pem can sign valid leaves and statements, displace the legitimate connector at any time (newest link wins), and impersonate the service. Pinning cannot distinguish them. When displaced, the legitimate connector exits with another connector with this route's key took the route over; investigate any unexpected occurrence as a possible key compromise.

To recover, generate a new key with vagus keygen (creating a new route ID), distribute the new hostname to clients, and retire the old key.

A stolen leaf private key alone has a narrower blast radius: impersonation works only against clients using a statement that lists that leaf, and ends when the leaf expires (at most 13 days).

6. Shared source addresses

Return routing keys on client UDP IP:port. Another device behind the same NAT cannot hijack a route unless it also receives UDP packets for that exact IP:port. A client whose source address changes mid-session loses its route and must reconnect.

7. Lost relay host

The relay stores no irreplaceable state. Active relayed connections drop during an outage and pending native handoff invitations must be reissued; established peer-to-peer connections outside the relay continue unaffected. See Incident recovery for rebuild steps.

8. Leaked relay credentials

A leaked relay TLS key allows impersonating the relay (threat 1) if paired with DNS control or network interception. Pinning clients remain protected end to end, and control admission proofs cannot be replayed. Clients opting out of pinning remain safe from the leaked key alone provided the relay certificate has no wildcard. A leaked ACME account key allows revoking the relay certificate; a leaked Turnstile secret allows verifying tokens but not forging them. See Leaked relay credentials for recovery steps.

9. Impersonated handoff service

Native handoff puts the encrypted route in the invitation URL fragment and sends only the ticket to the server.

An impostor learns nothing from HTTP requests alone, and returning a wrong key fails AES-GCM decryption (invalid sealed route), so it cannot substitute another route. An impostor that answered the original offer chooses that invitation's key; if it also obtains the full invitation URL (including the fragment), it can decrypt the route even after 5 minutes. Handoff only exchanges the initial route, so native peers must still authenticate each other when connecting.

Security checklist

  • Run connectors with -leaf-dir (or pintls.Keyring), dial browsers with relayURL or statement, and dial Go clients with pintls.ClientConfig.
  • Keep CurvePreferences set to tls.X25519MLKEM768 on backend QUIC TLS configs so relayed connections enforce hybrid post-quantum key exchange.
  • Keep endpoint.pem mode 0600 owned by the connector user, restrict -leaf-dir to the connector user and service group (0750, keyring.msgp 0600, served leaf 0640), and isolate the relay TLS key to the relay user.
  • Issue the relay certificate for its own hostname only (never a wildcard) and pin your ACME account with a CAA record.
  • Firewall UDP 19451 (-control) to connector IPs on private relays.
  • Bind -backend to loopback or a dedicated interface serving only the intended service.
  • Authenticate users at the application layer and treat route IDs as public addresses.
  • Serve browser apps from trusted origins and include 'unsafe-webtransport-hashes' in connect-src when using a CSP.

Starting the terminal…