From 2e52bfad243e05aca90d612b0c4deb153a1eb6e7 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 27 Nov 2026 00:08:14 -0500 Subject: [PATCH] apps(secops): scoped read-only auditor ServiceAccount + ClusterRole (F8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Security runs had no read-only identity: every audit ran as kubernetes-admin (system:masters), the identity that can delete the cluster, so the auditor was the largest privilege holder in the environment. New ns secops with SA secops-auditor bound to a from-scratch ClusterRole: get,list,watch pods services endpoints events configmaps namespaces nodes get,list,watch * in apps, batch, networking.k8s.io, gateway.networking.k8s.io, cilium.io get pods/log Deliberately absent: secrets (all verbs), pods/exec, pods/attach, every write verb, impersonate/escalate/bind. Not bound to view/edit/admin (all three carry Secrets; edit reads Secret data). The bearer token is a credential and is generated out of band into ~/.kube/secops.yaml (mode 600) โ€” see the SA manifest comment for the one-liner. --- apps/base/secops/clusterrole.yaml | 48 ++++++++++++++++++++++++ apps/base/secops/clusterrolebinding.yaml | 14 +++++++ apps/base/secops/kustomization.yaml | 7 ++++ apps/base/secops/namespace.yaml | 6 +++ apps/base/secops/serviceaccount.yaml | 18 +++++++++ apps/home/kustomization.yaml | 1 + 6 files changed, 94 insertions(+) create mode 100644 apps/base/secops/clusterrole.yaml create mode 100644 apps/base/secops/clusterrolebinding.yaml create mode 100644 apps/base/secops/kustomization.yaml create mode 100644 apps/base/secops/namespace.yaml create mode 100644 apps/base/secops/serviceaccount.yaml diff --git a/apps/base/secops/clusterrole.yaml b/apps/base/secops/clusterrole.yaml new file mode 100644 index 0000000..b762ad2 --- /dev/null +++ b/apps/base/secops/clusterrole.yaml @@ -0,0 +1,48 @@ +# Deliberately built from scratch: do NOT swap this for the built-in `view`, +# `edit` or `admin` ClusterRoles. All three include Secrets (`view` can read +# Secret metadata and `edit` can read Secret data), which defeats the purpose of +# a read-only audit identity. `edit` is effectively read-all + write. +# +# Deliberately absent, and must stay absent: +# - secrets (would expose every credential in the cluster) +# - pods/exec, pods/attach (would be arbitrary code execution in any pod, +# and the flow collector pattern โ€” socket mount โ€” +# exists precisely so hubble needs no exec) +# - events create/patch (only get/list/watch) +# - any write verb on any resource +# +# kubectl auth can-i / kubectl logs still work: SelfSubjectAccessReview and API +# discovery come from the default `system:basic-user` / `system:discovery` +# bindings to system:authenticated, not from this role. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: secops-auditor + labels: + app.kubernetes.io/part-of: secops +rules: + - apiGroups: [""] + resources: + - pods + - services + - endpoints + - events + - configmaps + - namespaces + - nodes + verbs: ["get", "list", "watch"] + # Pod logs, read only. No `pods/exec`, no `pods/attach`. + - apiGroups: [""] + resources: ["pods/log"] + verbs: ["get"] + # Workload / policy / ingress / CNI object models, read only. Group-scoped + # wildcard so the identity follows CRD additions in these groups without + # another RBAC change (none of them carry Secret data). + - apiGroups: + - apps + - batch + - networking.k8s.io + - gateway.networking.k8s.io + - cilium.io + resources: ["*"] + verbs: ["get", "list", "watch"] diff --git a/apps/base/secops/clusterrolebinding.yaml b/apps/base/secops/clusterrolebinding.yaml new file mode 100644 index 0000000..94f1a19 --- /dev/null +++ b/apps/base/secops/clusterrolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: secops-auditor + labels: + app.kubernetes.io/part-of: secops +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: secops-auditor +subjects: + - kind: ServiceAccount + name: secops-auditor + namespace: secops diff --git a/apps/base/secops/kustomization.yaml b/apps/base/secops/kustomization.yaml new file mode 100644 index 0000000..581c169 --- /dev/null +++ b/apps/base/secops/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + - serviceaccount.yaml + - clusterrole.yaml + - clusterrolebinding.yaml diff --git a/apps/base/secops/namespace.yaml b/apps/base/secops/namespace.yaml new file mode 100644 index 0000000..ea50020 --- /dev/null +++ b/apps/base/secops/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: secops + labels: + app.kubernetes.io/part-of: secops diff --git a/apps/base/secops/serviceaccount.yaml b/apps/base/secops/serviceaccount.yaml new file mode 100644 index 0000000..e8a6a8f --- /dev/null +++ b/apps/base/secops/serviceaccount.yaml @@ -0,0 +1,18 @@ +# Read-only audit identity for security runs (netsec design ยง3.3, audit finding F8). +# +# Security work must NOT run as kubernetes-admin / system:masters: that identity +# can delete the cluster, so an investigator holding it is the largest privilege +# holder in the environment. This SA exists so audit runs are scoped, attributable +# and harmless. It holds no secrets and cannot exec/attach into pods. +# +# The kubeconfig that carries it is generated out of band (a token is a credential +# and must never be committed): +# kubectl -n secops create token secops-auditor --duration=8760h +# and written to ~/.kube/secops.yaml (mode 600) on the operator host. +apiVersion: v1 +kind: ServiceAccount +metadata: + name: secops-auditor + namespace: secops + labels: + app.kubernetes.io/part-of: secops diff --git a/apps/home/kustomization.yaml b/apps/home/kustomization.yaml index ed41cd9..ae9e307 100644 --- a/apps/home/kustomization.yaml +++ b/apps/home/kustomization.yaml @@ -9,3 +9,4 @@ resources: - ../base/metabase - ../base/customer1 - ../base/netsec + - ../base/secops -- 2.52.0