Skip to content

S07-16 - TLS and Tunnels

Purpose: What wb-proxyd does with client certificates, encrypted ClientHello and tunnels, and which refusals no mode or approval relaxes.

The protocol check on each stream is on S07-15-non-http-streamsS07-15-non-http-streams: Non-HTTP StreamsHow wb-proxyd checks the protocol of each stream, and what it does with SSH, other protocols and raw TCP..

Wraith Box doesn’t support client certificates in V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.. A client certificate needs its private key, and the guest can’t hold one (SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential.).

ECH hides the name a client wants inside an encrypted part of the ClientHello, under a public outer name. wb-proxyd binds every TLS stream to the outer SNI (S07-07-hosts-and-modesS07-07-hosts-and-modes: Hosts and ModesHow wb-proxyd binds a stream to its name, which upstream addresses it refuses, and the inspect, pass and audit modes., “Name binding”). These rules keep the inner name from reaching a host the guest isn’t allowed.

wb-netd answers HTTPS and SVCB queries without a record (S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget.). Those records hold ECH configurations. A client that looks up its keys in DNS doesn’t learn an ECH key, so it doesn’t try ECH.

That is a compatibility measure. It doesn’t stop a guest that brings its own ECH configuration. The next two rules do.

wb-proxyd terminates TLS, and doesn’t implement ECH as a server. So it completes the handshake for the outer ClientHello, with a certificate for the outer name.

In a pass relay, the inner name would reach the upstream front end unread. wb-proxyd can’t tell a real ECH extension from a GREASE one.

So it parses the client’s handshake records until the server sends a ServerHello that isn’t a HelloRetryRequest. That includes a second ClientHello after a HelloRetryRequest, whose SNI must equal the bound host too.

The server’s records are read only up to that ServerHello, within a byte cap fixed in code (SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.). A server record before it that isn’t a handshake, alert or Change Cipher Spec record, a second HelloRetryRequest, or a ServerHello that comes after a HelloRetryRequest but before the client’s second ClientHello, resets the stream with stream-protocol-mismatch.

Before that ServerHello, the client’s records are handled like this:

  • Other records. A handshake record that isn’t a ClientHello, or an application data record, resets the stream with the rule stream-protocol-mismatch.
  • Early data. TLS 1.3 early data (0-RTT) is sent as application data before the ServerHello. The rule above resets it. A ClientHello with the early_data extension is reset with the same rule, before any early data. The audit entry says early data isn’t allowed to a pass host (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).
  • Change Cipher Spec. One Change Cipher Spec record, holding one byte 0x01, is relayed. A TLS 1.3 client in its compatibility mode for network middleboxes (RFC 8446) sends one before its second ClientHello. A second one, or one with other content, resets the stream with stream-protocol-mismatch.
  • Alerts. An alert record closes the stream in both directions without relaying it. The audit entry records the alert’s level and description, with the rule tls-client-alert.

A ClientHello to a pass host is reset when it holds:

  • an encrypted_client_hello extension (0xfe0d), or the earlier encrypted SNI extension (0xffce), with the rule tls-ech-pass;
  • any other extension outside a list fixed in code, with the rule tls-extension-unknown (fail closed). The list holds the extensions wb-proxyd recognizes, and the GREASE values of RFC 8701.

A client that sends GREASE ECH by default can’t reach a pass host until it is configured not to.

These are refused with a 403 and the rule http-tunnel, whatever policy allows:

  • a request with the method CONNECT;
  • a request with an Upgrade header for any protocol other than WebSocket.

That holds on every inspected stream, inspected TLS and plain HTTP alike. A policy rule that names CONNECT is refused at load.

The bytes after a 200 would reach whatever host the upstream proxy picks, outside every rule of this spec (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.).

On HTTP/2, wb-proxyd doesn’t offer extended CONNECT (RFC 8441). A client then opens a WebSocket over HTTP/1.1. That is under the host’s HTTP policy, and S07-17-approvals-and-learningS07-17-approvals-and-learning: Approvals and LearningHow an unknown destination reaches the user as an approval request, what an approval grants, and how learn mode collects names., “What an approval grants”.

A proxy that runs inside the guest doesn’t need an exception. The connections it opens are ordinary streams to synthetic addresses, checked as above. No tool needs proxy settings (FR08-no-proxy-configFR08-no-proxy-config: No per-tool proxy settingsAllowlisted network destinations work for every tool without per-tool proxy configuration.).

A request with the method TRACE or TRACK is refused with a 403 and the rule http-trace, whatever policy allows. A server that answers it echoes the request it got, with the credential the injection step added (SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential.). Any other spelling of them fails the policy step’s http-method-form (S07-19-request-decisionsS07-19-request-decisions: Request DecisionsHow wb-proxyd decides a request on an inspected host: the order of the steps, their rule names, what a git hosting write is, and what audit relaxes.).

HTTP policy matches the method of the request line. Some servers and frameworks take the method from a header field instead, so an allowed POST could reach them as a DELETE on the same path. A request with an X-HTTP-Method-Override, X-HTTP-Method or X-Method-Override field is refused with a 403 and the rule http-method-override, whatever policy allows. The check runs before HTTP policy and before anything goes upstream.

The check matches the field name without case, and with any byte other than a letter or a digit read as -, since some servers map each such byte to _ before the application sees the field. So X.HTTP.Method.Override matches too. Any value is refused, an empty one included. A field that a Connection names is refused too, though it would never go upstream. A _method parameter in the query or the body isn’t checked (I876I876 (closed): wb-proxyd: decide on _method query and body method overridesReview of #872 (code F1, security F3) found that method-override parameters reach the upstream: POST /p?method=DELETE, and method=DELETE in a urlencoded form body.).

A host and port in audit relaxes exactly two refusals: http-no-rule and http-deny-rule, the method and path rules and the deny_rules of its sources. The request goes on, and is logged with the rule audit-allowed and the rule it broke (S07-19-request-decisionsS07-19-request-decisions: Request DecisionsHow wb-proxyd decides a request on an inspected host: the order of the steps, their rule names, what a git hosting write is, and what audit relaxes.). Every other refusal applies on a host in audit too. Among them:

A guarded host is never in audit (S07-07-hosts-and-modesS07-07-hosts-and-modes: Hosts and ModesHow wb-proxyd binds a stream to its name, which upstream addresses it refuses, and the inspect, pass and audit modes.), and wb-proxyd holds each host a profile covers in enforce, even if a policy put it there.

A CONNECT request, or an Upgrade other than WebSocket, never raises an approval request.

Status: Draft