The log was a second plaintext copy of every secret that had been read: of 3,527 secret events on the live log, 2,574 carried .data in responseObject (1,606 were plain get). A get is fully described by objectRef + user + sourceIPs + responseStatus; the body adds a credential and no forensic value, and root reading the root-only log produces no audit event at all. - rule 4a: secrets get/list/watch -> Metadata - rule 4b: secrets create/update/patch/delete/deletecollection -> RequestResponse (the tampering verbs; the body there is the evidence) - everything else untouched: pods/exec, tokenreviews, RBAC/cert writes, proxies docs: rule table, read/write rationale, sensitivity + purge notes.
138 lines
5.5 KiB
YAML
138 lines
5.5 KiB
YAML
apiVersion: audit.k8s.io/v1
|
|
kind: Policy
|
|
# One record per request instead of two (RequestReceived + ResponseComplete).
|
|
# The completion record carries responseStatus and is the forensic one.
|
|
omitStages:
|
|
- RequestReceived
|
|
# server-managed noise, never evidence
|
|
omitManagedFields: true
|
|
|
|
# Volume note (measured 2026-11-27 on this cluster): full bodies for every secret
|
|
# verb peaked at 22.8 GB/day, driven almost entirely by `list secrets` (1.9 MiB per
|
|
# event: flux helm-controller enumerating every secret on each reconcile) during a
|
|
# reconcile storm.
|
|
#
|
|
# Read/write split: secret READS (get/list/watch) are Metadata - the body is a
|
|
# credential and objectRef already answers who/which/from where. Secret WRITES
|
|
# (create/update/patch/delete) keep full request/response - the body there is the
|
|
# evidence (an attacker planting their own key), not a credential to protect.
|
|
# Measured before the split: 2,574 of 3,527 secret events carried `.data` in
|
|
# responseObject, i.e. the log was a second copy of every secret that had been read.
|
|
# Everything else - pods/exec, tokenreviews, RBAC writes, proxies - is unchanged.
|
|
# Measured steady state: ~2.2 GB/day total, ~0.25 GB/day of which is secret traffic;
|
|
# a reconcile storm adds a bounded burst that rotation absorbs.
|
|
rules:
|
|
# ---------------------------------------------------------------- 1. silence
|
|
# Liveness/version/discovery surface: polled by kubelet on every node every
|
|
# few seconds and carries no identity information.
|
|
- level: None
|
|
verbs: ["get"]
|
|
nonResourceURLs:
|
|
- /healthz
|
|
- /healthz/*
|
|
- /livez
|
|
- /livez/*
|
|
- /readyz
|
|
- /readyz/*
|
|
- /version
|
|
- /version/*
|
|
- /openapi/v2
|
|
- /openapi/v3
|
|
- /openapi/v3/*
|
|
- /metrics
|
|
|
|
# Leader election / heartbeat / event spam.
|
|
- level: None
|
|
resources:
|
|
- group: coordination.k8s.io
|
|
resources: ["leases"]
|
|
- group: ""
|
|
resources: ["events"]
|
|
- group: events.k8s.io
|
|
resources: ["events"]
|
|
|
|
# Informer watch subscriptions on high-volume, non-secret resources: recorded
|
|
# once at subscribe time and the payload never enters the record. secrets,
|
|
# RBAC and certificate objects are deliberately NOT here - a watch on those is
|
|
# itself worth a record (rules 4/6 keep it, minus the body).
|
|
- level: None
|
|
verbs: ["watch"]
|
|
resources:
|
|
- group: ""
|
|
resources: ["pods", "nodes", "services", "endpoints", "configmaps",
|
|
"persistentvolumes", "persistentvolumeclaims"]
|
|
- group: discovery.k8s.io
|
|
resources: ["endpointslices"]
|
|
- group: networking.k8s.io
|
|
resources: ["ingresses", "networkpolicies"]
|
|
- group: apiextensions.k8s.io
|
|
resources: ["customresourcedefinitions"]
|
|
- group: storage.k8s.io
|
|
resources: ["storageclasses"]
|
|
|
|
# ---------------------- 4a. secrets: READS (corpus + single object) = Metadata
|
|
# `list` returns EVERY secret in the namespace (measured 1.9 MiB per event, dozens
|
|
# per flux reconcile storm); `get` returns one object whose responseObject.data is
|
|
# the live credential. Neither body is evidence: objectRef + user + sourceIPs +
|
|
# responseStatus fully answers "who read which secret, when, and did it succeed".
|
|
# Keeping the body writes a second plaintext copy of every secret into a root-only
|
|
# file that no audit event covers (root can read the log without touching the API).
|
|
- level: Metadata
|
|
verbs: ["get", "list", "watch"]
|
|
resources:
|
|
- group: ""
|
|
resources: ["secrets"]
|
|
|
|
# -------------------- 4b. secrets: WRITES = full request/response bodies
|
|
# The tampering verbs. Here the body IS the evidence: who planted which key, who
|
|
# rewrote the forgejo-pull dockerconfigjson, who deleted the SOPS age key secret.
|
|
# Verbs are enumerated so an unknown future verb falls through to Metadata (rule 6)
|
|
# rather than silently acquiring a body.
|
|
- level: RequestResponse
|
|
verbs: ["create", "update", "patch", "delete", "deletecollection"]
|
|
resources:
|
|
- group: ""
|
|
resources: ["secrets"]
|
|
|
|
# ------------------- 3. RBAC / certs enumeration: identity + request, no response
|
|
# list/watch of roles & bindings returns whole objects; the write paths are what
|
|
# matter and rule 6 keeps those at RequestResponse.
|
|
- level: Request
|
|
verbs: ["list", "watch"]
|
|
resources:
|
|
- group: rbac.authorization.k8s.io
|
|
resources: ["*"]
|
|
- group: certificates.k8s.io
|
|
resources: ["*"]
|
|
|
|
# -------------------------------- 5. everything privileged-but-authorized
|
|
- level: RequestResponse
|
|
resources:
|
|
- group: ""
|
|
resources:
|
|
- serviceaccounts/token
|
|
- pods/exec
|
|
- pods/attach
|
|
- pods/portforward
|
|
# every verb + subresource: create/update/patch/bind/escalate of a
|
|
# ClusterRoleBinding is a cluster takeover, not a config change
|
|
- group: rbac.authorization.k8s.io
|
|
resources: ["*"]
|
|
# CSR approval signs new client certs against the cluster CA
|
|
- group: certificates.k8s.io
|
|
resources: ["*"]
|
|
# acting as another identity
|
|
- level: RequestResponse
|
|
verbs: ["impersonate"]
|
|
|
|
# Metadata + request body only: kubelet/API proxies can return multi-MB bodies
|
|
# (metrics, pprof, logs) and the response is the volume, not the evidence.
|
|
- level: Request
|
|
resources:
|
|
- group: ""
|
|
resources: ["pods/proxy", "nodes/proxy", "nodes/log", "nodes/metrics",
|
|
"nodes/spec", "nodes/stats"]
|
|
|
|
# ------------------------------------------------------------------ 6. default
|
|
# who / what / when / from where / status code - no bodies.
|
|
- level: Metadata
|