Skip to content

Deploying the hub ​

The hub runs on your team's Kubernetes cluster, installed with the Helm chart in contrib/helm. Do this before the game: the first install takes a few minutes, and the agent has nothing to send to until it is done.

What you need ​

  • Kubernetes 1.28 or newer, with a default StorageClass (or set storageClassName in the values), and a network plugin that enforces NetworkPolicy if you rely on the chart's policies.
  • A way to give the agent a TCP address: a LoadBalancer Service by default, or a Gateway that passes TLS through (see ingest through the Gateway). TLS ends in the hub's pod, so whatever is in front must pass TCP through untouched.
  • The Gateway API and an implementation of it, such as Envoy Gateway, for the web UI, with a host name and a TLS certificate: a Gateway you run, or one the chart creates.
  • An OpenID Connect issuer your team signs in with, such as Dex, or an authenticating proxy (see signing in).
  • helm, and helmfile for the reference deployment.
  • A container registry the cluster can pull from.

The chart installs ClickHouse through ClickHouse's operator, which needs cert-manager; the helmfile installs both. With a ClickHouse of your own you need neither (see your own ClickHouse).

Build the image ​

There is no published image yet, so build one and push it to your registry. From the repository's root:

sh
(cd crates/hub/ui && npm ci && npm run build)    # the web UI
podman build -f crates/hub/Containerfile -t registry.example.org/vulnboxd-hub:1.0.0 .
podman push registry.example.org/vulnboxd-hub:1.0.0

docker build works the same way. Without crates/hub/ui/dist the image has no UI, and only the API works. One image serves every subcommand; the chart runs it as ingest, assemble, link, alert, api and migrate. It runs as an unprivileged user: the agent's segments are attacker-controlled input.

The chart's tag defaults to its appVersion; set image.repository and image.tag to what you pushed, and imagePullSecrets for a private registry.

Exchange the keys ​

The agent and the hub pin each other's certificates, so each needs the other's before they can talk. Make the hub's pair with the hub binary, either from a build (cargo build --release -p hub) or from the image:

sh
mkdir hub-keys
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/hub-keys:/keys" \
  registry.example.org/vulnboxd-hub:1.0.0 keygen /keys
# or: ./target/release/vulnboxd-hub keygen hub-keys/

That writes hub-keys/hub.crt and hub-keys/hub.key. On the vulnbox, make the agent's:

sh
sudo vulnboxd-agent keygen /etc/vulnboxd     # agent.crt and agent.key

Then swap certificates — only the certificates; each key stays where it was made:

  • copy the vulnbox's /etc/vulnboxd/agent.crt into hub-keys/;
  • copy hub-keys/hub.crt to the vulnbox as /etc/vulnboxd/hub.crt.

and store the hub's side in a Secret:

sh
kubectl create namespace vulnboxd-hub
kubectl -n vulnboxd-hub create secret generic vulnboxd-hub-tls --from-file=hub-keys/

The Secret holds hub.crt, hub.key and agent.crt; name it in tls.existingSecret. (tls.hubCert, tls.hubKey and tls.agentCert take the PEM in the values instead, if you prefer that.)

The certificates are valid for a century, so nothing expires during a game. Each side accepts exactly one certificate: to replace a key, give the other side the new certificate as well.

Neither keygen replaces a key that is there already: the other side is pinned to it. Move the old pair away first if you mean to replace it.

Fill in the values ​

Copy contrib/helm/values.example.yaml to contrib/helm/values.yaml and fill it in. Everything it leaves out is in the chart's own values.yaml, with its default and a comment.

yaml
image:
  repository: registry.example.org/vulnboxd-hub
  tag: "1.0.0"

tls:
  existingSecret: vulnboxd-hub-tls

ingest:
  service:
    loadBalancerSourceRanges: [203.0.113.7/32]   # only the vulnbox

auth:
  mode: oidc
  issuer: https://dex.example.org
  clientId: vulnboxd-hub
  clientSecret:
    existingSecret: vulnboxd-hub-oidc
  allowedGroups: [ctf-team]

gateway:
  hostnames: [hub.example.org]
  parentRefs:                  # a Gateway you run, whose listener allows routes from vulnboxd-hub
    - name: public
      namespace: gateways
      sectionName: https

The chart attaches an HTTPRoute for the UI and API to that Gateway. To have the chart create a Gateway of its own instead, with an HTTPS listener for each host name and its certificate from cert-manager:

yaml
gateway:
  hostnames: [hub.example.org]
  create: true
  className: eg                # your implementation's GatewayClass; eg is Envoy Gateway's
  tls:
    issuerRef:
      name: letsencrypt
      kind: ClusterIssuer

Without issuerRef, the certificate is the Secret gateway.tls.secretName you made. The created Gateway also redirects plain HTTP on port 80 to HTTPS. If the cluster has no Gateway API implementation yet, the chart's README shows how to install Envoy Gateway.

The ClickHouse password and the session key are generated on the first install and kept across upgrades, unless you name Secrets of your own.

Install ​

With helmfile, which installs cert-manager, then the ClickHouse operator (watching the vulnboxd-hub namespace), then the hub:

sh
helmfile -f contrib/helm/helmfile.yaml apply

They are separate releases rather than subcharts: Helm cannot install a ClickHouseCluster in the same release as the CRD that defines it, and the operator's webhooks must be running before one is admitted. With plain Helm, the same in order:

sh
helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.21.2 \
  -n cert-manager --create-namespace --set crds.enabled=true --wait
helm install clickhouse-operator oci://ghcr.io/clickhouse/clickhouse-operator-helm --version 0.0.8 \
  -n clickhouse-operator --create-namespace --set 'controller.watchNamespaces={vulnboxd-hub}' --wait
helm install vulnboxd-hub contrib/helm/vulnboxd-hub -n vulnboxd-hub -f contrib/helm/values.yaml --timeout 15m

The first install takes a few minutes: the schema migration runs as a Helm hook and waits for ClickHouse to come up, and the hub's pods restart until the schema exists. It runs again before every upgrade.

When it is done, the release notes say where the agent connects:

sh
kubectl -n vulnboxd-hub get service vulnboxd-hub-ingest

That address and port 7443 are the agent's agent.hub. Now set up the agent.

What runs where ​

replicas
core1ingest, assemble, link and alert in one pod, sharing the segment store. Replaced rather than rolled: ingest hands out the order segments are assembled in, so there is only ever one. link stores the host sensor's events and links flows, processes and events (link.delay, link.rescan); alert learns each service's baseline and raises alerts (alert.delay), and posts them to the webhooks in the hub's settings, so it needs to reach those
apiapi.replicas, 2 by defaultthe web UI and API. Sessions are sealed cookies any replica can open, and what replicas share — live updates, who is online, rule previews — goes through ClickHouse, so no sticky sessions are needed. With more than one, a PodDisruptionBudget keeps one up through node drains
ClickHouse1a single-replica ClickHouseCluster and its KeeperCluster, made for the operator

Ingest is also the one place every rule push passes through, so the per-user push limit holds however many API replicas there are.

Storing the capture ​

The raw segments go to a PersistentVolumeClaim by default, storage.volume.size (200 GiB). Size it as roughly what the agent sends per day, times the days of the game. The claim is kept when the release is uninstalled: deleting the capture should be a decision.

For an S3-compatible store instead — a cloud provider's object storage, or one you run yourself, such as Garage, SeaweedFS or Ceph's RGW — make a bucket and a key pair for it:

sh
kubectl -n vulnboxd-hub create secret generic vulnboxd-hub-s3 \
  --from-literal=AWS_ACCESS_KEY_ID=... --from-literal=AWS_SECRET_ACCESS_KEY=...
yaml
storage:
  type: s3
  s3:
    url: s3://vulnboxd-hub/segments        # s3://<bucket>/<prefix>
    existingSecret: vulnboxd-hub-s3
    env:
      AWS_REGION: us-east-1
      AWS_ENDPOINT: https://s3.example.org # for a store that is not Amazon's
      # AWS_VIRTUAL_HOSTED_STYLE_REQUEST: "false"   # path-style, which most self-hosted stores need
      # AWS_ALLOW_HTTP: "true"                      # only for an endpoint without TLS

Any other AWS_* variable the store needs goes in env too. With S3 the core pod has no volume and can move between nodes.

Your own ClickHouse ​

Without the operator, point the hub at a ClickHouse you run, and drop cert-manager and the operator from the helmfile:

yaml
clickhouse:
  mode: external
  external:
    url: http://clickhouse.databases.svc:8123
    user: hub
  password:
    existingSecret: clickhouse-hub        # key: password

The user has to be able to create the database named by clickhouse.database (vulnboxd) and tables in it. The chart's NetworkPolicy for ClickHouse applies only in operator mode.

Signing in ​

With Dex ​

By default the hub signs users in itself, as an OpenID Connect client of Dex or any other issuer, and keeps the session in a sealed cookie. It keeps no tokens of the issuer's. Register it in Dex's config as a static client:

yaml
staticClients:
  - id: vulnboxd-hub
    name: vulnboxd
    secret: <a long random string>
    redirectURIs:
      - https://hub.example.org/auth/callback   # <auth.publicUrl>/auth/callback

and give the hub the same secret:

sh
kubectl -n vulnboxd-hub create secret generic vulnboxd-hub-oidc --from-literal=client-secret=<the secret>

auth.issuer must be exactly Dex's issuer. The hub reads the issuer's discovery document when it starts, so a wrong or unreachable issuer stops it from starting, rather than from signing anyone in. auth.publicUrl defaults to https://<the first of gateway.hostnames>, and changes through the API are only accepted from pages at that origin.

Who may sign in. auth.allowedGroups lets in members of one of these groups, auth.allowedEmails these verified addresses; either one suffices. With both empty, anyone the issuer authenticates gets in — fine for a Dex that only knows your team, not for one in front of GitHub at large. Groups come from the ID token's groups claim, which Dex fills when the connector supplies groups: the GitHub connector's teams, LDAP group searches, an upstream OIDC provider with insecureEnableGroups: true.

Names. A user is named by the auth.usernameClaim claim, email by default, or else the first of preferred_username, name and sub, qualified with the claim's name (such as name:Alice) so a display name cannot pass for another user's address. An email counts, for the name and for auth.allowedEmails, only with email_verified: true, which Dex always sends. That name is on their notes and tags, and it is the author of their rule pushes' Git commits.

Sessions last auth.sessionTtl, 12 hours by default. Changing the session key signs everyone out.

Behind your own proxy ​

With auth.mode: proxy, an authenticating proxy in front — oauth2-proxy, your Gateway's external auth — signs users in, and the hub takes the user's name from the header in api.userHeader (X-Forwarded-User). The hub trusts that header from anything that reaches it, so the proxy must remove it from what clients send, and nothing else may reach the API: point networkPolicy.gateway (or networkPolicy.apiFrom) at the proxy's pods. Setting auth.publicUrl turns on the same origin check as with OIDC; set it. Without it, the API logs a warning at startup and still refuses changes that a browser marks as coming from another site: by Sec-Fetch-Site, or else by an Origin that differs from the Host (or X-Forwarded-Host). Request bodies must be Content-Type: application/json in every mode, so a plain HTML form on another site cannot send one.

Network policy ​

With networkPolicy.enabled (the default), only the hub's pods reach ClickHouse, and only the Gateway's proxies reach the API. Ingest is open on its TLS port, where the pinned certificate keeps others out; narrow it further with ingest.service.loadBalancerSourceRanges. Where the proxies run depends on the implementation: the defaults fit Envoy Gateway, which runs every Gateway's Envoy in envoy-gateway-system. For one that runs them next to the Gateway, name the Gateway's namespace and its proxies' labels, for example:

yaml
networkPolicy:
  gateway:
    namespaceSelector:
      matchLabels:
        kubernetes.io/metadata.name: gateways
    podSelector:
      matchLabels:
        app.kubernetes.io/name: traefik

The HTTPRoute has no request timeout (gateway.timeouts.request: "0s"), since the UI's live updates are one response that stays open. If your Gateway sets timeouts of its own elsewhere, lift them for the hub, or the flow list stops updating.

Ingest through the Gateway ​

By default the agent connects to the ingest Service, a LoadBalancer. It can come through the Gateway too, as long as the Gateway passes the connection through untouched — the hub ends TLS itself, pinned to the agent's certificate:

yaml
ingest:
  service:
    type: ClusterIP
  route:
    enabled: true
    kind: TLSRoute             # or TCPRoute
    parentRefs:
      - name: public
        namespace: gateways
        sectionName: vulnboxd-ingest

A TLSRoute needs a listener with protocol: TLS and tls.mode: Passthrough; it matches on the server name vulnboxd-hub, which every agent sends whatever address it dials, so one hub per Gateway port. A TCPRoute takes a listener of protocol: TCP to itself. TLSRoute is in the Gateway API's standard channel from version 1.5, TCPRoute only in the experimental channel, and not every implementation has them. With gateway.create and no parentRefs, the chart adds the listener to its own Gateway, at ingest.route.port (7443).

When the vulnbox cannot reach the hub ​

If the vulnbox cannot open connections to your cluster but the cluster can reach the vulnbox, turn it around: the agent listens, and ingest dials it.

yaml
ingest:
  dial: 10.60.13.2:7443        # the agent's agent.listen
  service:
    enabled: false

and set agent.mode: listen on the box. The protocol and the pinning are the same either way.

Metrics ​

With metrics.enabled (the default), ingest serves Prometheus metrics on port 9100, assemble on 9101, link on 9103 and alert on 9104, through the vulnboxd-hub-metrics Service, and each API replica on 9102, through the headless vulnboxd-hub-api-metrics Service. See hub metrics for what they are; the two to watch are hub_ingest_connected and hub_assemble_behind.

With the prometheus-operator (kube-prometheus-stack, say), the chart makes a ServiceMonitor for all three, and ConfigMaps with the hub's two Grafana dashboards for Grafana's dashboard sidecar:

yaml
metrics:
  serviceMonitor:
    enabled: true
    labels:
      release: kube-prometheus-stack   # what your Prometheus selects ServiceMonitors by
  dashboards:
    enabled: true                      # labelled grafana_dashboard: "1"
networkPolicy:
  metricsFrom:                         # the NetworkPolicy lets in only the hub's namespace otherwise
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: monitoring

metrics.serviceMonitor.namespace and metrics.dashboards.namespace put them elsewhere, and metrics.dashboards.label, labelValue and annotations fit another sidecar's settings. The dashboards are also in contrib/grafana/ to import by hand: vulnboxd hub (hub.json) for the game — is the agent connected, how far behind the vulnbox the capture and the flows are, capture lost in gaps, flows per second, the API's latency and errors, who is online, rule pushes — and vulnboxd hub internals (hub-internals.json) for when something is slow, stuck or growing: memory and the async runtime per pod, the task table with tasks that stopped making progress in red, ClickHouse and segment store latency and errors by table and operation, assembly batches, ingest's frames and queues, and the API's jobs, streams and sign-ins. Both group by the pod and namespace labels the operator adds.

Running it without Kubernetes ​

The chart is the supported way, but the hub is one binary and needs nothing from Kubernetes. Each subcommand takes its settings as flags or HUB_* environment variables; see vulnboxd-hub. Run migrate once, then ingest, assemble and api against the same ClickHouse, with ingest and assemble sharing the segment store. Run exactly one ingest.