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

Merged
sirius merged 1 commit from t_d1275a3a-secret-read-metadata into master 2026-11-27 05:49:32 +00:00
Owner

Why

t_104f62a6 shipped audit logging; it works, but rule 4 recorded full bodies for single-object secret
reads, so /var/log/kubernetes/audit/audit.log became a second plaintext copy of every secret that had
been read. Measured on the live log (both files, 38,897 events):

secret events:                        3527   (get 1606, patch 899, watch 721, update 196, delete 49, list 43, create 13)
levels:                               RequestResponse 2846, Metadata 681
with responseObject:                  2753
with responseObject .data:            2574   <-- the secret values
readers:                              kubernetes-admin, kustomize-controller (1731), source-controller,
                                      kube-prometheus-stack-grafana, sirius-growth:portal, ...

The file is 0600 root on the control-plane node, so reading it produces no audit event — the log
undermines its own purpose. A get is fully described by objectRef + user + sourceIPs +
responseStatus.

What changed

infrastructure/controlplane/audit/audit-policy.yaml — one rule split, nothing else touched:

before after
rule 4a — secrets get, list, watch → Metadata
rule 4b secrets (all verbs) → RequestResponse secrets create, update, patch, delete, deletecollection → RequestResponse

Write 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 in
the cluster. Verbs are enumerated so an unknown verb falls through to Metadata rather than silently
gaining a body. pods/exec, tokenreviews, serviceaccounts/token, RBAC/cert writes, impersonate
and 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.sh and the apiserver restarted to reload it:

  • post-change get secret record: level: Metadata, objectRef + user + responseStatus, no
    data anywhere in the event;
  • post-change patch on a throwaway secret: RequestResponse, requestObject.data present, secret
    then deleted;
  • pre-change rotated files (which held the read bodies) deleted; audit.log restarted at the change;
  • apiserver ready=true, all Flux Kustomizations Ready=True at the merge sha.

No change to retention (100 MiB × 48, 7 days), no rule weakened, manifest not hand-edited.

## Why `t_104f62a6` shipped audit logging; it works, but rule 4 recorded full bodies for single-object secret reads, so `/var/log/kubernetes/audit/audit.log` became a second plaintext copy of every secret that had been read. Measured on the live log (both files, 38,897 events): ``` secret events: 3527 (get 1606, patch 899, watch 721, update 196, delete 49, list 43, create 13) levels: RequestResponse 2846, Metadata 681 with responseObject: 2753 with responseObject .data: 2574 <-- the secret values readers: kubernetes-admin, kustomize-controller (1731), source-controller, kube-prometheus-stack-grafana, sirius-growth:portal, ... ``` The file is 0600 root on the control-plane node, so reading it produces **no audit event** — the log undermines its own purpose. A `get` is fully described by `objectRef` + `user` + `sourceIPs` + `responseStatus`. ## What changed `infrastructure/controlplane/audit/audit-policy.yaml` — one rule split, nothing else touched: | | before | after | |---|---|---| | rule 4a | — | `secrets` **get, list, watch** → `Metadata` | | rule 4b | `secrets` (all verbs) → `RequestResponse` | `secrets` **create, update, patch, delete, deletecollection** → `RequestResponse` | Write 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 in the cluster. Verbs are enumerated so an unknown verb falls through to `Metadata` rather than silently gaining a body. `pods/exec`, `tokenreviews`, `serviceaccounts/token`, RBAC/cert writes, `impersonate` and 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.sh` and the apiserver restarted to reload it: - post-change `get secret` record: `level: Metadata`, `objectRef` + `user` + `responseStatus`, **no** `data` anywhere in the event; - post-change `patch` on a throwaway secret: `RequestResponse`, `requestObject.data` present, secret then deleted; - pre-change rotated files (which held the read bodies) deleted; `audit.log` restarted at the change; - apiserver `ready=true`, all Flux Kustomizations `Ready=True` at the merge sha. No change to retention (`100 MiB × 48`, 7 days), no rule weakened, manifest not hand-edited.
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.
sirius merged commit 9f07d3330c into master 2026-11-27 05:49:32 +00:00
sirius deleted branch t_d1275a3a-secret-read-metadata 2026-11-27 05:49:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!60
No description provided.