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:
parent
a8534bae42
commit
09faa710c7
2 changed files with 60 additions and 33 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue