Implements the credential model the operator chose for wiring L2/L3 into CI: a narrow
trigger SA bounded by a fail-closed Kyverno admission policy, rather than the
zero-credential GitOps-native alternative (plan section 4, primary model).
THE ESCALATION THIS CLOSES. Kubernetes places NO `use` check on a Job's
serviceAccountName. Any principal that can `create jobs` in ns conformance can create a Job
running as conformance-runner -- nodes/patch, pods/exec, namespaces/patch -- with an
arbitrary command. A CI token with plain `create jobs` IS that privileged identity no matter
how narrow its own Role looks. RBAC cannot fix this; only constraining the SHAPE of what the
trigger may create can.
Adds:
* SA/Role/RoleBinding conformance-trigger -- create+get+list+watch jobs, get pods and
pods/log, nothing else. Namespaced. No delete (a trigger that can delete can hide a
failed run), no exec, no secrets. Results come back as a tarball on stdout read via
pods/log, so no execution channel into the runner pod is ever granted.
* ClusterPolicy conformance-trigger-job-shape -- Enforce, failurePolicy: Fail. It does NOT
use ${KYVERNO_VALIDATION_ACTION}: a security boundary an overlay can downgrade to Audit
is not a boundary. It constrains ONLY conformance-trigger, so a mistake here cannot wedge
the rest of the cluster.
* Flux Kustomization `conformance` -> ./conformance/incluster, wait:false and non-gating
like apps-vms, so a test identity can never stall the platform or app tiers.
* A kyverno test with seven cases, six of them real escalation paths.
VERIFIED by `kyverno apply` (pass: 10, fail: 6, error: 0), not assumed:
evil-command DENIED at /spec/template/spec/containers/0/command/ <- THE attack
evil-image DENIED at .../image/
tag-not-digest DENIED at .../image/ (mutable tag is republishable)
host-namespaces DENIED at /spec/template/spec/hostPID/
extra-volume DENIED by the volumes foreach
injected-args DENIED by the args foreach
good-run ADMITTED
ALSO FIXES A FAIL-OPEN IN THE GATE ITSELF. `kyverno test` does NOT fail when a policy cannot
LOAD: every row becomes "Skip / Invalid Policy" and it still prints "N tests passed" and
exits 0. Measured while writing this policy -- a schema error (subjects in a separate
match.all entry from resources) produced exactly that, and ci/l0.sh would have certified a
security policy that does not load as green. This is not specific to this policy: a typo in
restrict-host-namespaces or secret-provenance would silently disable it with the gate still
green. ci/l0.sh now scans for "Invalid Policy" and fails. Proven: broken policy -> l0 rc=1,
restored -> rc=0.
IMAGE PINNING, HONEST LIMIT: the plan specifies pinning the exact runner image digest. That
image does not exist yet, so this enforces the enforceable half -- the image must be under
the conformance repository path AND digest-pinned, never a mutable tag. Residual surface:
anyone who can PUSH to that path could publish a different digest. Tighten to the literal
digest when the image is built; it is a one-line change to the pattern, reviewed in a PR,
which is where a change to a security boundary belongs.
NOT YET WIRED, deliberately: no runner image, no trigger kubeconfig, no CLUSTER_AVAILABLE.
The identities here are inert until those exist, and PR #12 makes CLUSTER_AVAILABLE=true
block rather than fake a green in the meantime.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
27 lines
1.4 KiB
YAML
27 lines
1.4 KiB
YAML
# In-cluster enforcing bundle (SCAFFOLDING for T-2.7; not applied in Phase 0).
|
|
# Installs Kyverno and applies the SAME policies authored for the CI L0 gate as an
|
|
# admission controller -- authored once, shared between CLI and admission (ADR-0011).
|
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
kind: Kustomization
|
|
namespace: kyverno
|
|
resources:
|
|
- namespace.yaml
|
|
- helmrelease.yaml
|
|
# --- policies SHARED verbatim with the CI L0 gate ---
|
|
- ../policies/require-default-deny-baseline.yaml
|
|
- ../policies/validate-default-deny-shape.yaml
|
|
- ../policies/restrict-host-namespaces.yaml
|
|
- ../policies/require-egress-class-label.yaml
|
|
- ../policies/require-auth-mode-label.yaml
|
|
# mutate: gives CDI's OWN generated worker pods (importer-*/uploader-*/cloner-*) the two
|
|
# labels the policies above require -- they are controller-generated, so nothing in git can
|
|
# label them. Ships with them, never separately.
|
|
- ../policies/label-cdi-worker-pods.yaml
|
|
# --- secrets: the admission variant REPLACES the CI-only sops-block policy ---
|
|
# (../policies/disallow-plaintext-secrets.yaml is CI-only; see secret-provenance.yaml)
|
|
- secret-provenance.yaml
|
|
# --- R-SEC-02: constrain what the conformance CI trigger may create ---
|
|
# THE security boundary for CI cluster access. Enforce + fail-closed, deliberately NOT
|
|
# subject to ${KYVERNO_VALIDATION_ACTION}. See the file header.
|
|
- conformance-trigger-job-shape.yaml
|