CYART // SCHEMA · TOKEN-FLOW6 NODES · 6 LINKSVISIT1AUTH CODE + PKCE2CODE → TOKENS3BEARER ACCESS TOKEN4VERIFY SIGREFRESHACTOR · User — browserACTOR01UserbrowserSERVICE · Web app — BFF, httpOnly cookieSERVICE02Web appBFF, httpOnly cookieEDGE · Identity provider — login, MFA, consentEDGE03Identity providerlogin, MFA, consentSERVICE · Resource API — validates JWTSERVICE04Resource APIvalidates JWTDATA · JWKS — public keys, kid rotationDATA05JWKSpublic keys, kid rotationDATA · Refresh store — rotation + reuse detectionDATA06Refresh storerotation + reuse detection

Kubernetes audit log investigations

Investigate a cluster from the API server audit log: audit policy levels and stages, reading events by user, verb, objectRef and responseStatus, spotting exec into pods, privileged pod creation, service account token abuse and secrets access, then containing without losing evidence.

🔒 PROBy ·Lesson·19 min read·Intermediate → Advanced
Kubernetes audit logKubernetes securitykubectl execservice account tokencontainer securityincident response

01Audit policy: what the API server records

✓What you will learn
  • Write an audit policy and choose between None, Metadata, Request and RequestResponse
  • Read an audit event by user, verb, objectRef and responseStatus
  • Spot exec into pods, privileged pods, service account token abuse and secrets reads
  • Contain a cluster incident in an order that keeps evidence

Every action in Kubernetes, from kubectl get pods to a controller updating a Deployment, is a request to the kube-apiserver. The API server can write an audit event for each request, controlled by an audit policy: an ordered list of rules where the first match decides how much is recorded. Self-managed clusters enable it with --audit-policy-file and --audit-log-path; managed clusters expose it as a logging option.

LevelRecordsUse forCost
NoneNothingHealth checks, high-volume watches by system componentsBlind spot by design
MetadataUser, verb, resource, namespace, name, source IP, response codeSecrets and tokens (never log their bodies), default for everything elseLow
RequestMetadata + request bodyPod and workload creation, RBAC changes: shows the spec that was submittedMedium
RequestResponseMetadata + request and response bodiesNarrow, high-value writesHigh; can leak sensitive data into logs
An audit policy built for investigationsyaml
apiVersion: audit.k8s.io/v1
kind: Policy
omitStages: ["RequestReceived"]     # keep ResponseStarted/ResponseComplete only
rules:
  # 1. drop noise first: rules are evaluated top down, first match wins
  - level: None
    nonResourceURLs: ["/healthz*", "/livez*", "/readyz*", "/version"]
  - level: None
    users: ["system:kube-proxy"]
    verbs: ["watch"]
  # 2. secrets and tokens: who and when, never the values
  - level: Metadata
    resources:
      - group: ""
        resources: ["secrets", "configmaps", "serviceaccounts/token"]
  # 3. interactive access and workload creation: keep the request body
  - level: Request
    resources:
      - group: ""
        resources: ["pods", "pods/exec", "pods/attach", "pods/portforward", "pods/ephemeralcontainers"]
      - group: "apps"
        resources: ["deployments", "daemonsets", "statefulsets"]
    verbs: ["create", "update", "patch", "get"]
  # 4. RBAC changes: full detail
  - level: RequestResponse
    resources:
      - group: "rbac.authorization.k8s.io"
        resources: ["roles", "rolebindings", "clusterroles", "clusterrolebindings"]
    verbs: ["create", "update", "patch", "delete"]
  # 5. everything else
  - level: Metadata

Rule 3 includes get because newer kubectl versions open exec over a WebSocket, which arrives as an HTTP GET; older clients use a POST, recorded as create. Order matters: if the secrets rule came after a catch-all Request rule for the core group, secret values would land in your log pipeline.

PlatformHow to get audit logsWatch out for
Amazon EKSEnable the audit control-plane log type; lands in CloudWatch Logs /aws/eks/<cluster>/clusterOff by default; the policy is AWS-managed
Google GKECloud Audit Logs: Admin Activity always on; Data Access (get, list, watch) must be enabledWithout Data Access you will not see secret reads
Azure AKSDiagnostic settings: kube-audit or kube-audit-adminkube-audit-admin excludes get and list, so it misses secret reads
Self-managed--audit-policy-file, --audit-log-path, rotation flags, or a webhook backendLocal files on control-plane nodes rotate and can be tampered with

This is an advanced module

Investigations beyond Windows is part of the Pro pass. 3 more sections — the deep dives, the final design, follow-ups and the test — unlock with it.

Already a cyart.io or studio.cyart.io member? Your pass code is in your Studio account.