controlplane: audit — full bodies for secret writes, metadata only for list/watch

Measured on the live cluster: the 22.8 GB/day burst was driven by `list secrets`
(1.9 MiB per event — every secret in the namespace) and by helm-controller
rewriting its release blobs. Only list/watch give up their bodies now, so
"who rewrote this secret, and to what" stays reconstructable; steady state is
0.79 GB/day / ~420 events/min, i.e. ~6 days inside 48 x 100 MiB.

Re-verified after the change: create secret (server dry-run) records
requestObject.data; get/patch behave the same.
This commit is contained in:
Lance Walters 2026-11-27 00:28:24 -05:00
commit 2c7eab2b0b
2 changed files with 34 additions and 26 deletions

View file

@ -46,27 +46,32 @@ one carrying `responseStatus`). `omitManagedFields: true` drops server-managed f
| 1 | None | `/healthz* /livez* /readyz* /version /openapi* /metrics`, GET | kubelet polls these every few seconds per node |
| 2 | None | `coordination.k8s.io/leases`, `events` | leader election / heartbeat / event spam |
| 3 | None | `watch` on pods, nodes, services, endpoints, configmaps, PV/PVC, endpointslices, ingresses, netpols, CRDs, storageclasses | a watch is recorded once at subscribe time and its payload never enters the record. **secrets/RBAC/certs are deliberately not listed** — a watch on those is itself worth a record |
| 4 | Metadata | `secrets` **list, watch, update** | measured volume control, see below |
| 4 | Metadata | `secrets` **list, watch** | corpus dumps only, see below |
| 5 | Request | `rbac.authorization.k8s.io/*`, `certificates.k8s.io/*` **list, watch** | whole-object listings; the write paths stay at rule 6 |
| 6 | **RequestResponse** | `secrets` get/create/patch/delete/deletecollection, `serviceaccounts/token`, `pods/exec`, `pods/attach`, `pods/portforward`, `rbac.authorization.k8s.io/*`, `certificates.k8s.io/*`, verb `impersonate` | the privileged-but-authorized calls: full request+response bodies |
| 6 | **RequestResponse** | `secrets` (every verb except list/watch), `serviceaccounts/token`, `pods/exec`, `pods/attach`, `pods/portforward`, `rbac.authorization.k8s.io/*`, `certificates.k8s.io/*`, verb `impersonate` | the privileged-but-authorized calls: full request+response bodies |
| 7 | Request | `pods/proxy`, `nodes/proxy`, `nodes/log`, `nodes/metrics`, `nodes/spec`, `nodes/stats` | who proxied to which kubelet; the multi-MB response body is volume, not evidence |
| 8 | Metadata | everything else | who / what / when / from where / status code |
### Why `list`/`update` on secrets is Metadata and not RequestResponse
### Why `list`/`watch` on secrets is Metadata and not RequestResponse
First cut was `RequestResponse` for every secret verb. Measured on this cluster it cost
**22.8 GB/day** and would have rotated the whole retention window every ~2 hours:
The first cut logged full bodies for every secret verb. During a flux reconcile storm (which happens
after every apiserver restart and every full reconcile) that measured **22.8 GB/day**, i.e. it would
have rotated the entire retention window every couple of hours and buried the useful records:
| verb | events/189 s | avg event | share |
| verb | events/189 s | avg event | burst rate |
|---|---|---|---|
| `list secrets` | 16 | **1.9 MiB** (every secret in the namespace) | 14 GB/day |
| `update secrets` | 90 | 170 KiB (flux `sh.helm.release.v1.*` blobs + prometheus-operator `tls-assets`) | 7 GB/day |
| `update secrets` | 90 | 170 KiB (flux `sh.helm.release.v1.*` + prometheus-operator `tls-assets`) | 7 GB/day |
| `get secrets` | 151 | 6.8 KiB | 1 GB/day |
Those two verbs are dominated by automation rewriting its own storage; the body is a copy of what
etcd already holds. They now record identity + namespace/name + status (Metadata), which is the
part that answers "who touched this secret". The single-object read path — the actual finding —
stays at `RequestResponse`. Total after the change: **~2.5 GB/day, ~1330 events/min**.
A `list` body is a corpus dump scaled by how many secrets the cluster holds — it grows with the
cluster, and the security signal ("who enumerated every secret") is fully captured by the metadata.
That verb pair (`list`, `watch`) is therefore Metadata. **Every other secret verb keeps full
request/response bodies**, including writes, so "who rewrote this secret and to what" is
reconstructable.
Steady state with this split is **0.79 GB/day, ~420 events/min** (secret traffic ~0.25 GB/day); the
storm burst is bounded and absorbed by rotation. Retention numbers below account for it.
## Sensitivity: the audit log is secret material
@ -104,7 +109,8 @@ pods/exec kubernetes-admin get forgejo/<pod>/exec code 101 full comma
```
`pods/exec` produces two records per session (`ResponseStarted`, `ResponseComplete`) — the first is
what makes an interactive session visible while it is still running.
what makes an interactive session visible while it is still running. Write-path fidelity re-checked
after the final policy revision: `create secret` (server dry-run) records `requestObject.data`.
## Drift: a `kubeadm upgrade` silently resets this
@ -141,8 +147,8 @@ file makes it remove the static pod and take the API down.
## Disk headroom
`siriussec` had 102 GiB free of 214 GiB when this landed. Retention is bounded at
`48 × 100 MiB = 4.8 GiB` raw before compression (realistic on-disk after gzip is a few hundred MB,
since most records are small metadata JSON), so the ≥32 GiB floor is never at risk from audit.
`48 × 100 MiB = 4.8 GiB` raw before compression, which at the measured 0.79 GB/day is **~6 days of
history**; realistic on-disk after gzip is several hundred MB. The ≥32 GiB floor is never at risk.
## Not covered here