Skip to main content
Security & multi-tenancyLesson 9 of 13

Runtime security — catching abnormal behavior (CKS)

This covers the CKS Monitoring, Logging and Runtime Security (20%) domain and "kernel hardening tools such as AppArmor and seccomp" in System Hardening (10%). Even a container that passed every pre-deploy check can be breached at run time. We follow how to notice, block and investigate abnormal behavior inside a running container. Security standards applied at pod creation are in Pod Security Standards and securityContext, and audit policies in Audit Logs.

Falco alerts0
Blocked attempts0
Who did itunknown
Worker nodeAttackerstolen accountAPI serverrequest gatewaywebcontainerAudit logper-request recordLinux kernelsystem callsFalcoruns on each nodeAlert channelnotifications·logsSecurity teaminvestigatesexecopen shellrecord
RequestResponse / reportWatchAppears in a later step

What you will learn

  • Why every action in a container becomes a system call
  • Falco detects but does not block
  • Immutability enforced by a read-only root filesystem
  • What seccomp and AppArmor each block
  • Investigating with Falco alerts and audit logs together

Common exam questions​

SituationWhat to do / commandTrap
Find the container where a shell was openedCheck the rule name and container/pod names in Falco output, then replace that podFalco only alerts. You must clean up the pod yourself
Add or change a Falco ruleWrite it in a local rules file such as falco_rules.local.yaml, not the default rules fileEdits to the default rules file can be overwritten on upgrade
Container immutabilityreadOnlyRootFilesystem: true, with emptyDir only for paths that need writesApps that write temp files fail to start without a volume
Apply seccompsecurityContext.seccompProfile.type: RuntimeDefault or LocalhostA Localhost profile path is relative to the kubelet seccomp folder
Apply AppArmorLoad the profile on the node with apparmor_parser and name it in appArmorProfileA pod scheduled to a node without the profile cannot start
Who ran exec?Check the user on pods/exec requests in the audit logWithout a rule in the audit policy, nothing is recorded

Try it yourself​

kubectl logs -n falco -l app.kubernetes.io/name=falco -c falco # Falco alerts (Helm install)
kubectl get pod <pod> -o jsonpath='{.spec.securityContext}' # Pod-level seccomp/AppArmor
kubectl get pod <pod> -o jsonpath='{.spec.containers[*].securityContext}' # readOnlyRootFilesystem etc.
sudo aa-status | grep deny-shell # On the node: profile loaded?
sudo grep '"subresource":"exec"' /var/log/kubernetes/audit/audit.log # Who exec'd (path set by --audit-log-path)

Check yourself

  1. Falco fires Terminal shell in container for the web Pod. What happens to the shell?
  2. A Falco alert shows a shell was opened in Pod web. How do you find out who did it?
  3. You add an AppArmor Localhost profile to a Pod, and the Pod cannot start on some nodes. What is the most likely cause?

Further reading: CNCF certification curriculum · Falco docs · Restrict a container's syscalls with seccomp · Pod Security Standards and securityContext · Audit Logs