- A
kubectl logs <pod> && kubectl describe pod <pod>
Why wrong: While non-invasive, these only provide high-level logs and metadata, not deep forensic data like binaries or configuration files.
- B
kubectl cp <pod>:/ -c <container> /tmp/forensic && kubectl logs <pod> --previous
Correct. Copying the entire container filesystem preserves evidence without altering the running container, and --previous logs capture the terminated container's output.
- C
kubectl exec <pod> -- cat /proc/1/cmdline && kubectl exec <pod> -- ls -la /
Why wrong: Executing commands changes the container's state, which is not forensically sound.
- D
kubectl exec -it <pod> -- bash && kubectl exec <pod> -- cat /var/log/syslog
Why wrong: Executing a shell inside the container modifies its state and may destroy evidence.
How to Preserve Forensic Evidence from a Kubernetes Container
This CKS practice question tests your understanding of monitoring, logging and runtime security. This is a configuration task: choose the command set that satisfies every stated requirement. Small differences — like 'secret' vs 'password' or 'transport input ssh' vs 'all' — change whether the answer is correct. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
You are investigating a pod suspected of being compromised. Which set of commands would provide the most useful forensic evidence without altering the container's state?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
kubectl cp <pod>:/ -c <container> /tmp/forensic && kubectl logs <pod> --previous
Option B is correct because it uses `kubectl cp` to create a static forensic copy of the entire container filesystem without executing any commands inside the container, thus avoiding altering the container's state (e.g., no new processes, no modified atime). Adding `kubectl logs --previous` retrieves logs from the terminated container, which are critical for investigating a compromised pod without interacting with the running container.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl logs <pod> && kubectl describe pod <pod>
Why it's wrong here
While non-invasive, these only provide high-level logs and metadata, not deep forensic data like binaries or configuration files.
- ✓
kubectl cp <pod>:/ -c <container> /tmp/forensic && kubectl logs <pod> --previous
Why this is correct
Correct. Copying the entire container filesystem preserves evidence without altering the running container, and --previous logs capture the terminated container's output.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
kubectl exec <pod> -- cat /proc/1/cmdline && kubectl exec <pod> -- ls -la /
Why it's wrong here
Executing commands changes the container's state, which is not forensically sound.
- ✗
kubectl exec -it <pod> -- bash && kubectl exec <pod> -- cat /var/log/syslog
Why it's wrong here
Executing a shell inside the container modifies its state and may destroy evidence.
Common exam traps
Common exam trap: answer the scenario, not the keyword
In the CKS exam, a common trap is believing that `kubectl exec` is acceptable for forensic collection because it 'just reads files.' However, any `exec` creates new processes and modifies the container's runtime state, violating the principle of non-interactive forensics. Only `kubectl cp` (and `kubectl logs --previous`) avoid altering the container's state.
Trap categories for this question
Command / output trap
Executing commands changes the container's state, which is not forensically sound.
Detailed technical explanation
How to think about this question
Under the hood, `kubectl cp` uses the Kubernetes API's tar stream to copy files from the container without executing a shell, leveraging the `kubectl exec` mechanism with a minimal tar binary but without interactive or persistent processes. In forensic investigations, the principle of 'least interaction' is critical: any `exec` command creates a new process (visible in /proc) and updates file access times, which can be used by attackers to detect investigation or alter evidence. Real-world scenarios often involve compromised containers where attackers monitor for unexpected processes or file access, making `kubectl cp` the only safe option for acquiring a disk image.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A practitioner preparing for the CKS exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Monitoring, Logging and Runtime Security — study guide chapter
Learn the concepts, then practise the questions
- →
Monitoring, Logging and Runtime Security practice questions
Targeted practice on this topic area only
- →
All CKS questions
997 questions across all exam domains
- →
Certified Kubernetes Security Specialist CKS study guide
Full concept coverage aligned to exam objectives
- →
CKS practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related CKS practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Monitoring Logging and Runtime Security practice questions
Practise CKS questions linked to Monitoring Logging and Runtime Security.
Cluster Setup and Hardening practice questions
Practise CKS questions linked to Cluster Setup and Hardening.
System Hardening practice questions
Practise CKS questions linked to System Hardening.
Minimize Microservice Vulnerabilities practice questions
Practise CKS questions linked to Minimize Microservice Vulnerabilities.
Supply Chain Security practice questions
Practise CKS questions linked to Supply Chain Security.
Monitoring, Logging and Runtime Security practice questions
Practise CKS questions linked to Monitoring, Logging and Runtime Security.
Cluster Setup practice questions
Practise CKS questions linked to Cluster Setup.
Cluster Hardening practice questions
Practise CKS questions linked to Cluster Hardening.
CKS fundamentals practice questions
Practise CKS questions linked to CKS fundamentals.
CKS scenario practice questions
Practise CKS questions linked to CKS scenario.
CKS troubleshooting practice questions
Practise CKS questions linked to CKS troubleshooting.
Practice this exam
Start a free CKS practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this CKS question test?
Monitoring, Logging and Runtime Security — This question tests Monitoring, Logging and Runtime Security — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: kubectl cp <pod>:/ -c <container> /tmp/forensic && kubectl logs <pod> --previous — Option B is correct because it uses `kubectl cp` to create a static forensic copy of the entire container filesystem without executing any commands inside the container, thus avoiding altering the container's state (e.g., no new processes, no modified atime). Adding `kubectl logs --previous` retrieves logs from the terminated container, which are critical for investigating a compromised pod without interacting with the running container.
What should I do if I get this CKS question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
6 more ways this is tested on CKS
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. You suspect a container has been compromised. You run 'kubectl exec -it <pod> -- bash' to investigate. Which of the following is the BEST next step to preserve evidence?
medium- ✓ A.Use 'kubectl cp' to copy files from the container to a secure location, and 'kubectl logs' to capture log output
- B.Install forensic tools inside the container using apt-get
- C.Run 'kubectl exec' to capture memory dumps
- D.Delete the pod and create a new one for analysis
Why A: Option A is correct because 'kubectl cp' allows you to extract files from the container without modifying the container's state, preserving the original evidence. 'kubectl logs' captures the container's stdout/stderr output, which is critical for forensic analysis. This approach avoids altering the container's filesystem or process state, which is essential for maintaining the integrity of the evidence.
Variation 2. You are investigating a pod that may have been compromised. Which kubectl command allows you to run a shell inside the running container without overwriting the container's filesystem?
medium- ✓ A.kubectl exec -it pod-name -- /bin/bash
- B.kubectl debug pod-name --image=busybox
- C.kubectl run -it --image=busybox sh
- D.kubectl attach pod-name
Why A: Option A is correct because `kubectl exec -it pod-name -- /bin/bash` attaches an interactive shell to the running container without modifying its filesystem. This command uses the container runtime's exec facility to spawn a new process inside the existing container, leaving the container's root filesystem unchanged. It is the standard method for runtime investigation without altering the container's state.
Variation 3. You suspect a container has been compromised. You want to preserve the container's filesystem for forensic analysis before terminating the pod. Which approach should you use?
medium- A.Exec into the container and delete suspicious files
- B.Restart the kubelet on the node
- ✓ C.Use kubectl cp to copy files from the container to a safe location
- D.Immediately delete the pod to stop the attack
Why C: To preserve evidence, you should not delete the pod immediately. Instead, use kubectl cp or a sidecar to copy files, or create a snapshot. But the simplest non-destructive step is to copy files from the container using 'kubectl cp' before deletion.
Variation 4. You suspect a container has been compromised and want to perform forensics using kubectl exec. Which command safely collects the container's process list without affecting the container?
medium- A.kubectl attach <pod>
- ✓ B.kubectl exec <pod> -- ps aux
- C.kubectl cp /proc <pod>:/tmp
- D.kubectl exec -it <pod> -- /bin/sh
Why B: kubectl exec with -- ps aux runs the ps command inside the container, capturing processes without altering the container state.
Variation 5. You need to preserve evidence (container logs) from a compromised pod before deleting it. Which command should you run first?
medium- A.kubectl exec <pod> -- cat /var/log/*
- B.kubectl cp <pod>:/var/log ./pod-logs
- ✓ C.kubectl logs <pod> --tail=-1 > pod.log
- D.kubectl delete pod <pod>
Why C: Option C is correct because `kubectl logs --tail=-1` retrieves the complete log history (all lines) from the container's stdout/stderr stream, which is the primary source of container logs in Kubernetes. Redirecting this output to a file preserves the evidence before the pod is deleted, ensuring the logs are not lost when the pod is removed.
Variation 6. You are investigating a pod that is suspected of being compromised. You need to preserve the container's filesystem for forensic analysis. Which `crictl` command should you use to export the container's filesystem as a tar archive?
medium- A.crictl logs <container-id>
- ✓ B.crictl export <container-id>
- C.crictl inspect <container-id>
- D.crictl exec <container-id> tar cvf /tmp/fs.tar /
Why B: Option B is correct because `crictl export` is the dedicated command to export a container's filesystem as a tar archive, preserving its state for forensic analysis. This command creates a snapshot of the container's root filesystem, which is essential for offline investigation without altering the running container.
Keep practising
More CKS practice questions
- Which flag is used to restrict the kubelet's ability to modify node status and pods?
- A Falco rule has priority `WARNING` and output: `Sensitive file opened (user=%user.name command=%proc.cmdline file=%fd.n…
- Falco detects a shell being opened inside a container. Which Falco rule field is used to specify the syscall condition f…
- A security audit reveals that a ServiceAccount named 'monitor' has a ClusterRoleBinding to the cluster-admin role. What…
- Match each Kubernetes security component to its description.
- Match each Kubernetes certificate type to its usage.
Last reviewed: Jul 4, 2026
This CKS practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKS exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.