Skip to content

P4 relay Route: client certificates (mTLS) at the ghostunnel sidecar, so a token alone cannot attach #441

Open

Description

@pdettori

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, running server --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 as client.crt and client.key, mode 0600. The key reaches the file without ever appearing on argv.
  • Sidecar. Change the args from --disable-authentication to --cacert /client-ca/ca.crt plus 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_FILE and RELAY_KEY_FILE to session.TransportCredentials: tls.Config.Certificates, required as a pair and only valid with RELAY_TLS=true. Startup refuses an unreadable or mismatched pair, naming the variables, in the same posture as RELAY_CA_FILE.
  • Install. --remote validates 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

  1. 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-cn list 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.
  2. 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.
  3. Operator certificates. --relay-tls-cert covers 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: --remote installs 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 p4 P6: the probe without a client certificate fails at the TLS handshake. With the probe's own short-lived client certificate, the existing attach=0 exec=12 still 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.

Activity

  1. added
    enhancement
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions