audit(policy): drop bodies for secret reads, keep them for writes

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.
This commit is contained in:
Lance Walters 2026-11-27 00:49:13 -05:00
commit 09faa710c7
2 changed files with 60 additions and 33 deletions

View file

@ -46,13 +46,13 @@ 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** | corpus dumps only, see below |
| 4 | Metadata | `secrets` **get, list, watch** | reads: a corpus dump (`list`) or one live credential (`get`); objectRef is the whole signal, 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` (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 |
| 6 | **RequestResponse** | `secrets` **create/update/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. For secrets this is the **write** path only — the body is the tampering evidence |
| 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`/`watch` on secrets is Metadata and not RequestResponse
### Why secret reads are Metadata and secret writes are not
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
@ -66,19 +66,37 @@ have rotated the entire retention window every couple of hours and buried the us
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.
That verb pair (`list`, `watch`) was therefore the first to go Metadata.
`get` was the second half of the same problem, and it was not a volume issue. Measured on the live log
2026-11-27: of **3,527** secret events, **1,606** were `get` and **2,574** carried `.data` in
`responseObject` — the audit log was a second plaintext copy of every secret that had been read
(`kubernetes-admin`, `kustomize-controller`, `source-controller`, `sirius-growth:portal`, …). That copy
is root-only on the control-plane node, so reading it produces **no audit event**, which inverts the
purpose of the log. A `get` is fully described by `objectRef` + `user` + `sourceIPs` + `responseStatus`.
Secret **writes** are the opposite case and keep full `request`/`response` bodies: an attacker filling
a secret with their own SSH key or rewriting a `dockerconfigjson` is exactly the record you want, and a
write body is evidence rather than a credential that was already in the cluster. Verbs are enumerated
(`create/update/patch/delete/deletecollection`) so an unrecognised verb falls through to Metadata
instead of silently acquiring a body.
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
## Sensitivity: the audit log still holds secret material
At `RequestResponse`, a `get secret` audit event contains the secret's `data` in `responseObject`.
`/var/log/kubernetes/audit/` is therefore `0700 root` and the log `0600 root`, on the control-plane
node only. Treat any future log shipper as a **secrets pipeline**: no unauthenticated sink, no
plaintext off-node copy, and its own encryption/retention story. Nothing ships this log today.
Secret **reads** are Metadata since 2026-11-27, so a `get`/`list`/`watch` record carries no `data`.
Secret **writes** still do: at `RequestResponse` a `create`/`update`/`patch` record carries the object in
`requestObject` (and the server's answer in `responseObject`). `/var/log/kubernetes/audit/` therefore
stays `0700 root` with the log `0600 root`, on the control-plane node only.
Files written **before** that date also held every secret that had been *read*; they were deleted as part
of the change rather than left to age out (see "Purge" below). Treat any log shipper that touches this
path as a **secrets pipeline**: no unauthenticated sink, no plaintext off-node copy, and its own
encryption/retention story. The Loki/Alloy stack in `infrastructure/logging/` does **not** mount this
directory today (`/var/log/pods` + `/var/log/journal` only) — keep it that way unless the pipeline has an
encryption story.
## Verify it is live

View file

@ -7,14 +7,20 @@ omitStages:
# server-managed noise, never evidence
omitManagedFields: true
# Volume note (measured 2026-11-27 on this cluster): full bodies for EVERY secret
# 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. Only rule 2 gives up bodies, and only for list/watch, where the
# body is a corpus dump rather than evidence. Everything else - including secret
# writes - keeps full request/response. 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.
# 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
@ -64,14 +70,26 @@ rules:
- group: storage.k8s.io
resources: ["storageclasses"]
# ---------------------------- 2. secrets: bulk enumeration (corpus dumps only)
# A list returns EVERY secret in the namespace: measured 1.9 MiB per event, and a
# flux reconcile storm issues dozens. Identity + verb + namespace is the signal
# (mass enumeration); the body is just the corpus. Writes are NOT here - they stay
# at RequestResponse in rule 4, because "who rewrote this secret and to what" is
# evidence. Steady state with this split: ~0.25 GB/day of secret traffic.
# ---------------------- 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: ["list", "watch"]
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"]
@ -87,15 +105,6 @@ rules:
- group: certificates.k8s.io
resources: ["*"]
# --------------------- 4. secrets: single-object read/write, full bodies
# THIS FILE IS SECRET MATERIAL from here on: get/read responses and
# create/patch requests carry live secret values. 0600 root, never shipped
# off-node over an unauthenticated path.
- level: RequestResponse
resources:
- group: ""
resources: ["secrets"]
# -------------------------------- 5. everything privileged-but-authorized
- level: RequestResponse
resources: