audit(policy): drop bodies for secret reads, keep them for writes #60
Loading…
Reference in a new issue
No description provided.
Delete branch "t_d1275a3a-secret-read-metadata"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
t_104f62a6shipped audit logging; it works, but rule 4 recorded full bodies for single-object secretreads, so
/var/log/kubernetes/audit/audit.logbecame a second plaintext copy of every secret that hadbeen read. Measured on the live log (both files, 38,897 events):
The file is 0600 root on the control-plane node, so reading it produces no audit event — the log
undermines its own purpose. A
getis fully described byobjectRef+user+sourceIPs+responseStatus.What changed
infrastructure/controlplane/audit/audit-policy.yaml— one rule split, nothing else touched:secretsget, list, watch →Metadatasecrets(all verbs) →RequestResponsesecretscreate, update, patch, delete, deletecollection →RequestResponseWrite bodies are kept on purpose: filling a secret with an attacker's own key (or rewriting
forgejo-pull) is the evidence you want, and a write body is not a credential that already existed inthe cluster. Verbs are enumerated so an unknown verb falls through to
Metadatarather than silentlygaining a body.
pods/exec,tokenreviews,serviceaccounts/token, RBAC/cert writes,impersonateand the proxies are untouched.
docs/kube-apiserver-audit-logging.md: rule table, read/write rationale with the measured numbers,sensitivity section (the Loki/Alloy stack does not mount this directory) and a purge note.
Verified live on siriussec
Policy installed with the repo's
install-audit.shand the apiserver restarted to reload it:get secretrecord:level: Metadata,objectRef+user+responseStatus, nodataanywhere in the event;patchon a throwaway secret:RequestResponse,requestObject.datapresent, secretthen deleted;
audit.logrestarted at the change;ready=true, all Flux KustomizationsReady=Trueat the merge sha.No change to retention (
100 MiB × 48, 7 days), no rule weakened, manifest not hand-edited.