CKS Minimize Microservice Vulnerabilities Practice Question
Which THREE of the following are recommended practices for minimizing microservice vulnerabilities related to container security?
⚠ Common exam trap
Kubernetes CKS exams often test the misconception that resource limits (CPU/memory) are security controls, but they are only for resource isolation and DoS prevention, not for mitigating container escape or privilege escalation vulnerabilities.
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
✓
Set securityContext.runAsNonRoot: true
Setting `securityContext.runAsNonRoot: true` forces the container to run with a user ID (UID) other than 0 (root). This is a critical defense-in-depth measure because if an attacker exploits a vulnerability in the application or runtime, they will not gain root privileges on the host, limiting the blast radius. It enforces the principle of least privilege at the container level, and Kubernetes will reject the pod if the container image attempts to run as root.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Set securityContext.runAsNonRoot: true
Why this is correct
Setting securityContext.runAsNonRoot: true forces Kubernetes to reject the container if the image runs as UID 0, ensuring the process executes with a non-root user ID. This prevents an attacker from obtaining root privileges inside the container after exploiting a vulnerability, which massively reduces the ability to modify system files, install tooling, or leverage kernel-level privilege escalation. It also helps satisfy Pod Security Standards restricted profile requirements.
- ✓
Drop all capabilities via securityContext.capabilities.drop: ["ALL"]
Why this is correct
Linux capabilities are discrete privileges that root normally has; by dropping ALL with capabilities.drop: ["ALL"], the container is left with no capabilities, such as CAP_NET_BIND_SERVICE, CAP_KILL, or CAP_CHOWN. This follows the principle of least privilege: even if the container's user is compromised, the kernel refuses any privileged syscall like mount, raw socket use, or ptrace. Because capabilities are tied to the process's effective credentials, this control works independently of runAsNonRoot, preventing privilege escalation via retained capabilities.
- ✗
Set high CPU requests to ensure performance
Why it's wrong here
CPU requests are a scheduling and resource QoS mechanism, not a security boundary. They only indicate to the Kubernetes scheduler how much node capacity the pod requires, affecting placement and eviction; they do nothing to restrict syscalls, filesystem access, or network behavior. Setting high CPU requests may actually worsen security by exhausting node resources and enabling denial-of-service against co-located workloads, while real hardening requires seccomp, AppArmor, and securityContext fields.
- ✓
Set securityContext.readOnlyRootFilesystem: true
Why this is correct
Configuring securityContext.readOnlyRootFilesystem: true mounts the container's root filesystem as read-only, so even a fully compromised process cannot overwrite system binaries, libraries, or configuration files. Writes are only possible on explicitly mounted emptyDir or other writable volumes, encouraging a design where application state is externalized and /tmp is the only writable path. This makes it significantly harder for an attacker to persist backdoors or tamper with the container's execution environment, since any modification requires rebooting the pod.
- ✗
Expose secrets as environment variables for convenience
Why it's wrong here
Putting secrets in environment variables is a serious anti-pattern because environment variables are inherited by all child processes, visible in /proc/1/environ, and often get logged by applications or debugging tools. The secret data is only base64-encoded, not encrypted, so it can be easily decoded by anyone who can read the pod definition or process environment. Kubernetes mounted Secrets are safer because they are exposed as files with permissions, use tmpfs, and allow rotation through file updates rather than container recreation.
Quick reference
AAA Protocol Comparison
| Protocol | Port(s) | Encryption | Transport | Primary Use |
|---|---|---|---|---|
| RADIUS | 1812 / 1813 | Password only | UDP | Network access control |
| TACACS+ | 49 | Full packet | TCP | Device administration |
| Diameter | 3868 | Full session | TCP / SCTP | Carrier / mobile networks |
| 802.1X | — | EAP-based | Layer 2 | Port-based access control |
TACACS+ encrypts the entire packet; RADIUS only encrypts the password field — a key exam distinction.
Go deeper
Related to this question
About these practice questions
One of 845 original CKS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.