secops(f6): de-privilege CI job containers + runner uid, add PSA labels
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).
This commit is contained in:
parent
9822647bf9
commit
86b17edc72
20 changed files with 349 additions and 8 deletions
|
|
@ -3,5 +3,11 @@ kind: Namespace
|
|||
metadata:
|
||||
name: customer1
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
app.kubernetes.io/part-of: customer1
|
||||
sirius.dev/purpose: lab-replica-of-client-stack
|
||||
|
|
|
|||
|
|
@ -2,3 +2,22 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: forgejo
|
||||
# Pod Security: warn/audit only. `enforce: baseline` is deliberately NOT set
|
||||
# yet: the three Actions runner Deployments in this namespace carry a
|
||||
# docker-in-docker sidecar that cannot lose `privileged: true` on these nodes
|
||||
# (see the long note in runner-amd64.yaml — procfs needs CAP_SYS_ADMIN,
|
||||
# kubelet mounts /sys/fs/cgroup read-only for non-privileged pods, and
|
||||
# rootless dind is blocked by the masked /proc and the absent /dev/net/tun).
|
||||
# Baseline would reject those pods at admission, i.e. take CI down rather
|
||||
# than harden it. The remaining fix (move the CI capsule to its own
|
||||
# explicitly-privileged namespace, or exempt the runner ServiceAccount) is
|
||||
# tracked on card t_2bbe34a8.
|
||||
#
|
||||
# warn/audit at `restricted` means every future pod creation here prints its
|
||||
# violations and records them as audit annotations, so the next privileged,
|
||||
# hostPath or hostNetwork pod is visible even without enforcement.
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ spec:
|
|||
nodeSelector:
|
||||
kubernetes.io/hostname: siriussec
|
||||
securityContext:
|
||||
fsGroup: 0
|
||||
# Group on the data volume; matches the runner's gid so the cache dir
|
||||
# stays writable even before fix-data-perms re-owns it.
|
||||
fsGroup: 1000
|
||||
initContainers:
|
||||
- name: register
|
||||
image: alex3305/forgejo-runner-dind:13-dind-rootless-28
|
||||
|
|
@ -68,6 +70,32 @@ spec:
|
|||
subPath: amd64.toml
|
||||
- name: data
|
||||
mountPath: /data
|
||||
# The runner container runs as uid 1000 (the image's own user) and needs
|
||||
# to read its registration and write the actions cache on this PVC.
|
||||
# Both were created by root before this change, so re-own them once per
|
||||
# start. Scoped on purpose: a recursive chown of the whole PVC would
|
||||
# walk the dind data-root (tens of GB on the Pi).
|
||||
- name: fix-data-perms
|
||||
image: docker:27-dind
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
# The image's own user. No root needed: the dind socket is created
|
||||
# 0660 root:1000 by `dockerd --group 1000`, and fix-data-perms
|
||||
# re-owns the PVC as 1000:1000 so the actions cache is writable.
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
chown 1000:1000 /data
|
||||
[ -f /data/runner.ini ] && chown 1000:1000 /data/runner.ini
|
||||
[ -d /data/cache ] && chown -R 1000:1000 /data/cache
|
||||
true
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
containers:
|
||||
- name: dind
|
||||
image: docker:27-dind
|
||||
|
|
@ -92,12 +120,14 @@ spec:
|
|||
# layer uploads >~100MB, so in-cluster pushes are the reliable
|
||||
# path for large images.
|
||||
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
||||
--group 1000 \
|
||||
--insecure-registry=forgejo.forgejo.svc.cluster.local:3000 &
|
||||
pid=$!
|
||||
i=0
|
||||
while [ "$i" -lt 30 ]; do
|
||||
# Readiness only: ownership is set by `dockerd --group 1000`
|
||||
# (socket 0660 root:1000) so the runner's uid 1000 can use it.
|
||||
if [ -S /var/run/docker.sock ]; then
|
||||
chmod 666 /var/run/docker.sock
|
||||
break
|
||||
fi
|
||||
i=$((i+1))
|
||||
|
|
@ -105,6 +135,25 @@ spec:
|
|||
done
|
||||
wait "$pid"
|
||||
securityContext:
|
||||
# Cannot be dropped on these nodes. Verified live 2026-11-27
|
||||
# (card t_2bbe34a8): a pod with `privileged: false` cannot host a
|
||||
# container runtime in this cluster, at three independent points:
|
||||
# 1. dind's own containers need CAP_SYS_ADMIN: runc mounts a fresh
|
||||
# procfs per container, and without the capability the daemon
|
||||
# fails with `mount src=proc ... operation not permitted`.
|
||||
# 2. kubelet mounts /sys/fs/cgroup read-only for non-privileged
|
||||
# pods, so dockerd cannot create /sys/fs/cgroup/docker
|
||||
# ("read-only file system") and no container can start.
|
||||
# 3. rootless dind (docker:27-dind-rootless) dies earlier: a
|
||||
# nested user namespace cannot mount procfs because the pod's
|
||||
# /proc is masked (kernel mount_too_revealing), and
|
||||
# procMount: Unmasked is only accepted with hostUsers: false —
|
||||
# where newuidmap cannot map subuids and /dev/net/tun cannot be
|
||||
# created (mknod is refused in a userns pod, and hostPath is
|
||||
# forbidden under Pod Security baseline).
|
||||
# What this file *does* remove: the runner's uid 0, the privileged
|
||||
# flag on CI job containers (runner configmap), and the old
|
||||
# chmod-666 socket race.
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: dind-run
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ spec:
|
|||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: rpi
|
||||
# Group on the data volume; matches the runner gid so the actions cache
|
||||
# stays writable after fix-data-perms re-owns it.
|
||||
securityContext:
|
||||
fsGroup: 1000
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Equal
|
||||
|
|
@ -31,6 +35,33 @@ spec:
|
|||
# No supplementalGroups: there is no host docker socket and no host
|
||||
# docker gid to match any more. The only daemon this runner talks to is
|
||||
# the privileged `dind` sidecar below.
|
||||
# The runner container runs as uid 1000 (the image's own user) and needs
|
||||
# to read its registration and write the actions cache on this PVC.
|
||||
# Both were created by root before this change, so re-own them once per
|
||||
# start. Scoped on purpose: a recursive chown of the whole PVC would
|
||||
# walk the dind data-root (tens of GB on the Pi).
|
||||
- name: fix-data-perms
|
||||
image: docker:27-dind
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
# Image default user (uid 1000). No root needed: the dind socket is
|
||||
# 0660 root:1000 (dockerd --group 1000) and fix-data-perms owns the
|
||||
# PVC as 1000:1000.
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
chown 1000:1000 /data
|
||||
[ -f /data/runner.ini ] && chown 1000:1000 /data/runner.ini
|
||||
[ -d /data/cache ] && chown -R 1000:1000 /data/cache
|
||||
true
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
|
||||
containers:
|
||||
# In-pod Docker daemon. Same shape as forgejo-runner-amd64: privileged,
|
||||
# socket on an emptyDir shared with the runner, data-root on the PVC.
|
||||
|
|
@ -58,12 +89,13 @@ spec:
|
|||
# so without this `docker push 10.10.0.1:5000/...` from a job
|
||||
# fails with "server gave HTTP response to HTTPS client".
|
||||
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
||||
--group 1000 \
|
||||
--insecure-registry=10.10.0.1:5000 &
|
||||
pid=$!
|
||||
i=0
|
||||
while [ "$i" -lt 30 ]; do
|
||||
# Readiness only; ownership is set by dockerd --group 1000.
|
||||
if [ -S /var/run/docker.sock ]; then
|
||||
chmod 666 /var/run/docker.sock
|
||||
break
|
||||
fi
|
||||
i=$((i+1))
|
||||
|
|
@ -71,6 +103,23 @@ spec:
|
|||
done
|
||||
wait "$pid"
|
||||
securityContext:
|
||||
# Cannot be dropped on these nodes. Verified live 2026-11-27
|
||||
# (card t_2bbe34a8): a pod with `privileged: false` cannot host a
|
||||
# container runtime in this cluster, at three independent points:
|
||||
# 1. dind's containers need CAP_SYS_ADMIN (runc mounts a fresh
|
||||
# procfs per container).
|
||||
# 2. kubelet mounts /sys/fs/cgroup read-only for non-privileged
|
||||
# pods, so dockerd cannot create /sys/fs/cgroup/docker
|
||||
# ("read-only file system") — no container can start.
|
||||
# 3. rootless dind (docker:27-dind-rootless) dies earlier: a
|
||||
# nested user namespace cannot mount procfs because the pod's
|
||||
# /proc is masked (kernel mount_too_revealing), and
|
||||
# procMount: Unmasked is only allowed with hostUsers: false,
|
||||
# where newuidmap cannot map subuids, and /dev/net/tun cannot
|
||||
# be created (mknod is refused inside a userns pod; hostPath
|
||||
# is forbidden by Pod Security baseline).
|
||||
# What *is* removed: privileged job containers (runner configmap),
|
||||
# the runner's uid 0, and the host docker socket (no hostPath).
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: dind-run
|
||||
|
|
|
|||
|
|
@ -26,7 +26,12 @@ data:
|
|||
enabled: true
|
||||
dir: /data/cache
|
||||
container:
|
||||
privileged: true
|
||||
# CI job containers run unprivileged. They still get the dind socket (a
|
||||
# bind mount in `options` below), which is what the build/deploy
|
||||
# workflows actually need; nothing in them needs extra capabilities.
|
||||
# This was `true` until card t_2bbe34a8 (audit F6): a privileged job
|
||||
# container inside a privileged dind was node root twice over.
|
||||
privileged: false
|
||||
# No docker_host here: setting it makes the runner inject the socket bind
|
||||
# into the job container itself, which collides with the explicit
|
||||
# -v /var/run/docker.sock in options ("Duplicate mount point"). The
|
||||
|
|
@ -69,7 +74,12 @@ data:
|
|||
enabled: true
|
||||
dir: /data/cache
|
||||
container:
|
||||
privileged: true
|
||||
# CI job containers run unprivileged. They still get the dind socket (a
|
||||
# bind mount in `options` below), which is what the build/deploy
|
||||
# workflows actually need; nothing in them needs extra capabilities.
|
||||
# This was `true` until card t_2bbe34a8 (audit F6): a privileged job
|
||||
# container inside a privileged dind was node root twice over.
|
||||
privileged: false
|
||||
# Same injection as arm64.toml: the job container is node:20-bullseye,
|
||||
# which has no docker CLI and no buildx, and deploy-site.yml needs both.
|
||||
# Both come from the dind sidecar's own filesystem. binfmt/QEMU is
|
||||
|
|
@ -98,7 +108,12 @@ data:
|
|||
enabled: true
|
||||
dir: /data/cache
|
||||
container:
|
||||
privileged: true
|
||||
# CI job containers run unprivileged. They still get the dind socket (a
|
||||
# bind mount in `options` below), which is what the build/deploy
|
||||
# workflows actually need; nothing in them needs extra capabilities.
|
||||
# This was `true` until card t_2bbe34a8 (audit F6): a privileged job
|
||||
# container inside a privileged dind was node root twice over.
|
||||
privileged: false
|
||||
# No docker_host: it injects the socket bind into the job container,
|
||||
# which collides with the explicit -v /var/run/docker.sock in options
|
||||
# ("Duplicate mount point"). The options bind is the deliberate choice.
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ spec:
|
|||
operator: Equal
|
||||
value: network
|
||||
effect: PreferNoSchedule
|
||||
# Group on the data volume, matching the runner gid (see fix-data-perms).
|
||||
securityContext:
|
||||
fsGroup: 1000
|
||||
initContainers:
|
||||
# Registration guard, NOT a registration step. The runner's identity
|
||||
# (`runner.ini`, action_runner id 14 / uuid a41aad73-…) is copied onto
|
||||
|
|
@ -73,6 +76,28 @@ spec:
|
|||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
# The runner container runs as uid 1000 (the image's own user) and needs
|
||||
# to read its registration and write the actions cache on this PVC.
|
||||
# Both were created by root before this change, so re-own them once per
|
||||
# start. Scoped on purpose: a recursive chown of the whole PVC would
|
||||
# walk the dind data-root.
|
||||
- name: fix-data-perms
|
||||
image: docker:27-dind
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
chown 1000:1000 /data
|
||||
[ -f /data/runner.ini ] && chown 1000:1000 /data/runner.ini
|
||||
[ -d /data/cache ] && chown -R 1000:1000 /data/cache
|
||||
true
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
containers:
|
||||
- name: dind
|
||||
image: docker:27-dind
|
||||
|
|
@ -86,12 +111,13 @@ spec:
|
|||
# so without this `docker push 10.10.0.1:5000/...` from a job
|
||||
# fails with "server gave HTTP response to HTTPS client".
|
||||
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
||||
--group 1000 \
|
||||
--insecure-registry=10.10.0.1:5000 &
|
||||
pid=$!
|
||||
i=0
|
||||
while [ "$i" -lt 30 ]; do
|
||||
# Readiness only: ownership is set by `dockerd --group 1000`.
|
||||
if [ -S /var/run/docker.sock ]; then
|
||||
chmod 666 /var/run/docker.sock
|
||||
break
|
||||
fi
|
||||
i=$((i+1))
|
||||
|
|
@ -99,6 +125,10 @@ spec:
|
|||
done
|
||||
wait "$pid"
|
||||
securityContext:
|
||||
# Cannot be dropped on these nodes: see the long note in
|
||||
# runner-amd64.yaml (procfs without CAP_SYS_ADMIN, /sys/fs/cgroup
|
||||
# mounted read-only by kubelet, rootless dind blocked by masked
|
||||
# /proc + missing /dev/net/tun). Verified live 2026-11-27.
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: dind-run
|
||||
|
|
@ -125,7 +155,11 @@ spec:
|
|||
image: code.forgejo.org/forgejo/runner:5.0.1
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
# Image default user. The dind socket is 0660 root:1000
|
||||
# (`dockerd --group 1000`) and fix-data-perms owns the PVC as
|
||||
# 1000:1000, so no root is needed here.
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
|
|
|
|||
|
|
@ -3,4 +3,10 @@ kind: Namespace
|
|||
metadata:
|
||||
name: metabase
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
app.kubernetes.io/part-of: metabase
|
||||
|
|
|
|||
|
|
@ -3,4 +3,8 @@ kind: Namespace
|
|||
metadata:
|
||||
name: netsec
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
app.kubernetes.io/part-of: netsec
|
||||
|
|
|
|||
|
|
@ -2,3 +2,10 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: osint
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
|
|
@ -3,4 +3,10 @@ kind: Namespace
|
|||
metadata:
|
||||
name: piedmont
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
app.kubernetes.io/part-of: piedmont
|
||||
|
|
|
|||
|
|
@ -3,4 +3,10 @@ kind: Namespace
|
|||
metadata:
|
||||
name: secops
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
app.kubernetes.io/part-of: secops
|
||||
|
|
|
|||
|
|
@ -3,4 +3,10 @@ kind: Namespace
|
|||
metadata:
|
||||
name: sirius-growth
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
app.kubernetes.io/part-of: sirius-growth
|
||||
|
|
|
|||
|
|
@ -2,3 +2,10 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: siriusdevops
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
96
docs/pod-security.md
Normal file
96
docs/pod-security.md
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# Pod Security posture (2026-11-27)
|
||||
|
||||
Status of Pod Security Admission (PSA) labels per namespace, why some namespaces
|
||||
enforce and others only warn/audit, and the one workload that cannot be
|
||||
de-privileged on these nodes.
|
||||
|
||||
## Levels in use
|
||||
|
||||
| level | namespaces |
|
||||
|---|---|
|
||||
| `enforce: baseline` + `warn`/`audit: restricted` | `customer1`, `metabase`, `osint`, `piedmont`, `secops`, `sirius-growth`, `siriusdevops`, `cert-manager` |
|
||||
| `warn`/`audit: restricted` only | `forgejo`, `netsec`, `monitoring`, `node-io`, `internal`, `gateway-system`, `local-path-storage`, plus cluster-owned `kube-system`, `kube-public`, `kube-node-lease`, `default`, `cnpg-system`, `cilium-secrets`, `logging`, `flux-system` |
|
||||
|
||||
The enforced set was picked by reading the live pods first: every namespace in
|
||||
it had zero baseline violations (no `privileged`, no `hostNetwork`/`hostPID`/
|
||||
`hostIPC`, no `hostPath`, no `hostPort`, no capability additions, no
|
||||
`seccompProfile: Unconfined`) on 2026-11-27. Enforcement is per *pod creation*,
|
||||
so a namespace that later needs one of those shapes has to be moved to
|
||||
warn/audit deliberately, with a comment, instead of being allowed by accident.
|
||||
|
||||
The warn/audit-only set is the opposite list — each one hosts a workload that
|
||||
baseline forbids today:
|
||||
|
||||
| namespace | blocker |
|
||||
|---|---|
|
||||
| `kube-system` | Cilium agent/envoy (hostNetwork, hostPath, privileged init, hostPorts), static control-plane pods |
|
||||
| `monitoring` | node-exporter (hostNetwork + hostPID + hostPath `/proc`,`/sys`,`/`) |
|
||||
| `logging` | Alloy DaemonSet (hostPath `/var/log`, journal, machine-id) |
|
||||
| `netsec` | hubble-flow-collector (hostPath socket + log dir) |
|
||||
| `node-io` | etcd-io-guard (privileged, hostPID, hostPath) |
|
||||
| `local-path-storage` | provisioner helper pods are privileged (created on every PVC) |
|
||||
| `internal`, `gateway-system` | reserved for hostNetwork Cilium Gateway listeners |
|
||||
| `forgejo` | Actions runner dind sidecars, see below |
|
||||
|
||||
`kube-system`, `kube-public`, `kube-node-lease`, `default`, `cnpg-system`,
|
||||
`cilium-secrets`, `logging` and `flux-system` are not declared in this repo
|
||||
(created by kubeadm/Helm/Flux), so their warn/audit labels are applied
|
||||
out-of-band; re-apply them after a control-plane rebuild:
|
||||
|
||||
```sh
|
||||
for ns in kube-system kube-public kube-node-lease default cnpg-system cilium-secrets logging flux-system; do
|
||||
kubectl label ns "$ns" --overwrite \
|
||||
pod-security.kubernetes.io/warn=restricted \
|
||||
pod-security.kubernetes.io/warn-version=latest \
|
||||
pod-security.kubernetes.io/audit=restricted \
|
||||
pod-security.kubernetes.io/audit-version=latest
|
||||
done
|
||||
```
|
||||
|
||||
## Why the Forgejo CI runners are still `privileged`
|
||||
|
||||
The three runner Deployments (`forgejo-runner-amd64`, `forgejo-runner-arm64`,
|
||||
`forgejo-runner-deploy-arm64`) keep a docker-in-docker sidecar with
|
||||
`privileged: true`. That is the reason `forgejo` is not in the enforced set:
|
||||
baseline rejects those pods at admission, so enforcing it would break Actions
|
||||
rather than harden it.
|
||||
|
||||
Three independent attempts to drop the flag were measured live on 2026-11-27
|
||||
(siriussec, kernel 6.18.50-lts; rpi reproduced the procfs failure):
|
||||
|
||||
1. **Explicit capability set** (`privileged: false`,
|
||||
`capabilities.add: [SYS_ADMIN, NET_ADMIN]`): dockerd starts and pulls
|
||||
images, but no container starts —
|
||||
`runc create failed: ... mkdir /sys/fs/cgroup/docker: read-only file system`.
|
||||
kubelet mounts `/sys/fs/cgroup` read-only for non-privileged pods. PSA
|
||||
baseline also forbids adding `SYS_ADMIN`/`NET_ADMIN`, so this shape cannot
|
||||
live in an enforced namespace at all.
|
||||
2. **Rootless dind** (`docker:27-dind-rootless`, uid 1000, vpnkit network):
|
||||
the daemon initialises and pulls images, but every container fails with
|
||||
`error mounting "proc" to rootfs at "/proc": operation not permitted`. A
|
||||
nested user namespace may only mount a fresh procfs if a fully visible
|
||||
procfs already exists in the namespace (kernel `mount_too_revealing`), and
|
||||
kubelet masks a number of `/proc` paths in every pod.
|
||||
3. **`procMount: Unmasked`** fixes (2), but the API only accepts it with
|
||||
`hostUsers: false`. In a user-namespace pod `newuidmap` cannot write a
|
||||
subuid map (it is not setuid-root inside that namespace) and `mknod
|
||||
/dev/net/tun` is refused, so rootless dind has neither a uid map nor the
|
||||
tun device it needs for networking.
|
||||
|
||||
What *was* removed in the same change:
|
||||
|
||||
* the runner container no longer runs as uid 0 — it uses the image's uid 1000,
|
||||
and the dind socket is created `0660 root:1000` via `dockerd --group 1000`
|
||||
(which also removes the old one-shot `chmod 666` race that forced root);
|
||||
* CI **job** containers are no longer privileged (`container.privileged: false`
|
||||
in the runner ConfigMap) — previously every job container was privileged
|
||||
inside a privileged dind;
|
||||
* there is still no `hostPath`, no `hostNetwork` and no host docker socket in
|
||||
any runner pod.
|
||||
|
||||
Remaining options for dropping `privileged` (each needs a design decision, not
|
||||
a manifest edit): move the runner Deployments into their own
|
||||
`pod-security.kubernetes.io/enforce: privileged` namespace so `forgejo` can
|
||||
enforce baseline; exempt the runner ServiceAccount from PSA via the API server
|
||||
`AdmissionConfiguration`; or introduce a runtime that virtualises the container
|
||||
runtime (sysbox / gVisor) and a matching `RuntimeClass`.
|
||||
|
|
@ -2,3 +2,10 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: cert-manager
|
||||
labels:
|
||||
pod-security.kubernetes.io/enforce: baseline
|
||||
pod-security.kubernetes.io/enforce-version: latest
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
|
|
@ -2,3 +2,8 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: gateway-system
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
|
|
@ -3,4 +3,8 @@ kind: Namespace
|
|||
metadata:
|
||||
name: internal
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
istio-injection: disabled
|
||||
|
|
|
|||
|
|
@ -2,3 +2,8 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: node-io
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: local-path-storage
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
|
|
|
|||
|
|
@ -2,3 +2,8 @@ apiVersion: v1
|
|||
kind: Namespace
|
||||
metadata:
|
||||
name: monitoring
|
||||
labels:
|
||||
pod-security.kubernetes.io/warn: restricted
|
||||
pod-security.kubernetes.io/warn-version: latest
|
||||
pod-security.kubernetes.io/audit: restricted
|
||||
pod-security.kubernetes.io/audit-version: latest
|
||||
|
|
|
|||
Loading…
Reference in a new issue