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.
Design
Section titled “Design”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..
TLS with a client certificate
Section titled “TLS with a client certificate”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.).
- Inspect.
wb-proxyddoesn’t ask the guest for a certificate, and never presents one upstream. The upstream server can ask for one, and the handshake then fail. The guest’s request then gets a502with the ruletls-client-cert-unsupported. The audit entry names the host (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). - Pass and raw TCP.
wb-proxydcan’t see a client certificate in a pass or raw relay, because TLS 1.3 encrypts it. A key the guest holds can reach such a host. That key is a credential the guest brought, which Wraith Box neither gave nor removes (T10-unnamed-credentialsT10-unnamed-credentials: Guest credentials in unnamed placeswb-proxyd removes Authorization, Proxy-Authorization and Cookie on every inspected host.).
Encrypted ClientHello
Section titled “Encrypted ClientHello”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.
Inspect
Section titled “Inspect”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.
- A client that sent a real ECH extension then aborts with an
ech_requiredalert, as the ECH RFC (RFC 9849) requires. The stream fails closed.wb-proxydresets it, and logs the ruletls-ech-refusedwith the name and port. Any other alert from the client istls-client-rejected-leaf(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., “Inside TLS on an inspected host”). - A client that sends a GREASE ECH extension, which lacks an inner name, continues as usual.
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_dataextension 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 withstream-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_helloextension (0xfe0d), or the earlier encrypted SNI extension (0xffce), with the ruletls-ech-pass; - any other extension outside a list fixed in code, with the rule
tls-extension-unknown(fail closed). The list holds the extensionswb-proxydrecognizes, 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.
CONNECT and other tunnels
Section titled “CONNECT and other tunnels”These are refused with a 403 and the rule http-tunnel, whatever
policy allows:
- a request with the method
CONNECT; - a request with an
Upgradeheader 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.).
TRACE and TRACK
Section titled “TRACE and TRACK”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.).
Method overrides
Section titled “Method overrides”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.).
Not relaxed by audit mode or approvals
Section titled “Not relaxed by audit mode or approvals”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:
- the built-in denies of 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.:
model-path-escape,git-archive,git-create-denied,model-event-log,registry-token,registry-publishandgit-write-outside-project-set; profile-part-offandgraphql-operation;- the request form refusals:
http-method-form,http-path-form,http-request-form, and the other checks of S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones., “Request form”; http-step-missing;- the removal of guest credentials, and the refusal of a named credential parameter (S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones., “Credential replacement”);
- the placeholder refusals
placeholder-outside-binding,model-placeholder-in-bodyandmodel-content-encoding; anonymous-binding-read-only;- the dependency gate’s refusals (S07-12-dependency-gateS07-12-dependency-gate: Dependency GateHow wb-proxyd keeps young and vulnerable package versions from the guest on the gated registries.);
port-not-allowed;- the
http-tunnel,http-traceandhttp-method-overriderefusals; - the
tls-*refusals; - the
stream-*resets; http-header-timeout,http-header-size,http-transfer-coding,http-body-timeoutandhttp-idle-timeout;upstream-request-failed;upstream-address-refused,upstream-tls-verifyandupstream-tls-failed.
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