Move CI runner to an unprivileged Proxmox LXC #64

Closed
opened 2026-11-26 20:30:11 +01:00 by kasun · 3 comments
Owner

Why

All workflows in this repo (01 to 05) run on proxmox-lab-runner. That's the gitea/runner container on the Pi, next to Gitea, with problems that can't be fixed in place:

  • It needs /var/run/docker.sock. A job that reaches the socket has root on the Pi, which also runs Gitea, Postgres, Nextcloud and the other services.
  • It's registered for the whole instance, so any repo can schedule jobs on it.
  • It's on pg_network, so jobs can reach Postgres.
  • Jobs hold the most powerful credentials in the homelab: the Proxmox API tokens for pve1 to pve3, pfSense access, the Pulumi passphrase and the backend URL.

Moving the runner into a dedicated, unprivileged LXC outside the k3s cluster means a compromised job only gets a throwaway container. That container can be snapshotted and has firewalled egress. Keeping it outside the cluster also avoids a circular dependency: 01 and 02 create the cluster, so they can't depend on it.

Scope

In scope: a new runner LXC, ideally provisioned by 01-proxmox-infra; act_runner as a systemd service; Proxmox tokens scoped to what Pulumi needs; workflow runs-on changes; retiring the Docker runner.

Out of scope: the Ansible runner LXC, which stays separate (it holds different credentials); an in-cluster runner or GitOps for 03 to 05, which can be a follow-up.

Tasks

LXC

  • Unprivileged LXC (unprivileged: true, no nesting and no extra features unless something needs them). Debian or Ubuntu template, small sizing (2 vCPU, 2 to 4 GB RAM, ~20 GB disk)
  • Define it in 01-proxmox-infra so it's managed by Pulumi. Bootstrap it by hand the first time, since the runner can't create itself
  • Install the toolchain: Node 24, Pulumi CLI, Helm, git, plus whatever 02 needs to bootstrap k3s. Pin versions
  • Turn on Proxmox backups or snapshots for the LXC

Runner service

  • Dedicated non-root user act_runner with no sudo
  • Pinned act_runner binary, installed as a systemd unit with hardening (NoNewPrivileges, ProtectSystem=strict, ProtectHome, PrivateTmp, ReadWritePaths= limited to the runner's work dir)
  • Register it for this repo only (repo Settings → Actions → Runners), not the whole instance
  • Unique label, e.g. proxmox:host. capacity: 1
  • .runner and config.yaml set to 0600, owned by act_runner
  • Clean up the work dir after each job so decrypted Pulumi.dev.yaml files don't remain on disk

Credentials

  • A dedicated Proxmox user and API token for each node (or one for the cluster) with privilege separation turned on, in place of the current tokens
  • Least-privilege role on the pools and storage Pulumi manages (e.g. PVEVMAdmin + PVEDatastoreUser + PVESDNUser where needed). No root@pam, no Administrator
  • Update the *_PULUMI_DEV_YAML secrets with the new tokens, then revoke the old ones
  • Check what pfSense access 01 needs and narrow it the same way

Network

  • Proxmox firewall on the LXC: allow outbound traffic to Gitea, the Proxmox API (pve1 to pve3), pfSense, the Pulumi backend, the k3s API and the package/npm registries. Deny all else, including the Pi's Postgres and other LAN hosts
  • No inbound traffic except SSH from the admin network

Workflows

  • Change runs-on: ubuntu-latest to runs-on: proxmox in 01 to 05 (and secret-scan.yaml if it should run there)
  • Remove actions/setup-node and azure/setup-helm where the tools come from the LXC
  • Pin the remaining third-party actions (pulumi/actions, actions/checkout) to commit SHAs
  • Check each stack's preview and deploy on the new runner

Retire the Docker runner

  • Delete proxmox-lab-runner in Site Administration → Actions → Runners
  • Remove the gitea-runner service and GITEA_RUNNER_REGISTRATION_TOKEN from the Pi's gitea/docker-compose.yml and .env
  • Delete /home/pi/docker/gitea-runner/ (it holds the old runner token)

Docs

  • Runbook in docs/runbooks/ covering how to rebuild or re-register the runner LXC and rotate its Proxmox tokens
  • Decision record in docs/decisions/ covering the move to an unprivileged LXC with a systemd runner instead of Docker on the Pi or a k8s pod

Done when

  • All workflows in this repo run on the LXC runner, and preview and deploy pass for 01 to 05
  • The Docker runner on the Pi is gone and its token is deregistered
  • The old Proxmox tokens are revoked; the new ones can't do anything outside the Pulumi-managed pools
  • From the LXC, Postgres on the Pi can't be reached (check with nc -zv)
## Why All workflows in this repo (`01` to `05`) run on `proxmox-lab-runner`. That's the `gitea/runner` container on the Pi, next to Gitea, with problems that can't be fixed in place: - It needs `/var/run/docker.sock`. A job that reaches the socket has root on the Pi, which also runs Gitea, Postgres, Nextcloud and the other services. - It's registered for the whole instance, so any repo can schedule jobs on it. - It's on `pg_network`, so jobs can reach Postgres. - Jobs hold the most powerful credentials in the homelab: the Proxmox API tokens for pve1 to pve3, pfSense access, the Pulumi passphrase and the backend URL. Moving the runner into a dedicated, unprivileged LXC outside the k3s cluster means a compromised job only gets a throwaway container. That container can be snapshotted and has firewalled egress. Keeping it outside the cluster also avoids a circular dependency: `01` and `02` create the cluster, so they can't depend on it. ## Scope **In scope:** a new runner LXC, ideally provisioned by `01-proxmox-infra`; act_runner as a systemd service; Proxmox tokens scoped to what Pulumi needs; workflow `runs-on` changes; retiring the Docker runner. **Out of scope:** the Ansible runner LXC, which stays separate (it holds different credentials); an in-cluster runner or GitOps for `03` to `05`, which can be a follow-up. ## Tasks ### LXC - [ ] Unprivileged LXC (`unprivileged: true`, no `nesting` and no extra features unless something needs them). Debian or Ubuntu template, small sizing (2 vCPU, 2 to 4 GB RAM, ~20 GB disk) - [ ] Define it in `01-proxmox-infra` so it's managed by Pulumi. Bootstrap it by hand the first time, since the runner can't create itself - [ ] Install the toolchain: Node 24, Pulumi CLI, Helm, git, plus whatever `02` needs to bootstrap k3s. Pin versions - [ ] Turn on Proxmox backups or snapshots for the LXC ### Runner service - [ ] Dedicated non-root user `act_runner` with no sudo - [ ] Pinned `act_runner` binary, installed as a systemd unit with hardening (`NoNewPrivileges`, `ProtectSystem=strict`, `ProtectHome`, `PrivateTmp`, `ReadWritePaths=` limited to the runner's work dir) - [ ] Register it **for this repo only** (repo Settings → Actions → Runners), not the whole instance - [ ] Unique label, e.g. `proxmox:host`. `capacity: 1` - [ ] `.runner` and `config.yaml` set to `0600`, owned by `act_runner` - [ ] Clean up the work dir after each job so decrypted `Pulumi.dev.yaml` files don't remain on disk ### Credentials - [ ] A dedicated Proxmox user and API token for each node (or one for the cluster) with **privilege separation** turned on, in place of the current tokens - [ ] Least-privilege role on the pools and storage Pulumi manages (e.g. `PVEVMAdmin` + `PVEDatastoreUser` + `PVESDNUser` where needed). No `root@pam`, no `Administrator` - [ ] Update the `*_PULUMI_DEV_YAML` secrets with the new tokens, then revoke the old ones - [ ] Check what pfSense access `01` needs and narrow it the same way ### Network - [ ] Proxmox firewall on the LXC: allow outbound traffic to Gitea, the Proxmox API (pve1 to pve3), pfSense, the Pulumi backend, the k3s API and the package/npm registries. Deny all else, including the Pi's Postgres and other LAN hosts - [ ] No inbound traffic except SSH from the admin network ### Workflows - [ ] Change `runs-on: ubuntu-latest` to `runs-on: proxmox` in `01` to `05` (and `secret-scan.yaml` if it should run there) - [ ] Remove `actions/setup-node` and `azure/setup-helm` where the tools come from the LXC - [ ] Pin the remaining third-party actions (`pulumi/actions`, `actions/checkout`) to commit SHAs - [ ] Check each stack's preview and deploy on the new runner ### Retire the Docker runner - [ ] Delete `proxmox-lab-runner` in Site Administration → Actions → Runners - [ ] Remove the `gitea-runner` service and `GITEA_RUNNER_REGISTRATION_TOKEN` from the Pi's `gitea/docker-compose.yml` and `.env` - [ ] Delete `/home/pi/docker/gitea-runner/` (it holds the old runner token) ### Docs - [ ] Runbook in `docs/runbooks/` covering how to rebuild or re-register the runner LXC and rotate its Proxmox tokens - [ ] Decision record in `docs/decisions/` covering the move to an unprivileged LXC with a systemd runner instead of Docker on the Pi or a k8s pod ## Done when - All workflows in this repo run on the LXC runner, and preview and deploy pass for `01` to `05` - The Docker runner on the Pi is gone and its token is deregistered - The old Proxmox tokens are revoked; the new ones can't do anything outside the Pulumi-managed pools - From the LXC, Postgres on the Pi can't be reached (check with `nc -zv`)

Superseded by the security roadmap tickets:

  • LXC, firewall, backups: #82
  • act_runner install, registration, retiring the Docker runner: kasun/homelab-ansible#18
  • Design decision (Docker job containers instead of host mode or k8s pods): decision record in #82

Changes from this ticket: jobs run in Docker containers, not host mode, so actions/setup-node and azure/setup-helm stay and the toolchain doesn't need to be installed on the LXC. The LXC needs nesting and keyctl for that.

Not covered by those tickets yet, still to do:

  • Dedicated Proxmox user and API tokens with privilege separation, least-privilege role (no root@pam, no Administrator); update the *_PULUMI_DEV_YAML secrets, then revoke the old tokens
  • Narrow the pfSense access 01 needs
  • Pin third-party actions (pulumi/actions, actions/checkout, ...) to commit SHAs (may fit Roadmap 1.3, Renovate with digest pinning)
  • Runbook in docs/runbooks/ for rebuilding or re-registering the runner and rotating its Proxmox tokens
Superseded by the security roadmap tickets: - LXC, firewall, backups: #82 - act_runner install, registration, retiring the Docker runner: kasun/homelab-ansible#18 - Design decision (Docker job containers instead of host mode or k8s pods): decision record in #82 Changes from this ticket: jobs run in Docker containers, not host mode, so `actions/setup-node` and `azure/setup-helm` stay and the toolchain doesn't need to be installed on the LXC. The LXC needs `nesting` and `keyctl` for that. **Not covered by those tickets yet**, still to do: - [ ] Dedicated Proxmox user and API tokens with privilege separation, least-privilege role (no `root@pam`, no `Administrator`); update the `*_PULUMI_DEV_YAML` secrets, then revoke the old tokens - [ ] Narrow the pfSense access `01` needs - [ ] Pin third-party actions (`pulumi/actions`, `actions/checkout`, ...) to commit SHAs (may fit Roadmap 1.3, Renovate with digest pinning) - [ ] Runbook in `docs/runbooks/` for rebuilding or re-registering the runner and rotating its Proxmox tokens
claude-bot Bot closed this issue 2026-12-04 18:07:11 +01:00

The tasks listed above as not covered are now tracked in #92.

The tasks listed above as not covered are now tracked in #92.

Update: the runner will be a VM, not an LXC (#82). Docker in an LXC would need nesting + keyctl, which widens the shared-kernel attack surface towards the Proxmox host; the runner holds the most powerful credentials, so it gets its own kernel. Everything else in the comment above still applies.

Update: the runner will be a **VM**, not an LXC (#82). Docker in an LXC would need `nesting` + `keyctl`, which widens the shared-kernel attack surface towards the Proxmox host; the runner holds the most powerful credentials, so it gets its own kernel. Everything else in the comment above still applies.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kasun/homelab-infrastructure-as-code#64