More Info:
The audit policy should cover access to Secrets, modification of Pod and Deployment objects, and use of exec/portforward/proxy subresources. This ensures key security events are captured.Risk Level
HighAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Locate and inspect the current audit policy
- On every control plane node, display the policy file:
- If the file is empty or missing, you must design and deploy an audit policy; capture that as a gap.
- On every control plane node, display the policy file:
-
Verify coverage of Secrets, ConfigMaps, and TokenReviews (metadata-only)
- In the displayed YAML, look for rules with
level: Metadata(or higher) that match at least these resources:secretsconfigmapstokenreviews(usuallygroup: authentication.k8s.io)
- Example patterns you should see in some rule(s):
- If
levelisRequestorRequestResponsefor these resources, assess the risk of sensitive data being logged and consider reducing toMetadatawhere possible.
- In the displayed YAML, look for rules with
-
Verify coverage of Pod and Deployment modifications
- In the same file, confirm there are rules that log at least
Metadatafor modifications (e.g.,verbs: ["create","update","patch","delete"]) on:pods(group"")deployments(groupapps)
- Example patterns you should see:
- If verbs are not restricted, ensure at minimum that modification verbs are covered; you may add or refine
verbsas needed for your risk tolerance.
- In the same file, confirm there are rules that log at least
-
Verify coverage of exec/portforward/proxy subresources
- Still in
/etc/kubernetes/audit-policy.yaml, ensure rules exist that log at leastMetadatafor these subresources:pods/execpods/portforwardpods/proxyservices/proxy
- Example patterns you should see:
- If missing, plan to add such rules; if
levelis lower than desired, consider raising toMetadataor higher per your logging policy.
- Still in
-
Edit and apply changes, noting operational impact
- On every control plane node, edit the policy file with your preferred editor, adding or adjusting rules as identified in steps 2–4:
- Confirm the API server is actually using this file (and where it is referenced) by checking its manifest (static pod):
- If necessary, adjust the
--audit-policy-file=/etc/kubernetes/audit-policy.yamlflag path to match your file location. - Any change to
/etc/kubernetes/manifests/kube-apiserver.yamlor the audit policy file will cause the kube-apiserver static pod to restart on that control plane node.
- On every control plane node, edit the policy file with your preferred editor, adding or adjusting rules as identified in steps 2–4:
-
Verify the policy is active and producing expected logs
- On every control plane node, confirm the kube-apiserver pod has restarted recently (after your changes):
- Generate a test event (for example, reading a Secret and using
kubectl exec) from any machine with kubectl access: - On the control plane node where audit logs are written, inspect the audit log (path may vary; common example):
- Verify that the generated events appear at the expected log
level(e.g.,Metadata) and that sensitive Secret data is not logged in full. Adjust the policy and repeat as necessary.
- On every control plane node, confirm the kube-apiserver pod has restarted recently (after your changes):
Using kubectl
Using kubectl
kubectl cannot modify the audit policy file
/etc/kubernetes/audit-policy.yaml or any other host-level control plane configuration; these changes must be made directly on every control plane node. Refer to the Manual Steps section for guidance on reviewing and updating the audit policy on the nodes themselves.Automation
Automation
How to run
- Save the script as
check-audit-policy-key-events.sh. - Edit the
CONTROL_PLANE_NODESarray to list all your control plane node hostnames or IPs. - Make it executable:
- Run from any machine that can SSH to all control plane nodes:
Interpreting the output
Outputs that indicate a problem and require manual review/adjustment of/etc/kubernetes/audit-policy.yaml on the affected control plane node include:-
[PROBLEM] Policy file not found at /etc/kubernetes/audit-policy.yaml
→ No audit policy configured at the expected path. -
[PROBLEM] No rule mentioning secrets/configmaps/tokenreviews resources
→ Access to these sensitive resources may not be logged at all. -
[PROBLEM] Rule with level RequestBody/RequestResponse applies to secrets/configmaps/tokenreviews
→ Audit may be logging sensitive data content instead of metadata only. -
No lines starting with
[INFO] Pod/Deployment modification rule:
→ Modifications to Pods/Deployments may not be distinctly logged. -
[PROBLEM] No rule mentioning pods/exec|pods/portforward|pods/proxy|services/proxy
→ Use of these subresources may not be logged. -
In the summary:
[PROBLEM] Missing any rule referencing secrets[PROBLEM] Missing any rule referencing pods[PROBLEM] Missing rules for exec/portforward/proxy subresources
→ Key security concerns are not covered and the policy should be revised manually.

