secops(f6): de-privilege CI job containers + runner uid, add Pod Security labels #54

Merged
sirius merged 1 commit from secops/f6-runner-deprivilege-psa into master 2026-11-27 05:42:39 +00:00
Owner

Finding F6 — CI runners, Pod Security

Implements what is technically possible on these nodes; the parts that are not
possible are documented with measured evidence in docs/pod-security.md.

Runners (all three Deployments)

  • runner container: uid 0 → 1000 (the image's own user). The socket race that
    forced root is gone: dockerd --group 1000 creates /var/run/docker.sock as
    0660 root:1000, and a scoped fix-data-perms init container re-owns
    runner.ini + /data/cache.
  • CI job containers are no longer privileged (container.privileged: false
    in the runner ConfigMap). Before: a privileged job container inside a
    privileged dind.
  • The dind sidecar keeps privileged: true — see below — with the reason
    recorded inline in every manifest.

Pod Security

  • enforce: baseline (+ warn/audit restricted) on the eight namespaces that
    had zero baseline violations in a live read (2026-11-27):
    customer1, metabase, osint, piedmont, secops, sirius-growth,
    siriusdevops, cert-manager.
  • warn + audit: restricted on every other namespace (repo-declared, plus
    kube-system, kube-public, kube-node-lease, default, cnpg-system,
    cilium-secrets, logging, flux-system applied out-of-band).

Why forgejo is not enforce: baseline yet

The dind sidecar cannot lose privileged here. Measured, three independent wall:

  1. privileged: false + capabilities.add: [SYS_ADMIN, NET_ADMIN]: dockerd runs
    and pulls, but no container starts — mkdir /sys/fs/cgroup/docker: read-only file system (kubelet mounts the cgroup fs read-only for non-privileged pods).
  2. rootless dind (docker:27-dind-rootless): daemon up, every container dies on
    error mounting "proc" ... operation not permitted — a nested userns may only
    mount procfs if a fully-visible procfs exists, and kubelet masks /proc paths.
  3. procMount: Unmasked (the fix for 2) requires hostUsers: false, where
    newuidmap cannot write a subuid map and /dev/net/tun cannot be created.

Enforcing baseline on forgejo today rejects the runner pods at admission =
Actions down. Options (namespace split / PSA SA exemption / sysbox|gVisor) are a
design decision, tracked on the card.

Verification

  • kubectl kustomize apps/home builds (147 objects).
  • CI: real deploy runs after the merge (URLs in the card).
## Finding F6 — CI runners, Pod Security Implements what is technically possible on these nodes; the parts that are not possible are documented with measured evidence in `docs/pod-security.md`. ### Runners (all three Deployments) * **runner container: uid 0 → 1000** (the image's own user). The socket race that forced root is gone: `dockerd --group 1000` creates `/var/run/docker.sock` as `0660 root:1000`, and a scoped `fix-data-perms` init container re-owns `runner.ini` + `/data/cache`. * **CI job containers are no longer privileged** (`container.privileged: false` in the runner ConfigMap). Before: a privileged job container inside a privileged dind. * The dind sidecar keeps `privileged: true` — see below — with the reason recorded inline in every manifest. ### Pod Security * `enforce: baseline` (+ warn/audit `restricted`) on the eight namespaces that had **zero** baseline violations in a live read (2026-11-27): `customer1`, `metabase`, `osint`, `piedmont`, `secops`, `sirius-growth`, `siriusdevops`, `cert-manager`. * `warn` + `audit: restricted` on every other namespace (repo-declared, plus `kube-system`, `kube-public`, `kube-node-lease`, `default`, `cnpg-system`, `cilium-secrets`, `logging`, `flux-system` applied out-of-band). ### Why `forgejo` is not `enforce: baseline` yet The dind sidecar cannot lose `privileged` here. Measured, three independent wall: 1. `privileged: false` + `capabilities.add: [SYS_ADMIN, NET_ADMIN]`: dockerd runs and pulls, but no container starts — `mkdir /sys/fs/cgroup/docker: read-only file system` (kubelet mounts the cgroup fs read-only for non-privileged pods). 2. rootless dind (`docker:27-dind-rootless`): daemon up, every container dies on `error mounting "proc" ... operation not permitted` — a nested userns may only mount procfs if a fully-visible procfs exists, and kubelet masks /proc paths. 3. `procMount: Unmasked` (the fix for 2) requires `hostUsers: false`, where `newuidmap` cannot write a subuid map and `/dev/net/tun` cannot be created. Enforcing baseline on `forgejo` today rejects the runner pods at admission = Actions down. Options (namespace split / PSA SA exemption / sysbox|gVisor) are a design decision, tracked on the card. ### Verification * `kubectl kustomize apps/home` builds (147 objects). * CI: real deploy runs after the merge (URLs in the card).
Audit finding F6 (2026-11-27-cluster-netsec-audit.md).

Runners (all three Deployments):
* runner container no longer runs as uid 0 — image uid 1000. The dind socket is
  now created 0660 root:1000 via `dockerd --group 1000`, which removes the
  one-shot `chmod 666` race that was the reason for running as root; a scoped
  fix-data-perms init container re-owns runner.ini + the actions cache.
* CI *job* containers are no longer privileged (container.privileged: false) —
  previously every job container was privileged inside a privileged dind.

Pod Security:
* enforce baseline on the eight namespaces that have zero baseline violations
  (customer1, metabase, osint, piedmont, secops, sirius-growth, siriusdevops,
  cert-manager), warn+audit restricted everywhere else (repo-declared and
  cluster-owned), so the next privileged/hostPath/hostNetwork pod is visible.
* forgejo itself stays warn/audit: the runner dind sidecar cannot lose
  privileged on these nodes (documented in docs/pod-security.md, with the three
  measured failure modes: procfs needs SYS_ADMIN, /sys/fs/cgroup is read-only
  for non-privileged pods, rootless dind blocked by masked /proc + no tun).
sirius merged commit cb387a8121 into master 2026-11-27 05:42:39 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!54
No description provided.