Repository navigation
Open
Labels
enhancementNew feature or request
Description
Follow-up from the #437 review (P6 on Kubernetes slice 2, #424): design note.
Today
- The relay's external path is a ghostunnel sidecar behind passthrough Route
moca-relay, runningserver --disable-authentication. TLS gives confidentiality and server identity only. - A P4 host is authenticated by its 64-hex attach token alone, checked with a constant-time compare.
- There is no rate limiting, so the token's entropy is the only defence against guessing. The spec accepts this for slice 2.
Proposal: client certificates at the sidecar
Any TCP client on the internet can currently complete a TLS handshake and send Attach frames. Client certificates would make the sidecar refuse a connection that has no host certificate before the relay sees a single byte. A leaked or guessed token would then be useless on its own.
Cluster side (deploy/k8s/setup.sh, overlays/ocp/p4-relay)
- Client CA. Generate a client CA once and keep it in a new Secret, for example
moca-relay-client-ca, never rotated by a re-run. It follows the same off-argv, fail-closed-read rules as the other Secrets. - Host certificates. Issue one client certificate per P4 ID (
CN=<sandboxId>, around 825 days) and add it to that host's bundle asclient.crtandclient.key, mode 0600. The key reaches the file without ever appearing on argv. - Sidecar. Change the args from
--disable-authenticationto--cacert /client-ca/ca.crtplus an allow policy (see the design questions). Mount the CA read-only.
Host side (remote-worker, deploy/microvm/setup-microvm.sh --remote)
- Worker. Add
RELAY_CERT_FILEandRELAY_KEY_FILEtosession.TransportCredentials:tls.Config.Certificates, required as a pair and only valid withRELAY_TLS=true. Startup refuses an unreadable or mismatched pair, naming the variables, in the same posture asRELAY_CA_FILE. - Install.
--remotevalidates and installs the pair, for example/etc/serverless-harness/microvm-relay-client.{crt,key}, with the key at 0600 root:root. It sets both env vars, and removes them when switching back to local mode.
Design questions to settle first
- Revocation without a relay restart. Slice 2's property is that adding or revoking a host never restarts the relay. If revocation goes through ghostunnel's
--allow-cnlist in the pod args, every change rolls the pod and drops every attached host. Options:- allow any certificate the client CA issued (
--allow-all), and keep revocation at the token level, as today. Both must then be valid, but revoking the token is enough; - a reloadable policy, if ghostunnel supports one;
- a CRL.
- allow any certificate the client CA issued (
- Binding the certificate to the token. The relay never sees the client certificate, because TLS ends at the sidecar. Without a binding, host A's certificate plus host B's token would attach as B. Either accept that (the certificate gates access, the token gates identity), or find a way to pass the peer CN to the relay and check it against the hello's
sandboxId. An L4 sidecar can't add a gRPC header, so this might need ghostunnel's PROXY-protocol support or terminating TLS in the relay itself. - Operator certificates.
--relay-tls-certcovers the server certificate only. The client CA stays a setup.sh-managed CA either way.
Alternative or complement: rate limiting in the relay
Limit failed attaches per source address. Behind the OpenShift router the source is the router unless PROXY protocol is enabled, so this has the same address-visibility problem as question 2.
Acceptance
- Manifest tests: the sidecar args carry the client CA and the allow policy, and the CA Secret is mounted read-only.
setup.test.sh: the client CA is generated once and kept; each bundle carries a matching certificate and key at 0600; no key appears on argv; a removed ID's certificate leaves with its bundle.setup-microvm.test.sh:--remoteinstalls and validates the pair, and switching back removes it.- Go: a TLS test server that requires client certificates accepts the worker with a certificate and refuses it without one.
smoke.sh --tier p4P6: the probe without a client certificate fails at the TLS handshake. With the probe's own short-lived client certificate, the existingattach=0 exec=12still holds.- Live on OpenShift plus the KVM rig: a host with its certificate attaches; the same token without the certificate does not; adding a host still restarts nothing.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity