qqt

Protocol

The qqt wire protocol

One QUIC connection, one bidirectional stream per forwarded TCP connection, a header that names the dial target, and the half-close rules — with the security properties and the non-goals.

The contract between a qqt client and a qqt server — what goes on the wire, what each side promises, and what is deliberately out of scope. |hadron|: QQT-001 the client pins SNI to quic-tun and verifies the server certificate’s SAN against it while the server never inspects the ClientHello’s SNI — the pin is a client-side mis-issuance tripwire, not a server-side gate, so a server operator who renames nothing still gets the client’s refusal on any cert not minted for this exact purpose. |hadron|: QQT-002 an aborted pump resets the QUIC stream instead of ending it — a peer that read a graceful FIN as EOF would silently truncate where the protocol means to fail, which is the difference between “file complete” and “file lost mid-transfer” for every consumer on the far side.

Reverse forwards (ssh -R parity) are the second shape: a client may ask the server to bind listeners whose accepted connections ride back as server-opened data streams. Data frames are byte-identical to the forward stream header, so a peer without reverse support still forwards unchanged; the control frame and reverse streams need both ends to carry them.

Transport and handshake

Property Value
Transport QUIC v1 (RFC 9000) over UDP
Handshake TLS 1.3 with mutual certificate authentication
SNI quic-tun — the client pins it and verifies the server cert’s SAN against it; the server does not inspect the ClientHello’s SNI
ALPN quic-tun — required by both sides; mismatches fail the handshake
Client auth Required: a certificate signed by a CA in the server’s trust bundle, or the handshake is rejected
Keepalive 10 s, client side
Idle timeout 60 s, both sides
Streams up to 1024 concurrent bidirectional streams per connection, in either initiation direction

The certificate is the access control. The server trusts every holder of a client certificate from a CA in its bundle equally; there is no per-connection authorization beyond that (see the security properties below).

Data plane

One client connection carries every forwarded TCP connection. Each accepted TCP connection opens one bidirectional QUIC stream whose first byte is the frame type (1 = data), followed by the dial header:

+--------+----------------+-----------------+----------------+
| type=1 | host length    | host (UTF-8)   | port           |
| u8     | u16, big-endian| host_len bytes  | u16, big-endian|
+--------+----------------+-----------------+----------------+
   1           2              0..65535            2
  • The type byte is 1 for data — the byte v1 read as its header version, unchanged. A peer that reads any other type resets the stream with the error unsupported frame type — it never guesses.
  • The host may arrive bracketed ([2001:db8::5]); the receiving side strips the brackets and dials the bare host. IPv6 zone suffixes (fe80::1%eth0) are accepted on link-local addresses only. The sending side writes the header from its own parsed spec, so the CLI’s address grammar (-l, -R, -r, --listen, --verify, --metrics-addr) takes the same bracketed and zoned forms the wire accepts — with one asymmetry: the wire refuses a zone on a non-link-local address, where the CLI accepts any zone and leaves the verdict to the resolver.
  • Port 0 is refused.

After the header, the stream is a raw byte pipe in both directions. Whoever receives a data stream dials its header’s target from that side’s own network position — forwards arrive at the server (targets the server can reach), reverse forwards at the client (targets the client can reach). The roles are mirrored, not the frame.

Reverse forwards

-R on the client names a listener the server should bind and the target the client will dial for it. Right after every handshake (and redial) the client opens one control stream (frame type 2) and writes one frame, then half-closes:

+--------+----------------+----------------------------------------------+
| type=2 | count          | count × entry                                |
| u8     | u16, big-endian| entry below                                   |
+--------+----------------+----------------------------------------------+

entry: bind_len u16 · bind (UTF-8) · bind_port u16
       · target_len u16 · target (UTF-8) · target_port u16
  • The bind is where the server listens; the target is what the client dials. Both arrive bracket-stripped to the same rules as the dial header, and an empty bind or a 0 target port is refused. A frame names at most 4096 entries — past that the server refuses it rather than let one client pin tens of thousands of its file descriptors.
  • The server answers one status row per entry, in the request’s order, then the stream closes:
+--------+-------------+----------------+-------------+-----------------+
| count  | count × row                                                  |
| u16    | status u8 · bound_port u16 · msg_len u16 · msg (UTF-8)       |
+--------+-------------+----------------+-------------+-----------------+

status is 0 bound or 1 refused; bound_port is the port actually bound (the real port when the spec asked for 0, 0 on refusal); msg is empty on success, the OS’s error on refusal. A row’s message is truncated so a full 4096-row reply still fits the reply cap. - Each connection the server accepts on a bound listener opens one server-initiated data stream carrying the dial header above with the entry’s target; the client dials it. The client validates that header against its own registered -R targets — a server-written target the client did not name is refused, not dialed. - The listeners live exactly as long as the connection that asked for them: the server drops them when it reaps the connection, and a redial asks again. A client that exits cleanly closes the connection so the drop is immediate; a client that died without a close leaves its listener bound until the server’s 60 s idle timeout, and a redial’s in-use bind retries across that window (a ~70 s budget) before reporting the spec failed.

A frame is bounded: the control frame is the protocol’s only unbounded read, so both ends cap it (1 MiB) rather than trust the peer’s frame size.

Half-close and abort

  • A TCP FIN on the client side finishes the QUIC send stream (a clean QUIC FIN), and the server shuts down the TCP write side — and vice versa. This is ssh -L and ssh -R parity: protocols that rely on half-close behave.
  • An aborted pump (failed dial, copy error) resets the QUIC stream so the peer sees a failure, never a graceful end that could read as EOF.

Connection lifecycle

  • Without --reconnect, the client exits with status 1 when the connection is lost; supervision (systemd or equivalent) owns the retry. With --reconnect, the client itself re-resolves the server address and re-dials on a fixed 2 s pacing. Either way a reconnect is a fresh handshake and fresh streams — never a transparent takeover; in-flight streams die with the old connection.
  • The server accepts any number of client connections concurrently; each is independent.

Security properties

  • Confidentiality and integrity: QUIC’s TLS 1.3 channel — no plaintext mode exists.
  • Mutual authentication: both sides present certificate chains; the server admits chains to a CA in its trust bundle (a multi-CA bundle is the per-customer model — each customer’s CA key stays with the customer, and the operator holds no key that admits a client). A minted client set carries its leaf and the issuing CA, so the server can evaluate the whole chain; revocation additionally resolves the leaf’s issuer from the server’s own bundle, which is what makes a revoked CA bite even when a client presents the leaf alone.
  • No target authorization: the header names any host the server can reach. The protocol’s trust model is “every certificate holder may reach everything the server process can reach.” For weaker trust models, the operator adds firewall rules or separate CAs — the protocol does not pretend to enforce what it cannot see.
  • Bind authority mirrors dial authority: a -R spec names any address and port the server process can bind, and whatever connects there reaches whatever the holder’s client dials. The trusted-crew model covers both directions the same way.
  • Validity windows: minted certificates carry a real window (365 days by default, --valid-days; the CA 3650), and the TLS handshake enforces it on both sides — an expired leaf stops admitting on its own. A CA’s own dates are not checked by the verifier, so a CA is retired by removing it from the bundle or revoking it, never by waiting. qqt expiry prints both windows before they close.
  • Admit-path revocation: server --revoked re-reads a SHA-256 fingerprint list at every handshake and closes any connection whose presented chain (leaf or CA) matches an entry — and, beyond the chain a client chooses to send, resolves the leaf’s issuer from the server’s own trust bundle, so a revoked CA kills its certs even when the client omits the CA block. No CRL, no OCSP, no restart to revoke. The bounds: the check sits after the handshake (a revoked holder’s failed connect reads as a closed connection, and a live connection keeps its streams until it drops or the server restarts), and the client has no revocation check of the server cert. The re-mint runbook is instructions_qqt-remint.md.

Non-goals

  • Transparent reconnect — a reconnect (supervisor-driven or the client’s own --reconnect redial) is a fresh handshake; existing streams never survive it. A reverse listener is re-bound on the redial, so its port is closed across the gap.
  • SOCKS or dynamic targets — every forward is named at client start.
  • NAT traversal from the server side — the server’s UDP port must be reachable; client-side NAT is fine.
  • Multipath or path migration beyond what QUIC’s connection IDs give you.

← All documentation