The audit policy should be configured to log key security events, such as pod creation, secret access, and RBAC changes.
apiVersion: rules.spotter.dev/v1alpha1
kind: SpotterRule
metadata:
name: spotter-audit-001
labels:
severity: "high"
category: "audit"
annotations:
rules.spotter.dev/title: "Audit Policy Not Cover Key Security Concerns"
rules.spotter.dev/version: "1.0.0"
rules.spotter.dev/cwe: "CWE-778"
rules.spotter.dev/description: "The audit policy should be configured to log key security events, such as pod creation, secret access, and RBAC changes."
spec:
match:
resources:
kubernetes:
apiGroups: ["audit.k8s.io"]
versions: ["v1"]
kinds: ["Policy"]
cel: |
object.kind == "Policy" &&
(
!has(object.rules) || size(object.rules) == 0 ||
!object.rules.exists(rule,
has(rule.resources) && rule.resources.exists(res,
has(res.resources) && (
res.resources.exists(r, r == "secrets") ||
res.resources.exists(r, r == "configmaps") ||
res.resources.exists(r, r == "tokenreviews")
)
)
) ||
!object.rules.exists(rule,
has(rule.resources) && rule.resources.exists(res,
has(res.resources) && (
res.resources.exists(r, r == "pods/exec") ||
res.resources.exists(r, r == "pods/portforward") ||
res.resources.exists(r, r == "pods/proxy") ||
res.resources.exists(r, r == "services/proxy")
)
)
)
)
remediation:
manual: "Review and update the audit policy file to ensure it logs important security events. This includes pod creation, secret access, and changes to RBAC roles and bindings."
references:
- title: "Kubernetes Auditing"
url: "https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/"