Practice Questions: Monitoring, Logging and Runtime Security
Practice Environment
These questions are designed for a Kind cluster or any local Kubernetes environment. Some questions require Falco to be installed on the node. Where node-level access is needed, instructions assume you can SSH into the node or use docker exec for Kind clusters.
Time Target: Aim to complete all 20 questions within 90 minutes to simulate exam pressure.
Question 1: Basic Audit Policy Creation
Difficulty: Easy
Scenario: Your cluster does not have audit logging enabled. The security team requires audit logging to track all API activity.
Task:
- Create an audit policy file at
/etc/kubernetes/audit/policy.yamlthat:- Logs all Secret operations at the
Metadatalevel - Logs all namespace create and delete operations at the
RequestResponselevel - Logs everything else at the
Metadatalevel - Does not log
RequestReceivedstage events
- Logs all Secret operations at the
- The audit policy should be syntactically correct with the proper
apiVersionandkind.
Question 2: Enable Audit Logging on API Server
Difficulty: Medium
Scenario: An audit policy has been created at /etc/kubernetes/audit/policy.yaml. You need to configure the API server to use it.
Task:
- Configure the kube-apiserver to enable audit logging using the policy file at
/etc/kubernetes/audit/policy.yaml - Audit logs should be written to
/var/log/kubernetes/audit/audit.log - Set maximum log age to 30 days, maximum backup count to 5, and maximum log size to 100MB
- Ensure all required volume mounts and volumes are configured
- Verify the API server restarts successfully and audit events are being logged
Question 3: Advanced Audit Policy
Difficulty: Hard
Scenario: The security team needs a more granular audit policy. They want to minimize log volume while capturing security-relevant events.
Task: Create an audit policy file at /etc/kubernetes/audit/policy-advanced.yaml that:
- Does NOT log
get,list, orwatchoperations on endpoints or services - Does NOT log any requests to non-resource URLs like
/api*,/healthz*,/version - Logs all Secret operations at the
Metadatalevel (never log Secret contents) - Logs all RBAC resource modifications (create, update, patch, delete) at
RequestResponselevel - Logs
pods/exec,pods/attach, andpods/portforwardatMetadatalevel - Logs all other events at
Metadatalevel - Omits the
RequestReceivedstage globally
Question 4: Audit Log Investigation
Difficulty: Medium
Scenario: The file /var/log/kubernetes/audit/audit.log contains audit events. A Deployment named webapp in the production namespace was recently deleted, and you need to find out who did it.
Task:
- Write a
jqcommand to filter the audit log and find who deleted the Deployment namedwebappin theproductionnamespace - Record the username, source IP, and timestamp of the deletion event
- Save the filtered output to
/tmp/investigation/deletion-event.json
Question 5: Write a Falco Rule for Shell Detection
Difficulty: Easy
Scenario: The security team wants Falco to detect when an interactive shell is spawned inside any container.
Task:
- Create a Falco rule in
/etc/falco/falco_rules.local.yamlthat:- Has the name
Detect Shell in Container - Detects when
bash,sh,dash, orzshis spawned in a container - Outputs the user name, shell name, container name, pod name, namespace, and command line
- Has priority
WARNING - Is tagged with
shellandcontainer
- Has the name
- Validate the rule file
- Restart Falco
Question 6: Falco Rule for Sensitive File Access
Difficulty: Medium
Scenario: Falco is running on the cluster nodes. You need to create a custom rule to detect when any process inside a container reads /etc/shadow.
Task:
- Add a Falco rule to
/etc/falco/falco_rules.local.yamlthat:- Has the name
Shadow File Read in Container - Detects reads of
/etc/shadowinside containers - Outputs the process name, user, container name, pod name, namespace, and image
- Has priority
ERROR
- Has the name
- Test the rule by exec-ing into a container and running
cat /etc/shadow - Verify the Falco alert is generated
Question 7: Falco Rule for Package Manager Detection
Difficulty: Medium
Scenario: Container immutability is a security requirement. You need to detect any attempt to install packages inside running containers.
Task:
- Create a Falco rule file at
/etc/falco/rules.d/package-manager.yamlwith:- A list named
package_mgr_binariescontaining:apt,apt-get,dpkg,yum,rpm,pip,pip3,npm,apk - A rule named
Package Manager Launched in Containerthat detects execution of any package manager process inside a container - Priority
CRITICAL - Output should include the package manager name, command line, container name, pod name, and namespace
- A list named
- Restart Falco and verify the rule is loaded
Question 8: Investigate Falco Alerts
Difficulty: Medium
Scenario: Falco has been generating alerts about a pod named web-app in the default namespace. The alerts indicate that a shell has been spawned in the container.
Task:
- Check the Falco alerts from the last hour
- Identify the specific container and process that triggered the alert
- Investigate the pod and determine what processes are running
- Check if any files have been modified in the container's
/tmpdirectory - Record your findings in
/tmp/investigation/falco-findings.txt
Question 9: Container Immutability - Fix a Pod
Difficulty: Easy
Scenario: A pod named mutable-app is running in the default namespace without readOnlyRootFilesystem. This violates the security policy.
Task:
- Delete the existing
mutable-apppod - Recreate it with the same image and configuration but with:
readOnlyRootFilesystem: true- An
emptyDirvolume mounted at/tmp - An
emptyDirvolume mounted at/var/cache
- Verify the pod is running successfully
Question 10: Container Immutability - Nginx
Difficulty: Medium
Scenario: Deploy an Nginx pod that enforces container immutability while remaining fully functional.
Task:
- Create a pod named
immutable-nginxin thedefaultnamespace with:- Image:
nginx:1.25 readOnlyRootFilesystem: true- All necessary writable directories provided via
emptyDirvolumes (nginx needs/tmp,/var/run,/var/cache/nginx,/var/log/nginx) allowPrivilegeEscalation: false
- Image:
- Verify the pod is running and Nginx is serving on port 80
- Verify that writing to the root filesystem (e.g.,
/usr/share/nginx/html/test.html) fails
Question 11: Forensic Investigation - Suspicious Container
Difficulty: Hard
Scenario: A container named suspicious-app in the investigation namespace is suspected of being compromised. You need to investigate without alerting the attacker.
Task:
- Create the
investigationnamespace and deploy a pod namedsuspicious-appusingnginx:1.25 - Simulate compromise: exec into the pod and run:
apt-get update && apt-get install -y curlcurl -o /tmp/payload http://example.comecho "malicious" > /tmp/backdoor.sh
- Now investigate from the host:
- Find the container ID using
crictl - Find the host PID of the container
- List processes running inside the container
- Check what files exist in
/tmpinside the container - Record your investigation results in
/tmp/investigation/forensics-report.txt
- Find the container ID using
Question 12: Audit Log Analysis - Secret Access
Difficulty: Medium
Scenario: You suspect that someone has been accessing Secrets they should not have access to. Audit logging is enabled.
Task:
- Write commands to find all audit log entries where:
- The resource type is
secrets - The verb is
getorlist - Group the results by username
- The resource type is
- Identify any users or service accounts that accessed secrets in namespaces other than their own
- Save the analysis to
/tmp/investigation/secret-access.txt
Question 13: Behavioral Analytics - Detect Lateral Movement
Difficulty: Hard
Scenario: You need to set up detection for lateral movement attempts in your cluster.
Task:
- Create a Falco rule in
/etc/falco/rules.d/lateral-movement.yamlthat detects:- Any container reading the service account token file (
/var/run/secrets/kubernetes.io/serviceaccount/token) - With priority
WARNING - Output includes process name, command, container name, pod name, namespace
- Any container reading the service account token file (
- Create another rule that detects:
- Network scanning tools (
nmap,masscan,nc,ncat,netcat) being executed in a container - With priority
CRITICAL - Output includes the tool name, command line, container name, pod name, namespace
- Network scanning tools (
- Restart Falco and verify both rules are loaded
Question 14: Combined - Audit Policy and Investigation
Difficulty: Hard
Scenario: A security incident occurred. You need to set up audit logging and investigate.
Task:
- Create an audit policy at
/etc/kubernetes/audit/incident-policy.yamlthat:- Logs all
pods/execoperations atRequestResponselevel - Logs all Secret operations at
Metadatalevel - Logs all RBAC changes at
RequestResponselevel - Logs everything else at
Metadatalevel
- Logs all
- Configure the API server to use this policy (logs to
/var/log/kubernetes/audit/incident.log) - After the API server restarts, perform these actions:
- Create a Secret named
test-secretin thedefaultnamespace - Exec into a running pod
- Create a Secret named
- Verify these actions appear in the audit log
Question 15: Immutability Enforcement with Pod Security Standards
Difficulty: Medium
Scenario: You need to enforce security standards on a namespace to ensure all pods meet minimum security requirements.
Task:
- Create a namespace named
restricted-ns - Apply the
restrictedPod Security Standard inenforcemode - Attempt to create a pod without security context -- verify it is rejected
- Create a pod that meets the
restrictedstandard with:readOnlyRootFilesystem: truerunAsNonRoot: truerunAsUser: 1000allowPrivilegeEscalation: falsecapabilities: drop: [ALL]seccompProfile: type: RuntimeDefault- Appropriate
emptyDirvolumes
- Verify the pod runs successfully
Question 16: Falco - Modify Output Format
Difficulty: Easy
Scenario: The security team wants Falco alerts to be output in JSON format to a specific file.
Task:
- Modify
/etc/falco/falco.yamlto:- Enable JSON output
- Enable file output to
/var/log/falco/alerts.json - Keep stdout output enabled
- Restart Falco
- Trigger an alert (exec into a container)
- Verify the alert appears in JSON format in the output file
Question 17: Forensic Investigation - Network Analysis
Difficulty: Hard
Scenario: A pod named network-suspect in the default namespace is suspected of making unauthorized outbound connections.
Task:
- Create a pod
network-suspectusingnginx:1.25 - Simulate suspicious activity: exec into the pod and run
curl http://example.com - From the host, investigate:
- Find the container's host PID
- Check active network connections
- Check listening ports
- Check the processes that have network activity
- Create a NetworkPolicy that isolates this pod (deny all ingress and egress)
- Verify the pod can no longer make outbound connections
Question 18: sysdig Investigation
Difficulty: Medium
Scenario: You need to use sysdig to monitor system calls made by a specific container.
Task:
- Create a pod named
monitored-appin thedefaultnamespace usingnginx:1.25 - Use sysdig to:
- Monitor all file open events in the
monitored-appcontainer - Monitor all process execution events in the
monitored-appcontainer - Monitor all network connection events in the
monitored-appcontainer
- Monitor all file open events in the
- Write the sysdig commands that would produce each of these outputs
- Save the commands to
/tmp/investigation/sysdig-commands.txt
Question 19: Combined - Full Incident Response
Difficulty: Hard
Scenario: You receive a Falco alert indicating that a shell was spawned in a container in the production namespace. You need to perform a complete incident response.
Task:
- Create the
productionnamespace with a pod namedapp-serverusingnginx:1.25 - Simulate the compromise: exec into the pod, create a file
/tmp/malware.sh, and installcurl - Perform incident response:
- Collect evidence: pod logs, pod spec, running processes, filesystem changes
- Save all evidence to
/tmp/evidence/ - Create a NetworkPolicy to isolate the pod
- Document the timeline of events
- Remediate:
- Delete the compromised pod
- Recreate it with immutable settings (
readOnlyRootFilesystem: true) - Verify the remediated pod is running
Question 20: Comprehensive Security Monitoring Setup
Difficulty: Hard
Scenario: You need to set up a comprehensive security monitoring configuration for a new cluster.
Task:
- Create an audit policy at
/etc/kubernetes/audit/comprehensive-policy.yamlthat:- Does not log
get/list/watchon endpoints and services - Does not log kube-proxy watch requests
- Does not log requests to
/healthz*,/readyz*,/livez* - Logs Secrets at
Metadatalevel - Logs RBAC changes at
RequestResponselevel - Logs
pods/execandpods/portforwardatRequestlevel - Logs all other events at
Metadatalevel
- Does not log
- Create a Falco rules file at
/etc/falco/rules.d/comprehensive.yamlwith rules to detect:- Shell spawning in containers (WARNING)
- Package manager execution in containers (ERROR)
- Sensitive file reads (
/etc/shadow,/etc/passwd) in containers (WARNING) - Write operations to
/etcin containers (ERROR)
- Configure the API server to use the audit policy
- Restart Falco to load the new rules
- Verify both audit logging and Falco are operational