Courseiva

Certified Kubernetes Security Specialist CKS (CKS) — Questions 376–450

845 questions total · 12pages · All types, answers revealed

Page 5

Page 6 of 12

Page 7
376
Multi-Selecthard

Which THREE of the following are recommended incident response steps when a container is compromised?

Select 3 answers
A.Ignore the incident and monitor for further activity
B.Copy the container's filesystem using kubectl cp for offline analysis
C.Capture the container logs using kubectl logs
D.Apply a NetworkPolicy to isolate the pod
E.Immediately terminate the pod to contain the threat
AnswersB, C, D

Using `kubectl cp` to copy the container’s filesystem is a forensically sound step because it preserves the writable layer, arbitrary files, and binaries without altering the running state. This offline copy lets you analyze the image, look for persistence mechanisms (e.g., cron jobs, backdoors), and inspect configuration files while the container remains responsive. Because `kubectl cp` reads the live filesystem, it is non-destructive and is a best practice before any termination decision. It also gives you a baseline for detecting changes if you later compare with the original image.

Why this answer

Option B is correct because copying the container's filesystem with kubectl cp preserves volatile evidence for offline forensic analysis before the container is destroyed or restarted. Option C is correct because kubectl logs captures the container's stdout/stderr output, which may contain indicators of compromise, attacker commands, or error traces useful for scoping the incident. Option D is correct because applying a NetworkPolicy to the pod isolates it from other workloads, limiting lateral movement and exfiltration while still keeping the container alive for investigation.

Option A is wrong because ignoring a compromise allows the attacker to persist and expand access. Option E is wrong because immediately terminating the pod destroys volatile evidence such as memory, running processes, and network connections, and may trigger automated redeployment that erases the compromised instance before it can be examined.

Exam trap

The trap is choosing to immediately terminate the pod as a containment step, but that destroys evidence; the correct approach is to isolate and preserve first.

377
MCQeasy

Which of the following is a valid way to check the status of AppArmor profiles on a node?

A.Use 'apparmor_parser --status'
B.Run 'kubectl get apparmorprofiles'
C.Read the file /sys/kernel/security/apparmor/profiles
D.Run 'aa-status' on the node
AnswerD

aa-status is the canonical utility from the apparmor-utils package for checking AppArmor status on a node. It reads the AppArmor security filesystem under /sys/kernel/security/apparmor/ to display loaded profiles, their enforcement mode (enforce or complain), and which processes are confined. Running aa-status on the node gives an administrator the exact, current state of the AppArmor subsystem, making it the correct and most direct verification method.

Why this answer

`aa-status` is the standard command-line tool for checking the status of AppArmor profiles on a Linux node. It displays which profiles are loaded, which processes are confined, and the enforcement mode (enforce/complain). This is the direct, node-level utility for AppArmor status verification.

Exam trap

The trap here is that candidates may confuse Kubernetes-native resources (like `kubectl get`) with node-level security tools, or assume that reading a kernel file is equivalent to using the dedicated status command, but the exam expects familiarity with the standard Linux administration command `aa-status` for AppArmor.

How to eliminate wrong answers

Option A is wrong because `apparmor_parser` is used to load or unload AppArmor profiles into the kernel, not to check their status; the `--status` flag does not exist for this command. Option B is wrong because `kubectl get apparmorprofiles` is not a valid Kubernetes API resource; AppArmor profiles are managed at the node level, not via Kubernetes objects. Option C is wrong because while `/sys/kernel/security/apparmor/profiles` lists loaded profiles, it is a raw kernel interface that requires parsing and does not provide a human-readable status summary like `aa-status` does.

378
MCQhard

During a security incident, you need to isolate a compromised pod named 'malicious-pod' in namespace 'default' to prevent it from communicating with other pods. Which command should you run?

A.kubectl run networkpolicy --image=nginx --restart=Never
B.kubectl delete pod malicious-pod
C.kubectl apply -f networkpolicy.yaml
D.kubectl create networkpolicy isolate --pod-selector=app=malicious --policy-types=Ingress,Egress
AnswerC

Applying a NetworkPolicy YAML is the correct method because this API resource is designed to select pods by label and restrict their ingress and egress traffic. A properly written manifest with a podSelector matching 'app=malicious' and policyTypes: [Ingress, Egress] but no ingress/egress rules creates a default-deny rule for that pod, blocking all inbound and outbound connections non-destructively. kubectl apply is also idempotent and the only reliable way to declare such a policy, since kubectl does not offer a native 'create networkpolicy' command.

Why this answer

Pod isolation is achieved by applying a NetworkPolicy that denies ingress/egress traffic. 'kubectl apply -f networkpolicy.yaml' applies the policy. The policy must be written to deny all traffic.

379
Multi-Selecteasy

Which TWO of the following flags are used to secure the kubelet?

Select 2 answers
A.--protect-kernel-defaults
B.--anonymous-auth=false
C.--enable-admission-plugins
D.--audit-log-path
E.--authorization-mode=RBAC
AnswersA, B

--protect-kernel-defaults is a kubelet flag that enforces kernel hardening by refusing to apply sysctls that would alter sensitive kernel parameters like net.ipv4.tcp_syncookies or kernel.shmmax. It ensures the node's kernel stays in a secure default state, and the kubelet will fail to start or reject pod updates if a disallowed sysctl is requested. This is a key control for reducing the attack surface on worker nodes, especially in multi-tenant clusters.

Why this answer

The `--protect-kernel-defaults` flag is used to secure the kubelet by ensuring that kernel tunable parameters (e.g., `vm.overcommit_memory`, `kernel.panic`) are set to safe values. If the kernel defaults are not properly configured, the kubelet will fail to start, preventing insecure kernel settings from being used. This flag is part of the kubelet's security hardening measures, as recommended by the CIS Kubernetes Benchmark.

Exam trap

CNCF often tests the distinction between kubelet flags and API server flags, so the trap here is that candidates may confuse `--authorization-mode=RBAC` or `--audit-log-path` as kubelet security settings when they are actually API server parameters.

380
MCQmedium

A security admin wants to ensure all pods in a cluster drop ALL Linux capabilities. Which of the following YAML snippets should be added to a PodSecurityPolicy (assuming PSP is enabled) or a pod spec?

A.capabilities: drop: "ALL"
B.capabilities: drop: - "NET_RAW"
C.capabilities: add: ["ALL"]
D.capabilities: drop: ["ALL"]
AnswerD

Setting `capabilities.drop: ["ALL"]` inside the `securityContext` removes every Linux capability from the container's capability sets, leaving the process with no capabilities beyond those required for basic operation. This is a security best practice because it prevents many privilege-escalation attacks, including those that abuse a setuid binary or a capability retained by the runtime. The list form is mandatory; Kubernetes validates `drop` as an array of capability names, and `ALL` is the wildcard that clears the entire default set.

Why this answer

Dropping all Linux capabilities from a container is achieved by specifying `drop: ["ALL"]` in the PodSecurityPolicy or pod security context. This ensures the container runs with no capabilities, following the principle of least privilege. The correct syntax uses a YAML list (array) for the `drop` field, not a string.

Exam trap

The trap here is that candidates confuse the YAML syntax for dropping capabilities (must be a list) with a string value, or they think dropping a single capability like NET_RAW is sufficient to remove all capabilities. Also, note that PodSecurityPolicy is deprecated in Kubernetes 1.21 and removed in 1.25, so for newer clusters, use Pod Security Admission or a pod security context.

How to eliminate wrong answers

Option A is wrong because `drop: "ALL"` uses a string value instead of a list, which is invalid YAML syntax for the capabilities field; the Kubernetes API expects an array of strings. Option B is wrong because it only drops the `NET_RAW` capability, not all capabilities, leaving the container with other potentially dangerous capabilities. Option C is wrong because `add: ["ALL"]` adds all capabilities, which is the opposite of what the security admin wants and would grant maximum privileges.

381
MCQmedium

A pod is running in a namespace that has a Kyverno policy requiring all images to come from a trusted registry. The pod is using an image from an untrusted registry. What will happen when the pod is created?

A.The pod will be created but immediately terminated
B.The pod creation will be rejected with an admission error
C.The pod will be created and run successfully
D.The pod will be created but the image will be replaced with a trusted one
AnswerB

Kyverno acts as a validating admission controller that evaluates the pod manifest against the configured policy. If a rule is violated, the API server receives a denial response and reports an admission error to the client, preventing the pod from being created. The request is rejected pre-persist, so the pod never runs.

Why this answer

Kyverno operates as an admission controller in Kubernetes. When a pod is created, the Kyverno admission webhook intercepts the creation request and evaluates it against the configured policies. If the policy requires all images to come from a trusted registry and the pod uses an image from an untrusted registry, the admission webhook rejects the request, preventing the pod from being created.

This results in an admission error, not a post-creation termination.

Exam trap

The trap here is that candidates confuse admission control with post-creation enforcement (like OPA Gatekeeper's audit mode or Kubernetes security contexts), assuming the pod is created and then terminated, rather than understanding that Kyverno policies block creation at the admission webhook stage before the pod is ever persisted.

How to eliminate wrong answers

Option A is wrong because Kyverno policies are enforced at admission time via a MutatingAdmissionWebhook or ValidatingAdmissionWebhook, not after the pod is created; the pod is never scheduled or run, so it cannot be 'immediately terminated'. Option C is wrong because the policy explicitly blocks images from untrusted registries, so the pod cannot be created and run successfully. Option D is wrong because Kyverno does not automatically replace images; it either allows or denies the request based on the policy, and image substitution would require a mutation rule explicitly defined in the policy, which is not implied by the scenario.

382
MCQmedium

A security auditor runs kube-bench and reports that the kubelet is not configured with --protect-kernel-defaults. What is the impact of this misconfiguration?

A.Container runtime will not be able to pull images
B.The node will be unable to schedule pods
C.The kubelet will refuse to start
D.Kernel parameters may be modified, potentially reducing node security
AnswerD

Without --protect-kernel-defaults, kubelet does not verify that kernel parameters such as kernel.panic, vm.overcommit_memory, or net.ipv4.ip_forward match the secure values required by the CIS Kubernetes Benchmark, nor does it prevent containers from applying unsafe sysctls that can alter node-wide kernel behavior. A pod could thus modify kernel settings (e.g., enabling IP forwarding, changing shared-memory limits, or altering panic behavior), weakening node isolation and potentially facilitating container escapes or lateral network movement. Setting the flag to true forces kubelet to enforce these defaults or refuse to start, preserving node security.

Why this answer

The `--protect-kernel-defaults` flag ensures that the kubelet enforces kernel parameter hardening, preventing modifications that could weaken node security. Without it, a compromised or misconfigured pod could alter kernel settings (e.g., `net.ipv4.ip_forward`, `vm.overcommit_memory`), reducing the overall security posture of the node. This does not affect image pulling, pod scheduling, or kubelet startup.

Exam trap

The trap here is that candidates assume a missing security flag will cause an immediate failure (like kubelet not starting), when in reality the kubelet runs but the node becomes vulnerable to kernel parameter tampering.

How to eliminate wrong answers

Option A is wrong because the container runtime's ability to pull images depends on network connectivity and registry access, not on kernel parameter protection. Option B is wrong because pod scheduling is controlled by the scheduler and node conditions, not by the `--protect-kernel-defaults` flag; the node will still schedule pods. Option C is wrong because the kubelet will start without this flag; it only logs a warning or fails if the kernel parameters are not set correctly, but the flag itself does not prevent startup.

383
MCQmedium

An administrator wants to enforce that no container in a specific namespace runs with the privileged security context. They decide to use Pod Security Standards. Which Pod Security Standard level should be applied to the namespace?

A.baseline
B.custom
C.restricted
D.privileged
AnswerC

Restricted is the most restrictive level and prohibits privileged containers.

Why this answer

The restricted Pod Security Standard (PSS) level is the correct choice because it enforces the most stringent set of security controls, including the prohibition of privileged containers. This level denies any pod that requests `privileged: true` or uses other privileged capabilities, ensuring that no container in the namespace can run with elevated host access. The baseline level is less restrictive and allows some privileged configurations, while the privileged level imposes no restrictions at all.

Exam trap

The trap here is that candidates often confuse the 'baseline' level as being sufficient to block privileged containers, but baseline only prevents known privilege escalations and does not explicitly deny the `privileged: true` setting, which is only enforced by the restricted level.

How to eliminate wrong answers

Option A is wrong because the baseline level only blocks known privilege escalations but still allows some privileged settings (e.g., `privileged: true` is not explicitly denied by baseline). Option B is wrong because 'custom' is not a standard Pod Security Standard level; PSS defines only three built-in levels: privileged, baseline, and restricted. Option D is wrong because the privileged level explicitly permits all containers to run with privileged security contexts, which is the opposite of the enforcement goal.

384
MCQeasy

Which admission plugin should be used to enforce Pod Security Standards at the namespace level?

A.PodSecurity
B.PodSecurityPolicy
C.NodeRestriction
D.SecurityContextDeny
AnswerA

PodSecurity is the built-in admission controller that enforces the Kubernetes Pod Security Standards (PSS). It inspects incoming pod creation and update requests and applies one of three policy levels (privileged, baseline, restricted) based on namespace labels like pod-security.kubernetes.io/enforce. Since v1.25, it is the official replacement for PodSecurityPolicy and is enabled by default in most clusters.

Why this answer

The PodSecurity admission plugin is the successor to PodSecurityPolicy (PSP) and is designed specifically to enforce Pod Security Standards (PSS) at the namespace level. It evaluates pods against the three predefined PSS levels (privileged, baseline, restricted) based on labels set on the namespace, and can be configured in warn, audit, or enforce mode. This plugin is built into the kube-apiserver and is the recommended approach for pod security in Kubernetes v1.25 and later.

Exam trap

CNCF often tests the fact that PodSecurityPolicy is deprecated and removed, so candidates who studied older material may mistakenly choose PodSecurityPolicy, not realizing it has been replaced by the PodSecurity admission plugin.

How to eliminate wrong answers

Option B is wrong because PodSecurityPolicy (PSP) was deprecated in Kubernetes v1.21 and removed in v1.25, and it enforces security policies cluster-wide via a CRD, not at the namespace level using Pod Security Standards. Option C is wrong because NodeRestriction is an admission plugin that limits the Node API objects a kubelet can modify, and has nothing to do with pod security standards. Option D is wrong because SecurityContextDeny is an older admission plugin that rejects pods with certain security context settings, but it does not enforce the namespace-scoped Pod Security Standards and is not the recommended replacement for PSP.

385
MCQeasy

Which of the following is the best practice for injecting secrets into a pod?

A.Storing secrets in container image layers
B.Using environment variables
C.Using ConfigMap for secrets
D.Injecting via volume mounts
AnswerD

Mounting secrets as files in a volume is safer because the sensitive data appears only as file contents at the specified mount path, not in environment variables. It allows per-pod filesystem permissions, like read-only and mode settings, and is easier to rotate, as a change to the Secret object will eventually update the mounted file without restarting the container.

Why this answer

Mounting secrets as volumes ensures that secret data is stored in the pod's filesystem as files, which are created in a tmpfs in-memory filesystem (ram-backed) and never written to disk. This approach also allows for automatic rotation of secret values when the Secret object is updated, without requiring a pod restart, and avoids exposing secrets in process listings or container logs.

Exam trap

Kubernetes often tests the misconception that environment variables are a safe way to inject secrets because they are 'in-memory,' but the trap here is that environment variables are visible in the process environment, can be leaked via `/proc`, and cannot be rotated without restarting the pod, making volume mounts the only secure and dynamic option.

How to eliminate wrong answers

Option A is wrong because storing secrets in container image layers makes them accessible to anyone with access to the image registry, and they persist in the image history even after deletion, violating the principle of least privilege. Option B is wrong because using environment variables for secrets exposes them in the pod's process environment, which can be read via /proc/self/environ or leaked in logs, and they cannot be dynamically updated without restarting the pod. Option C is wrong because ConfigMaps are designed for non-sensitive configuration data and do not support encryption at rest or in transit; using them for secrets would store data in plaintext in etcd and expose it to any user with access to the ConfigMap API.

386
MCQmedium

An administrator wants to prevent the kubelet from serving anonymous requests. Which flag should be set on the kubelet?

A.--client-ca-file=/etc/kubernetes/pki/ca.crt
B.--authorization-mode=Webhook
C.--anonymous-auth=false
D.--authentication-token-webhook=true
AnswerC

The --anonymous-auth=false flag disables the kubelet's built-in anonymous authentication policy. When this flag is set to false, requests that do not present verifiable client credentials are rejected with HTTP 401 before any authorization check occurs. This is the direct and intended mechanism to prevent the kubelet from serving to unauthenticated, anonymous clients. Without setting this flag, the kubelet remains vulnerable to unauthenticated access to its health/readiness endpoints, pod listing, and even exec/attach capabilities depending on authorization configuration. Therefore, this is the correct and minimal flag to achieve the administrator's stated goal.

Why this answer

The `--anonymous-auth=false` flag explicitly disables anonymous authentication on the kubelet, preventing unauthenticated requests from being processed. By default, anonymous authentication is enabled (`--anonymous-auth=true`), which allows any unauthenticated user to make requests to the kubelet API. Setting this flag to `false` ensures that only authenticated clients can interact with the kubelet, directly addressing the requirement to block anonymous requests.

Exam trap

The trap here is that candidates often confuse authentication with authorization—they think setting a client CA file or enabling webhook authorization will block anonymous requests, but those controls only affect already-authenticated users or authorization decisions, not the initial authentication step where anonymous access is allowed by default.

How to eliminate wrong answers

Option A is wrong because `--client-ca-file` configures the certificate authority used to validate client certificates for mutual TLS authentication, but it does not disable anonymous authentication—anonymous requests are still allowed unless explicitly blocked. Option B is wrong because `--authorization-mode=Webhook` sets the authorization mode to delegate authorization decisions to an external webhook, but it does not affect authentication; anonymous users can still be authenticated and then authorized. Option D is wrong because `--authentication-token-webhook=true` enables token-based authentication via a webhook, but it does not disable anonymous authentication—anonymous requests remain permitted unless `--anonymous-auth` is set to `false`.

387
MCQeasy

Which kubectl command creates a secret named 'mysecret' from a file called 'credentials.json'?

A.kubectl create secret generic mysecret --from-file=credentials.json
B.kubectl apply -f credentials.json
C.kubectl create configmap mysecret --from-file=credentials.json
D.kubectl create secret tls mysecret --cert=credentials.json
AnswerA

The '--from-file' flag tells kubectl to read the file 'credentials.json' and use its filename as the key, with the file's raw contents as the value. Because the subcommand is 'generic', kubectl wraps this data in a Secret object and base64-encodes each value when storing it in etcd. This is the correct command for converting a single local file into a Secret.

Why this answer

`kubectl create secret generic` is the command to create a generic (opaque) secret from a file. The `--from-file` flag reads the contents of `credentials.json` and stores them as the secret's data, using the filename as the key by default. This is the standard method for injecting sensitive file-based data into a Kubernetes secret.

Exam trap

Kubernetes often tests the distinction between `kubectl create secret generic` and `kubectl create secret tls`, and the trap here is that candidates may confuse the `--from-file` flag (for generic secrets) with the `--cert`/`--key` flags (for TLS secrets) or mistakenly use `kubectl apply` on a raw data file instead of a manifest.

How to eliminate wrong answers

Option B is wrong because `kubectl apply -f credentials.json` expects a valid Kubernetes manifest (YAML/JSON) defining a resource, not a raw data file like `credentials.json`. Option C is wrong because `kubectl create configmap` creates a ConfigMap, not a Secret; ConfigMaps store non-sensitive data, while Secrets are base64-encoded and intended for sensitive information. Option D is wrong because `kubectl create secret tls` is specifically for TLS certificates and requires `--cert` and `--key` flags pointing to PEM-encoded certificate and key files, not a generic JSON file.

388
MCQeasy

A DevOps engineer notices that a container's stdout logs are not appearing in the `kubectl logs` output. The container runs a legacy application that writes logs to a file inside the container. What is the most efficient way to capture these logs without modifying the application?

A.Configure the kubelet to rotate logs from the container's filesystem.
B.Add a sidecar container that reads the log file and outputs to stdout.
C.Use `kubectl cp` to periodically copy logs from the container.
D.Install a syslog daemon in the container to forward logs.
AnswerB

This pattern adds a lightweight sidecar container that shares a volume with the main application, typically an emptyDir, where the log file resides. The sidecar tails the file and writes every new line to its own stdout, which kubectl logs reads. It gives you real-time file log streaming through the standard Kubernetes API without modifying the primary container or its image.

Why this answer

Deploying a sidecar container that tails the log file and writes to its own stdout is the most efficient, Kubernetes-native pattern for capturing logs from applications that write to files. The sidecar container shares the same Pod and volume, reads the log file (e.g., using `tail -F`), and outputs to stdout, which is then collected by `kubectl logs` and the cluster-level logging pipeline. This approach requires no modification to the legacy application and leverages the existing container runtime and kubelet log collection.

Exam trap

CNCF often tests the sidecar logging pattern as the standard Kubernetes solution for capturing file-based logs, and the trap here is that candidates may incorrectly choose kubelet log rotation (Option A) thinking it applies to all container logs, when in fact it only applies to the container runtime's own stdout/stderr streams.

How to eliminate wrong answers

Option A is wrong because the kubelet handles log rotation only for container stdout/stderr streams, not for files written inside the container's filesystem; it cannot rotate arbitrary application log files. Option C is wrong because `kubectl cp` is a manual, non-scalable operation that requires external orchestration and does not provide real-time log streaming to `kubectl logs`. Option D is wrong because installing a syslog daemon inside the container would require modifying the container image or running additional processes, which contradicts the requirement of not modifying the application and adds unnecessary complexity.

389
MCQhard

A container runs as non-root and needs to perform operations that require CAP_SYS_PTRACE. Which YAML snippet correctly adds only this capability while following the principle of least privilege?

A.securityContext: capabilities: add: ['SYS_PTRACE']
B.securityContext: capabilities: drop: ['ALL'] add: ['SYS_PTRACE']
C.securityContext: capabilities: drop: ['ALL']
D.securityContext: privileged: true
AnswerB

This explicitly drops every capability first, then adds only SYS_PTRACE, resulting in a minimal capability set scoped to the required operation. This follows the least-privilege principle: the container receives exactly one Linux capability, reducing the kernel attack surface to the narrowest possible for the task.

Why this answer

It first drops all capabilities with `drop: ['ALL']` and then explicitly adds only `SYS_PTRACE`, ensuring the container runs with the minimum privileges required. This follows the principle of least privilege by removing any inherited or default capabilities before granting only the needed one. In Kubernetes, capabilities are Linux kernel capabilities; dropping all and adding only what is necessary is the recommended security practice.

Exam trap

CNCF often tests the misconception that simply adding a capability is sufficient, but the trap is that candidates forget to drop all other capabilities first, leaving the container with more privileges than intended.

How to eliminate wrong answers

Option A is wrong because it only adds `SYS_PTRACE` without dropping existing capabilities, meaning the container retains all default capabilities (e.g., CHOWN, DAC_OVERRIDE, FOWNER, etc.), violating the principle of least privilege. Option C is wrong because it drops all capabilities but does not add `SYS_PTRACE`, so the container would lack the required capability to perform ptrace operations. Option D is wrong because setting `privileged: true` grants all capabilities (including SYS_PTRACE) and disables most security constraints, which is excessive and violates least privilege.

390
MCQmedium

An administrator runs kube-bench on a cluster node and receives failures for CIS benchmark checks related to kubelet configuration. Which kubelet flag should be set to ensure that kernel defaults are not used when they might be insecure?

A.--protect-kernel-defaults
B.--read-only-port=0
C.--anonymous-auth=false
D.--kubelet-extra-args
AnswerA

--protect-kernel-defaults makes the kubelet refuse to start when kernel parameters such as sysctl settings differ from secure values, rather than silently accepting insecure kernel defaults. This directly satisfies the CIS benchmark checks failing on kubelet configuration.

Why this answer

The `--protect-kernel-defaults` kubelet flag ensures that the kubelet will not use insecure kernel defaults by enforcing that certain sysctl settings (e.g., `kernel.panic`, `vm.overcommit_memory`) are set to secure values. If these kernel parameters are not explicitly configured to safe values, the kubelet will fail to start, preventing the node from running with potentially insecure kernel defaults. This directly addresses CIS benchmark checks that require hardening of the kubelet's interaction with the host kernel.

Exam trap

The trap here is that candidates often confuse `--protect-kernel-defaults` with other kubelet security flags like `--read-only-port` or `--anonymous-auth`, or mistakenly think `--kubelet-extra-args` is a direct kubelet flag, when in fact it is a kubeadm configuration option and not a solution for kernel default protection.

How to eliminate wrong answers

Option B is wrong because `--read-only-port=0` disables the read-only port (10255) on the kubelet, which prevents unauthenticated access to kubelet metrics, but it does not address kernel default security. Option C is wrong because `--anonymous-auth=false` disables anonymous authentication to the kubelet API, which is a separate CIS check for authentication hardening, not for kernel defaults. Option D is wrong because `--kubelet-extra-args` is a kubeadm configuration field used to pass additional flags to the kubelet, not a kubelet flag itself, and it does not specifically enforce kernel default protection.

391
Multi-Selecthard

Which THREE of the following practices help protect microservice applications against supply chain attacks? (Choose three.)

Select 3 answers
A.Use images from any public registry for flexibility
B.Use minimal base images (e.g., distroless or scratch) to reduce attack surface
C.Always use the latest tag to get the most recent patches
D.Scan images for vulnerabilities using tools like Trivy or Clair
E.Enable image verification using digital signatures (e.g., Notary or Cosign)
AnswersB, D, E

Minimal images like distroless or scratch contain only the essential runtime dependencies, excluding shells, package managers, and superfluous utilities. This dramatically shrinks the attack surface available to an attacker who gains code execution, limiting exploitation capabilities and reducing the number of CVEs that can affect the image. Fewer components also mean fewer packages to monitor and patch in the base layer.

Why this answer

Using minimal base images like distroless or scratch significantly reduces the attack surface by eliminating unnecessary packages, libraries, and utilities that could contain vulnerabilities. This aligns with the principle of least functionality, as fewer components mean fewer potential entry points for an attacker to exploit in a supply chain attack.

Exam trap

CNCF often tests the misconception that using the latest tag is a safe practice for getting patches, when in fact it undermines supply chain security by breaking image immutability and reproducibility.

392
MCQmedium

A security admin needs to audit all API requests to the Kubernetes API server. Which audit policy level logs the request body and response body?

A.Request
B.None
C.RequestResponse
D.Metadata
AnswerC

RequestResponse records the full request and response bodies alongside metadata, satisfying the requirement to audit complete API request content. Lower levels such as Metadata or Request omit response bodies entirely, so they cannot capture the payloads the admin needs. This level therefore provides the body-level detail the stem explicitly demands.

Why this answer

The RequestResponse audit level logs the request body and response body, along with metadata. This is the most verbose audit level, capturing the full content of API requests and responses. It is used when complete visibility into API interactions is required, such as for deep security auditing or debugging.

However, it can generate large amounts of data and may expose sensitive information, so it should be used judiciously.

Exam trap

CKS often tests the distinction between audit levels, and candidates may confuse 'Request' with 'RequestResponse', forgetting that only the latter includes the response body.

How to eliminate wrong answers

Option A is wrong because the Request level logs only the request body and metadata, not the response body. Option B is wrong because the None level logs nothing; it is used to exclude events from auditing. Option D is wrong because the Metadata level logs only request metadata (such as user, timestamp, resource, verb) but not request or response bodies.

393
MCQeasy

What is the purpose of the --audit-log-path flag on the kube-apiserver?

A.It sets the maximum number of audit log files to retain.
B.It disables audit logging.
C.It enables audit logging and sets the output file path.
D.It specifies the path to the audit policy file.
AnswerC

This flag is the correct answer because it accomplishes two things: it activates the audit logging file backend on the kube-apiserver and designates the specific file path where JSON audit events will be appended. Without it, even with an audit policy defined, the API server has no local file destination for audit records. The flag is often used alongside --audit-policy-file to control which events are recorded, but the path flag itself is what turns on logging to disk.

Why this answer

The `--audit-log-path` flag on the kube-apiserver enables audit logging and specifies the file path where audit events are written. Without this flag, audit logging is disabled by default. Setting this flag is the first step to capturing API request logs for security monitoring and compliance.

Exam trap

CNCF often tests the distinction between `--audit-log-path` (enables logging and sets output path) and `--audit-policy-file` (defines what to log), causing candidates to confuse the two flags.

How to eliminate wrong answers

Option A is wrong because the `--audit-log-maxbackup` flag, not `--audit-log-path`, controls the maximum number of audit log files to retain. Option B is wrong because the `--audit-log-path` flag enables audit logging, not disables it; disabling audit logging is the default behavior when the flag is omitted. Option D is wrong because the path to the audit policy file is set by the `--audit-policy-file` flag, not `--audit-log-path`.

394
MCQmedium

Which of the following is NOT a valid seccomp profile type in Kubernetes?

A.SeccompDefault
B.Unconfined
C.RuntimeDefault
D.Localhost
AnswerA

SeccompDefault is not a valid seccomp profile type in Kubernetes. The valid values for the `type` field under `securityContext.seccompProfile` are `RuntimeDefault`, `Localhost`, and `Unconfined`. While the `SeccompDefault` feature gate enables the runtime default profile for pods, it does not appear as a profile type value. The attempt to set `type: SeccompDefault` will be rejected by the API server.

Why this answer

SeccompDefault is not a valid seccomp profile type in Kubernetes. The valid profile types are Unconfined, RuntimeDefault, and Localhost. SeccompDefault is a feature gate (introduced in Kubernetes 1.22) that, when enabled, tells the kubelet to use the RuntimeDefault seccomp profile by default for pods, but it is not itself a profile type.

Exam trap

The trap here is that candidates confuse the SeccompDefault feature gate with a valid seccomp profile type, especially since the feature gate name sounds like a profile type and is often mentioned in the context of default seccomp enforcement.

How to eliminate wrong answers

Option A is wrong because SeccompDefault is a feature gate, not a seccomp profile type. Option B is wrong because Unconfined is a valid seccomp profile type that disables seccomp filtering for a container. Option C is wrong because RuntimeDefault is a valid seccomp profile type that uses the container runtime's default seccomp profile (typically a restrictive profile that blocks syscalls like unshare, mount, etc.).

Option D is wrong because Localhost is a valid seccomp profile type that allows you to specify a custom seccomp profile file on the node's filesystem.

395
Multi-Selectmedium

Which TWO of the following are valid ways to securely manage secrets in Kubernetes? (Choose two.)

Select 2 answers
A.Mount Kubernetes Secrets as volumes into the pod.
B.Use environment variables from the pod spec referencing Secret keys.
C.Use an external secrets manager like HashiCorp Vault integrated with the pod.
D.Pass secrets as command-line arguments to the container.
E.Store secrets in ConfigMaps with base64 encoded data.
AnswersA, C

Mounting a Kubernetes Secret as a volume is the most secure built-in method because the kubelet creates an in-memory tmpfs filesystem and writes each secret key as a file, which is not stored on the node's disk. Unlike environment variables, volume-mounted secrets are not visible in /proc/<pid>/environ or container logs, and they support automatic rotation: when the Secret object is updated, the kubelet eventually rewrites the mounted files without requiring a pod restart. You can also set file permissions via defaultMode to restrict access to the specific user in the container, and the secret data never appears in the pod spec beyond the Secret reference.

Why this answer

Mounting Kubernetes Secrets as volumes into the pod ensures that secret data is stored in the pod's filesystem as files, which are created with in-memory tmpfs to avoid writing to disk. This approach leverages Kubernetes' native secret handling, where the secret data is base64-decoded and presented as plaintext files, and access can be controlled via RBAC and PodSecurityPolicies. It also supports automatic rotation when secrets are updated, provided the pod is restarted or the volume is remounted.

Exam trap

Kubernetes often tests the misconception that environment variables are a secure way to inject secrets, when in fact they are vulnerable to exposure through process introspection and logging, making volume mounts or external secret stores the recommended approaches.

396
Multi-Selectmedium

Which TWO of the following are valid ways to reduce the attack surface of a Kubernetes node? (Select 2)

Select 2 answers
A.Load all kernel modules to support any workload
B.Restrict hostNetwork, hostPID, and hostIPC access from containers
C.Enable SSH access for all users for troubleshooting
D.Disable unnecessary system services on the node
E.Allow containers to run as root
AnswersB, D

Restricting hostNetwork, hostPID and hostIPC prevents pods sharing the node's network stack, process table and IPC namespace, blocking host snooping and privilege escalation. This directly reduces the node attack surface by severing container-to-host namespace sharing.

Why this answer

Option B is correct because restricting hostNetwork, hostPID, and hostIPC prevents containers from sharing the node's network, process, and IPC namespaces, which blocks container escapes and privilege escalation that would otherwise expose the host directly. Option D is correct because disabling unnecessary system services on the node removes unused daemons and listening ports, shrinking the exploitable attack surface in line with CIS Kubernetes Benchmark node hardening guidance. Option A is wrong because loading all kernel modules increases the attack surface by exposing additional kernel code and potential vulnerabilities rather than reducing it.

Option C is wrong because enabling SSH for all users broadens remote access and credential exposure instead of limiting it. Option E is wrong because allowing containers to run as root grants unnecessary privileges that can be leveraged to compromise the node.

Exam trap

CNCF often tests the misconception that loading all kernel modules is beneficial for compatibility, when in fact it violates the principle of minimizing the attack surface by only loading required modules.

397
MCQeasy

What is the purpose of the CIS Kubernetes Benchmark?

A.To provide a set of security best practices for Kubernetes
B.To benchmark performance of Kubernetes clusters
C.To test network policies
D.To automate deployment of Kubernetes clusters
AnswerA

The CIS Kubernetes Benchmark is a consensus-based, expert-reviewed document that defines specific security configuration checks and hardening recommendations for Kubernetes components such as the API server, etcd, kubelet, and controller manager. It gives operators a concrete, auditable checklist to reduce attack surface and align cluster configuration with established security best practices, which is exactly its stated purpose.

Why this answer

The CIS Kubernetes Benchmark is a set of security best practices developed by the Center for Internet Security (CIS) specifically for hardening Kubernetes clusters. It provides prescriptive guidance on configuring cluster components (e.g., kube-apiserver, kubelet, etcd) to reduce the attack surface and meet compliance standards. Option A correctly identifies this purpose, as the benchmark is not about performance, networking, or automation.

Exam trap

The trap here is that candidates confuse the CIS Benchmark with a performance or automation tool, because 'benchmark' often implies performance testing in other contexts, but in Kubernetes security, it strictly refers to a compliance and hardening standard.

How to eliminate wrong answers

Option B is wrong because the CIS Kubernetes Benchmark focuses on security configuration, not performance benchmarking; performance metrics are measured by tools like the Kubernetes Performance and Scalability Working Group's benchmarks. Option C is wrong because while the benchmark includes recommendations for network policies, its scope is far broader, covering all aspects of cluster security (e.g., RBAC, secrets, pod security). Option D is wrong because the benchmark is a set of guidelines, not a deployment tool; automation of cluster deployment is handled by tools like kubeadm, Terraform, or Cluster API.

398
MCQmedium

A Kubernetes cluster has Kyverno installed. You want to enforce that all container images come from a trusted registry 'trusted-registry.example.com'. Which Kyverno policy rule type would you use?

A.validate with a deny condition
B.mutate
C.validate.deny
D.generate
AnswerA

Using a Kyverno validate rule with a deny condition allows you to enforce policy by rejecting any Pod that does not meet the specified criteria, such as pulling images from unauthorized registries. The deny condition is evaluated against the resource; if the condition is true, admission is blocked with a clear message. This is the canonical way to express negative constraints in Kyverno, as it directly validates the existing image field without altering it.

Why this answer

Kyverno's `validate` rule type with a `deny` condition is specifically designed to reject resources that violate a policy. In this case, the policy would deny any Pod that references an image not matching the pattern `trusted-registry.example.com/*`, enforcing the trusted registry requirement at admission time.

Exam trap

The trap here is that candidates confuse the `validate.deny` syntax (which does not exist) with the correct approach of using a `validate` rule containing a `deny` condition, often because other tools like OPA/Gatekeeper use a `deny` rule type directly.

How to eliminate wrong answers

Option B is wrong because `mutate` rules modify resources (e.g., prefixing an image registry) but do not block non-compliant resources; they cannot enforce a deny. Option C is wrong because `validate.deny` is not a valid Kyverno rule type; the correct syntax is `validate` with a `deny` condition under the `validationFailureAction` or `deny` block. Option D is wrong because `generate` rules create new resources (e.g., default NetworkPolicies) and have no capability to validate or deny existing resources.

399
MCQhard

You need to ensure that all pods in a namespace have the label 'security: high' added automatically upon creation. Which admission controller should you use?

A.PodSecurityPolicy (deprecated)
B.ResourceQuota
C.ValidatingAdmissionPolicy
D.MutatingWebhookConfiguration
AnswerD

MutatingWebhookConfiguration is correct because it registers external webhooks that can modify a pod object during the mutating admission phase. A mutating webhook can inspect the pod being created and add a label to its metadata before the object is persisted. This is exactly the mechanism for automatically labeling every pod in a namespace, unlike validation-only admission components.

Why this answer

A MutatingWebhookConfiguration intercepts pod creation requests and can automatically add the label 'security: high' to pods in a namespace. This admission controller mutates the object before it is persisted, ensuring all pods receive the label without manual intervention.

Exam trap

In the CNCF CKS exam, candidates often confuse MutatingAdmissionPolicy with ValidatingAdmissionPolicy. Remember that only mutating admission controllers can modify objects; ValidatingAdmissionPolicy only checks and rejects.

How to eliminate wrong answers

Option A is wrong because PodSecurityPolicy is deprecated and does not add labels; it enforces security contexts. Option B is wrong because ResourceQuota limits resource consumption, not labels. Option C is wrong because ValidatingAdmissionPolicy only validates requests and cannot mutate objects to add labels.

400
MCQhard

You are configuring encryption at rest for Kubernetes secrets. After creating an EncryptionConfiguration with aescbc provider, which additional step is required to enable encryption?

A.Restart the kube-apiserver with --encryption-provider-config flag
B.Apply the EncryptionConfiguration as a ConfigMap
C.Restart the kube-scheduler
D.Recreate all secrets in the cluster
AnswerA

The kube-apiserver reads --encryption-provider-config only at process startup, so the configuration file must be in place and the control plane component restarted for the change to take effect. This flag points to a YAML/JSON file that defines how to encrypt secrets at the etcd level. Without the restart, the apiserver continues using its previous, unencrypted write path. This is the required first step before any existing data can be migrated to encrypted form.

Why this answer

The EncryptionConfiguration resource defines how Kubernetes should encrypt data at rest, but it is not automatically applied. The kube-apiserver must be restarted with the `--encryption-provider-config` flag pointing to the configuration file so that it reads and enforces the encryption settings for all subsequent writes to etcd. Without this flag, the apiserver ignores the EncryptionConfiguration entirely.

Exam trap

A common pitfall is thinking that creating the EncryptionConfiguration resource is sufficient. In reality, the kube-apiserver must be configured with the --encryption-provider-config flag and restarted to activate encryption.

How to eliminate wrong answers

Option B is wrong because an EncryptionConfiguration is a custom resource, not a ConfigMap; applying it as a ConfigMap would not be recognized by the kube-apiserver. Option C is wrong because the kube-scheduler does not handle secret storage or encryption; encryption at rest is managed solely by the kube-apiserver when writing to etcd. Option D is wrong because existing secrets are not automatically re-encrypted; the encryption provider only applies to new or updated secrets, and existing secrets remain unencrypted until they are rewritten.

401
Multi-Selectmedium

Which THREE of the following are features of container sandboxing solutions like gVisor or Kata Containers?

Select 3 answers
A.They are compatible with the OCI runtime specification
B.They improve container performance over native runc
C.They can be used with RuntimeClass to select the sandbox runtime per pod
D.They provide an additional layer of isolation between containers and the host kernel
E.They use the host kernel directly for all system calls
AnswersA, C, D

Container sandboxes such as gVisor (runsc) and Kata Containers implement the OCI runtime specification, meaning they expose the same lifecycle commands (create, start, delete) and expect the same OCI image/bundle format. This allows containerd or CRI-O to treat them as drop-in replacements for runc, requiring no changes to the kubelet, container images, or orchestration workflows. OCI compatibility is therefore a core enabler for using these sandboxes in Kubernetes without breaking existing tooling.

Why this answer

Both gVisor and Kata Containers implement the OCI (Open Container Initiative) runtime specification, which allows them to be used as drop-in replacements for runc. This compatibility ensures that container images and tools like containerd can interface with these sandboxed runtimes without modification, as they expose the same runtime lifecycle commands (create, start, delete).

Exam trap

The CKS exam often tests the misconception that sandboxing improves performance, when in reality the added isolation layer (user-space kernel or VM) introduces latency and resource overhead compared to native runc.

402
MCQmedium

A Falco rule is configured to detect privilege escalation via setuid binaries. Which syscall is commonly associated with this activity?

A.connect
B.setuid
C.open
D.execve
AnswerB

The setuid syscall is the kernel API that changes the process's effective (and optionally real) user ID, and it is the direct primitive used in a privilege-escalation attack when a process transitions from an unprivileged UID to a privileged one such as root. Because an exploit often invokes setuid (or one of its variants like seteuid) to permanently or temporarily raise privileges, Falco can catch credential-state changes by filtering on this syscall. In a Falco rule for privilege escalation, setuid is the semantically correct event to monitor, since it represents the moment of privilege elevation, not just a side effect.

Why this answer

The setuid syscall is used to change the effective user ID of a process, and it is the mechanism by which setuid binaries elevate privileges. Falco rules that detect privilege escalation via setuid binaries monitor this syscall (often combined with execve of a setuid binary) to flag unauthorized elevation attempts.

Exam trap

CKS often tests whether candidates confuse execve (program execution) with setuid (credential change) — privilege escalation via setuid binaries requires the setuid syscall, not just execve.

How to eliminate wrong answers

Option A is wrong because connect is a network syscall used to initiate outbound connections, unrelated to privilege escalation. Option C is wrong because open is a file-access syscall and does not change process credentials. Option D is wrong because execve executes a program but does not itself elevate privileges — it is the setuid bit plus the setuid syscall (or the kernel's handling of the setuid bit during execve) that grants elevation.

403
MCQhard

A pod runs with a service mesh sidecar (Istio). The team wants to enforce mutual TLS (mTLS) for all traffic between services in the 'production' namespace. Which resource should be applied?

A.DestinationRule with trafficPolicy: tls: mode: ISTIO_MUTUAL
B.VirtualService with TLS settings
C.PeerAuthentication with mode: STRICT in the namespace
D.ServiceEntry with mTLS enabled
AnswerC

PeerAuthentication is the Istio policy resource specifically designed to control mTLS adoption at mesh, namespace, or workload granularity. Setting mode: STRICT in the production namespace requires every service-to-service communication to be mutual TLS; any plaintext request will be rejected by the sidecar proxies, effectively enforcing the team's requirement. This is the standard and recommended way to enforce mTLS for an entire namespace.

Why this answer

PeerAuthentication with mode: STRICT enforces mutual TLS at the service mesh level by requiring all traffic within the namespace to use TLS certificates for both sides of the connection. This is the correct Istio resource to enforce mTLS for all services in the 'production' namespace, as it sets a namespace-wide policy that overrides any permissive defaults.

Exam trap

CNCF often tests the distinction between PeerAuthentication (which enforces mTLS on the server side) and DestinationRule (which configures client-side TLS), leading candidates to mistakenly choose DestinationRule for namespace-wide mTLS enforcement.

How to eliminate wrong answers

Option A is wrong because DestinationRule with trafficPolicy: tls: mode: ISTIO_MUTUAL configures client-side TLS settings for traffic to specific hosts, but does not enforce server-side mTLS acceptance; it only sets the client's TLS mode and can be bypassed if the server allows plaintext. Option B is wrong because VirtualService is used for traffic routing (e.g., canary deployments, A/B testing) and does not handle TLS authentication or mTLS enforcement; its TLS settings are for ingress gateway TLS termination, not peer authentication. Option D is wrong because ServiceEntry is used to register external services into the mesh and enable mTLS for those endpoints, but it does not enforce mTLS for internal services within the namespace.

404
MCQmedium

You want to enable mutual TLS (mTLS) between services in a namespace using Istio. Which custom resource should you configure to enforce STRICT mTLS for all workloads in the namespace?

A.DestinationRule with trafficPolicy.tls.mode: ISTIO_MUTUAL
B.VirtualService with tls.mode: SIMPLE
C.PeerAuthentication with mtls.mode: STRICT
D.ServiceEntry with resolution: NONE
AnswerC

PeerAuthentication is the Istio policy object that controls inbound TLS enforcement on the server side, and mtls.mode: STRICT demands that all traffic arriving at the workload be wrapped in Istio mutual TLS. Any plaintext or non-Istio TLS connection is rejected with a 403 response, so this is the correct way to enable mTLS between services in a namespace. It works alongside DestinationRules, which configure the client side, but enforcement of the policy happens here.

Why this answer

PeerAuthentication is the Istio custom resource specifically designed to define traffic authentication policies between workloads. Setting `mtls.mode: STRICT` enforces that all traffic in the namespace must use mutual TLS (mTLS), rejecting any plain-text or non-mTLS connections. This is the standard way to enforce STRICT mTLS at the namespace level in Istio.

Exam trap

The trap here is confusing DestinationRule's `trafficPolicy.tls.mode: ISTIO_MUTUAL` with PeerAuthentication's `mtls.mode: STRICT`; candidates often mistakenly think DestinationRule enforces mTLS, but it only configures TLS for outbound traffic, not inbound authentication enforcement.

How to eliminate wrong answers

Option A is wrong because DestinationRule controls traffic routing and load balancing policies, not authentication; its `trafficPolicy.tls.mode: ISTIO_MUTUAL` only configures TLS settings for outbound connections to a specific host, not enforcing mTLS on inbound traffic. Option B is wrong because VirtualService is used for traffic routing and manipulation, not authentication; `tls.mode: SIMPLE` is not a valid field in VirtualService and does not relate to mTLS enforcement. Option D is wrong because ServiceEntry is used to register external services into the mesh, not to enforce authentication policies; `resolution: NONE` controls DNS resolution, not TLS mode.

405
MCQmedium

You suspect a pod is making unexpected outbound connections. Which tool can you use to inspect network connections from within the container?

A.kubectl port-forward
B.crictl exec
C.falco
D.kubectl logs
AnswerB

crictl exec is the correct choice because it lets you run a command inside the container via the container runtime (containerd/CRI-O), such as `crictl exec -it <container-id> ss -tpn` or `netstat -an`, to inspect active TCP/UDP connections initiated by the container. Unlike `kubectl exec`, it works directly against the runtime, even if the Kubernetes API server is unreachable. This allows you to see the exact source, destination, and process for each outbound connection.

Why this answer

`crictl exec` allows you to run commands inside a container managed by CRI-compatible runtimes (like containerd), enabling you to inspect network connections from within the container using tools like `ss`, `netstat`, or `ip`. This is the direct method to check outbound connections from the container's network namespace, which is isolated from the host.

Exam trap

The trap here is that candidates may choose `kubectl logs` thinking it shows network activity, but logs only capture application output, not kernel-level connection states, while `crictl exec` provides direct access to the container's network namespace.

How to eliminate wrong answers

Option A is wrong because `kubectl port-forward` is used to forward local ports to a pod for debugging or accessing applications, not to inspect network connections from within the container. Option C is wrong because Falco is a runtime security tool that monitors system calls and detects anomalous behavior at the host level, but it does not provide an interactive shell to inspect connections from inside the container. Option D is wrong because `kubectl logs` retrieves container logs (stdout/stderr), which typically do not contain real-time network connection information unless the application explicitly logs them.

406
MCQmedium

An admin runs 'kubectl auth reconcile -f rbac.yaml' and gets an error that the user does not have permission to create ClusterRoleBindings. What is the most likely cause?

A.The ClusterRoleBinding already exists.
B.The YAML file has a syntax error.
C.The Kubernetes API server is not reachable.
D.The user's kubeconfig context does not have RBAC permissions to create ClusterRoleBindings.
AnswerD

The 'Forbidden' error is the API server's authorization rejection: the user identified by the current kubeconfig context has not been granted 'create' permission on 'clusterrolebindings' in the 'rbac.authorization.k8s.io' API group at cluster scope. 'kubectl auth reconcile' attempts to create the binding when it does not exist, triggering this RBAC denial. To resolve it, the operator must either switch to a context with sufficient permissions (e.g., cluster-admin) or have an administrator grant the required RBAC rule.

Why this answer

The error indicates that the user's current kubeconfig context lacks RBAC permissions to create ClusterRoleBindings. The `kubectl auth reconcile` command attempts to apply the RBAC resources defined in the YAML file, and if the user's credentials (typically from a certificate or token) do not include the `create` verb on `clusterrolebindings` in the RBAC authorization layer, the API server will reject the request with a 403 Forbidden error. This is a direct permission issue, not a connectivity or syntax problem.

Exam trap

The trap here is that candidates may confuse a permission error with a resource conflict (Option A) or a connectivity issue (Option C), but the specific error message 'does not have permission to create ClusterRoleBindings' directly points to insufficient RBAC privileges in the current kubeconfig context.

How to eliminate wrong answers

Option A is wrong because if the ClusterRoleBinding already exists, `kubectl auth reconcile` would attempt to update it (which requires `update` permission), but the error specifically mentions lack of permission to `create`, not a conflict error like 'AlreadyExists'. Option B is wrong because a syntax error in the YAML file would produce a parsing error from kubectl (e.g., 'error converting YAML to JSON'), not an RBAC permission error. Option C is wrong because if the API server were unreachable, the error would be a connection timeout or 'Unable to connect to the server', not a permission-denied message.

407
Multi-Selectmedium

Which TWO actions should be taken to secure etcd in a Kubernetes cluster?

Select 2 answers
A.Enable TLS authentication for etcd peer and client communication
B.Run etcd as a DaemonSet to ensure high availability
C.Disable client certificate authentication for etcd
D.Enable the NodeRestriction admission plugin on etcd
E.Restrict access to etcd using network policies or firewall rules
AnswersA, E

TLS authentication for etcd encompasses both peer and client communication, encrypting data in transit and requiring certificates for mutual identity verification. This prevents eavesdropping, man-in-the-middle attacks, and unauthorized access from compromised nodes. In a Kubernetes control plane, etcd peer communication (port 2380) and client communication with the API server (port 2379) must both be TLS-protected, as etcd stores cluster state and secrets. Without TLS, anyone with network access could read or alter cluster data, defeating the security of the entire cluster.

Why this answer

Enabling TLS authentication for etcd peer and client communication ensures that all data in transit between etcd members and between etcd and the Kubernetes API server is encrypted and mutually authenticated. This prevents man-in-the-middle attacks and unauthorized access to the cluster's state store, which is a critical requirement for securing etcd as per the CIS Kubernetes Benchmark.

Exam trap

CNCF often tests the misconception that admission plugins like NodeRestriction apply to etcd, when in fact they are exclusively API server components and have no role in securing the etcd datastore itself.

408
MCQeasy

A security engineer wants to ensure that only images signed with a specific key are allowed to run in the cluster. Which tool can be used to sign container images?

A.kubesec
B.syft
C.cosign
D.trivy
AnswerC

cosign is part of the Sigstore project and natively supports signing container images and verifying those signatures, including keyless signing via Fulcio and transparency logs (Rekor). It stores signatures as separate OCI artifacts, typically tagged like 'sha256-<digest>.sig', and can enforce that only verified images are admitted. Because it directly addresses the requirement to ensure images are signed, it is the only correct choice here.

Why this answer

Cosign is the correct tool because it is specifically designed for signing and verifying container images using cryptographic keys, integrating directly with OCI-compliant registries. It supports keyless signing via Fulcio and transparency logs via Rekor, making it the standard choice for enforcing image signature verification in Kubernetes admission controllers like Kyverno or OPA.

Exam trap

CNCF often tests the distinction between image scanning (Trivy, Syft) and image signing (Cosign), so candidates mistakenly choose a vulnerability scanner or SBOM tool when the question explicitly asks for signing.

How to eliminate wrong answers

Option A is wrong because kubesec is a static analysis tool that evaluates Kubernetes resource manifests against security best practices, not a tool for signing container images. Option B is wrong because syft is a software bill of materials (SBOM) generator that produces dependency lists from container images, not a signing tool. Option D is wrong because trivy is a vulnerability scanner for container images, filesystems, and Git repositories, and does not provide image signing capabilities.

409
MCQmedium

You are tasked with enabling audit logging for the Kubernetes API server. Which API server flag must be used to specify the audit log file path?

A.--audit-log-path
B.--audit-log-dir
C.--audit-policy-file
D.--audit-log-file
AnswerA

The `--audit-log-path` flag is the correct kube-apiserver flag that directly sets the file path for writing audit log events, such as `/var/log/kubernetes/audit/audit.log`. When set, the API server writes each audited request/response to this file, and enabling audit logging requires both this path and a policy file. It is typically added to the kube-apiserver static pod manifest or its systemd unit, and the target directory must be writable by the process. This flag is the definitive answer because the question specifically asks for the log path flag.

Why this answer

The `--audit-log-path` flag is the correct API server flag to specify the file path where audit logs are written. This flag defines the absolute or relative path to the audit log file, and the kube-apiserver will create or append to that file. Without this flag, no audit log file is generated, even if an audit policy is configured.

Exam trap

CNCF often tests the exact flag name `--audit-log-path` versus the plausible but incorrect `--audit-log-file`, exploiting the common assumption that the flag would be named after the file rather than the path.

How to eliminate wrong answers

Option B is wrong because `--audit-log-dir` is not a valid kube-apiserver flag; the correct flag for specifying the directory is `--audit-log-path`, which can include a directory path as part of the filename. Option C is wrong because `--audit-policy-file` specifies the path to the audit policy YAML file that defines which events to log, not the log file path itself. Option D is wrong because `--audit-log-file` is not a valid flag; the correct flag name is `--audit-log-path`.

410
Multi-Selectmedium

Which TWO tools can generate an SBOM for a container image? (Select two.)

Select 2 answers
A.checkov
B.trivy
C.syft
D.cosign
E.kubesec
AnswersB, C

Trivy is a container security scanner that also generates SBOMs in multiple formats, including CycloneDX and SPDX. Using subcommands like `trivy image --format cyclonedx` or `trivy sbom`, it extracts package information from the image's layers and package databases (e.g., dpkg, RPM, and ERS). This dual functionality makes Trivy a go-to tool for both vulnerability scanning and SBOM production.

Why this answer

Trivy is a comprehensive vulnerability scanner that can generate an SBOM (Software Bill of Materials) for container images using its `trivy image --format cyclonedx` or `trivy image --format spdx` commands, outputting in CycloneDX or SPDX formats. Syft is a dedicated SBOM generation tool from Anchore that produces detailed SBOMs from container images using `syft packages <image>` and supports multiple output formats including CycloneDX and SPDX. Both tools are specifically designed to inventory all software components within a container image, making them correct choices for SBOM generation.

Exam trap

The CNCF CKS exam often tests the distinction between tools that generate SBOMs (Trivy, Syft) versus tools that scan for vulnerabilities (Trivy can do both, but the question specifically asks for SBOM generation) or perform other supply chain tasks like signing (Cosign) or IaC scanning (Checkov), leading candidates to confuse a tool's primary function with its secondary capabilities.

411
MCQeasy

What is the default authorization mode for a new Kubernetes cluster?

A.ABAC
B.Node
C.AlwaysDeny
D.RBAC
AnswerD

RBAC (Role-Based Access Control) is the default authorization mode in most modern Kubernetes distributions, including kubeadm and managed offerings like EKS, AKS, and GKE. It enables fine-grained control through Roles and ClusterRoles, bound to users, service accounts, and groups via RoleBindings and ClusterRoleBindings. This default provides a secure baseline and supports least-privilege access for both human administrators and in-cluster workloads.

Why this answer

RBAC (Role-Based Access Control) is the default authorization mode for new Kubernetes clusters since version 1.8. When you initialize a cluster with kubeadm, the API server is automatically configured with the `--authorization-mode=RBAC` flag, enabling fine-grained access control based on roles and bindings.

Exam trap

CNCF often tests the misconception that ABAC is the default because it was the original authorization mode in early Kubernetes versions, but RBAC has been the default since v1.8 and is the recommended standard for security.

How to eliminate wrong answers

Option A is wrong because ABAC (Attribute-Based Access Control) is not the default; it requires manual configuration with `--authorization-mode=ABAC` and a policy file, and it is less secure and harder to manage than RBAC. Option B is wrong because Node authorization is a special-purpose mode used to authorize kubelet API requests, not the default for the entire cluster; it is typically combined with other modes like RBAC. Option C is wrong because AlwaysDeny is a legacy mode that denies all requests and is not used in production; it was removed in Kubernetes 1.10 and is never the default.

412
MCQhard

During a security audit, a team discovers that their microservice application, deployed on Kubernetes, is vulnerable to container breakout attacks. The containers run as root and have many Linux capabilities. Which set of Pod Security Standards (PSS) enforcement modes and policies would best mitigate this risk?

A.Use 'privileged' PSS with Warn mode
B.Use 'baseline' PSS with Audit mode
C.Use 'restricted' PSS with Enforce mode
D.Use 'baseline' PSS with Enforce mode
AnswerC

Restricted profile in Enforce mode is the only combination among the choices that both selects the strongest pod-hardening policy and actually enforces it at admission time. Restricted requires runAsNonRoot=true, sets seccompProfile to RuntimeDefault, drops all capabilities except NET_BIND_SERVICE, and mandates a read-only root filesystem, which together deprive an attacker of the most common kernel exploits. Because Enforce mode rejects non-compliant pods before they are created, there is no opportunity for a restricted-violating pod to run and escape.

Why this answer

The 'restricted' Pod Security Standard with 'Enforce' mode is the correct choice because it mandates the most stringent security controls, including dropping all Linux capabilities and preventing containers from running as root. This directly mitigates container breakout attacks by eliminating the excessive privileges that enable such exploits. 'Enforce' mode actively blocks non-compliant pods, ensuring the policy is applied without relying on user awareness or audit logs.

Exam trap

CNCF often tests the misconception that 'baseline' PSS is sufficient for most security needs, but the trap here is that 'baseline' still allows root and default capabilities, which are exactly the vectors exploited in container breakout attacks, making 'restricted' the only adequate choice for this specific risk.

How to eliminate wrong answers

Option A is wrong because 'privileged' PSS is the least restrictive policy, allowing all capabilities and root access, which would not mitigate breakout risks; 'Warn' mode only alerts but does not block non-compliant pods. Option B is wrong because 'baseline' PSS allows some default capabilities and does not enforce dropping all capabilities or preventing root, and 'Audit' mode only logs violations without enforcement. Option D is wrong because while 'baseline' PSS with 'Enforce' mode blocks some obvious misconfigurations, it still permits containers to run as root and retains default capabilities, leaving significant breakout vectors unaddressed.

413
MCQmedium

After a security incident, you need to restrict which pods can communicate with each other in the 'finance' namespace. You want to allow only pods with label 'app: api' to connect to pods with label 'app: db' on TCP port 5432, and deny all other traffic. Which NetworkPolicy should you create?

A.apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-api-to-db namespace: finance spec: podSelector: matchLabels: app: api ingress: - from: - podSelector: matchLabels: app: db ports: - port: 5432
B.apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-api-to-db namespace: finance spec: podSelector: matchLabels: app: api egress: - to: - podSelector: matchLabels: app: db ports: - port: 5432
C.apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-api-to-db namespace: finance spec: podSelector: matchLabels: app: db ingress: - from: - podSelector: matchLabels: app: api
D.apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-api-to-db namespace: finance spec: podSelector: matchLabels: app: db ingress: - from: - podSelector: matchLabels: app: api ports: - port: 5432
AnswerD

This is the correct policy. It selects the DB pods and applies an ingress rule that allows only traffic from pods with label app: api on TCP port 5432. The presence of any NetworkPolicy selecting a pod makes that pod default-deny for ingress, so all other sources and ports are implicitly blocked. This matches the requirement: only the API can reach the database on the PostgreSQL port, and everything else is denied. The port restriction and podSelector together create a precise allow-list for the database.

Why this answer

It defines a NetworkPolicy that selects pods with label 'app: db' as the target and allows ingress traffic only from pods with label 'app: api' on TCP port 5432. By default, if no NetworkPolicy exists, all traffic is allowed; once a NetworkPolicy selects a pod, all traffic not explicitly allowed is denied. This policy therefore restricts communication to only the intended api-to-db flow on the specified port.

Exam trap

CNCF often tests the direction of traffic flow: candidates mistakenly apply the policy to the source pod (app: api) with an ingress rule, which would control traffic coming into the api pod rather than traffic going to the db pod, or they forget to specify the port, allowing all ports from the allowed source.

How to eliminate wrong answers

Option A is wrong because it selects pods with label 'app: api' and defines an ingress rule from pods with label 'app: db', which would allow db pods to connect to api pods, the reverse of the required direction. Option B is wrong because it defines an egress rule from api pods to db pods, but the question requires restricting which pods can communicate with each other, and egress policies control outbound traffic from the selected pods, not inbound traffic to the db pods; additionally, it does not deny all other traffic because it only affects egress from api pods, leaving ingress to db pods unrestricted. Option C is wrong because it selects db pods and allows ingress from api pods but does not specify the port (5432), thus allowing all ports from api pods, which is too permissive and does not meet the requirement to restrict to TCP port 5432.

414
MCQeasy

Which admission plugin is recommended by the CIS Kubernetes Benchmark to restrict the kubelet's ability to modify nodes?

A.NodeRestriction
B.PodNodeSelector
C.SecurityContextDeny
D.AlwaysPullImages
AnswerA

NodeRestriction limits the kubelet's own credentials so it can only modify its own Node object and the Pods bound to it, satisfying the CIS Benchmark recommendation to restrict kubelet node modification. Without it, a compromised node could alter labels or taints cluster-wide.

Why this answer

The NodeRestriction admission plugin is recommended by the CIS Kubernetes Benchmark to restrict the kubelet's ability to modify nodes. It limits the kubelet's permissions to only modify its own node and its own pods, preventing it from altering other nodes or performing unauthorized operations. This plugin enforces a security boundary by rejecting requests that attempt to modify node labels, taints, or status outside the kubelet's assigned scope.

Exam trap

The trap here is that candidates often confuse admission plugins that control pod security (like SecurityContextDeny or PodNodeSelector) with the specific plugin that restricts kubelet node modification, leading them to pick a security-focused option that does not address the kubelet's API access.

How to eliminate wrong answers

Option B (PodNodeSelector) is wrong because it enforces namespace-level pod node selector constraints, not kubelet node modification restrictions. Option C (SecurityContextDeny) is wrong because it rejects pods with certain security context settings, such as privileged containers, but does not limit kubelet actions on nodes. Option D (AlwaysPullImages) is wrong because it forces image pull policy to Always for every pod, addressing image freshness and security, not kubelet node modification control.

415
MCQeasy

A cluster administrator wants to monitor network traffic between pods for security analysis. Which tool is designed specifically for this purpose and integrates with Kubernetes?

A.Configure Fluentd to collect network logs from each node.
B.Use Prometheus to scrape network metrics from kube-proxy.
C.Run kube-bench to audit network policies.
D.Deploy Cilium with Hubble for network flow visibility.
AnswerD

Cilium operates as a CNI data plane using eBPF, and Hubble builds on it to deliver deep network observability by capturing every TCP, UDP, and ICMP flow between pods, services, and external endpoints. Each flow is enriched with Kubernetes labels and security identities, providing timestamped source/destination IPs, ports, protocols, and byte counts at pod granularity. Because Hubble observes traffic in the kernel without sidecar proxies, it gives complete and low-overhead visibility into actual network behavior, making it the correct choice for this requirement.

Why this answer

D is correct because Cilium, combined with Hubble, is specifically designed to provide deep network flow visibility and monitoring for Kubernetes pods. Hubble leverages eBPF to capture and report network traffic at the kernel level, offering granular observability into pod-to-pod communications, which directly meets the requirement for security analysis of network traffic between pods.

Exam trap

The trap here is that candidates may confuse general monitoring tools (Fluentd, Prometheus) or security auditing tools (kube-bench) with a purpose-built network flow visibility solution like Cilium/Hubble, which is the only option that directly addresses pod-to-pod traffic monitoring for security analysis.

How to eliminate wrong answers

Option A is wrong because Fluentd is a log collector and aggregator, not a network traffic monitoring tool; it collects log files (e.g., from containers or applications) but does not capture or analyze network flows between pods. Option B is wrong because Prometheus scrapes metrics (e.g., from kube-proxy for iptables rules or service endpoints) but does not provide real-time network flow visibility or capture individual packet-level communications between pods. Option C is wrong because kube-bench is a compliance auditor that checks Kubernetes clusters against CIS benchmarks, focusing on configuration security, not on monitoring live network traffic between pods.

416
MCQhard

An OPA/Gatekeeper ConstraintTemplate is defined with the following Rego rule: violation[{"msg": msg}] { container := input.review.object.spec.containers[_] container.securityContext.runAsNonRoot != true msg := "Container must run as non-root" } What happens when a pod is submitted with a container that has runAsNonRoot: true?

A.The pod is admitted but an audit log is generated
B.The pod is admitted
C.The pod is denied with a message
D.The pod is mutated to set runAsNonRoot
AnswerB

For a pod that explicitly sets securityContext.runAsNonRoot: true, the Gatekeeper constraint's violation condition (runAsNonRoot != true) evaluates to false. Since the Rego policy only triggers a denial when a violation is found, no violation exists and the admission request is allowed. Thus the pod is admitted without any message, mutation, or further side effects.

Why this answer

The Rego rule `container.securityContext.runAsNonRoot != true` only triggers a violation when the field is not set to `true`. When `runAsNonRoot: true` is explicitly set, the condition evaluates to `false`, so no violation is generated, and the pod is admitted without any denial or mutation. OPA/Gatekeeper by default enforces constraints by denying admission; it does not mutate resources or generate audit logs unless specifically configured for dry-run or audit mode.

Exam trap

The CKS exam often tests the subtle difference between `!= true` and `== false` in Rego — candidates mistakenly think `!= true` catches only `false` values, but it also catches `null` (missing field), and they forget that an explicit `true` passes the check, leading them to choose denial or mutation options.

How to eliminate wrong answers

Option A is wrong because OPA/Gatekeeper does not generate audit logs for admitted pods unless the constraint is explicitly configured in audit mode (e.g., with `spec.sync` and `spec.match`), and the Rego rule here is a validation rule that either denies or allows; it does not produce audit logs on success. Option C is wrong because the pod is not denied; the violation condition is false when `runAsNonRoot: true`, so no denial message is returned. Option D is wrong because OPA/Gatekeeper is a policy engine that validates and denies, not a mutating webhook; it cannot mutate fields like `runAsNonRoot` — mutation requires a separate MutatingAdmissionWebhook or a mutating Gatekeeper feature (e.g., via `modify` rules) which is not used here.

417
MCQmedium

An administrator wants to use gVisor to sandbox containers in a Kubernetes cluster. Which resource must be created to enable this?

A.RuntimeClass with handler: runsc
B.DaemonSet to install gVisor on nodes
C.PodSecurityPolicy with gVisor enabled
D.SecurityContext with runtime: gvisor
AnswerA

RuntimeClass is the native Kubernetes primitive for selecting a container runtime. The `.handler` field must match the runtime name configured on the kubelet (e.g., `runsc` for gVisor), and pods opt in via `runtimeClassName`. This is the only Kubernetes-native way to direct a pod to run under gVisor's sandboxed `runsc` runtime.

Why this answer

To use gVisor as a container runtime sandbox in Kubernetes, you must create a RuntimeClass resource with the handler set to 'runsc'. This tells the kubelet which runtime handler to use when running pods that reference this RuntimeClass, enabling gVisor's user-space kernel (runsc) to intercept and sandbox system calls.

Exam trap

The CKS exam often tests the distinction between installing a runtime (DaemonSet) and enabling it via a Kubernetes API object (RuntimeClass), leading candidates to confuse node-level setup with cluster-level resource creation.

How to eliminate wrong answers

Option B is wrong because a DaemonSet can install gVisor binaries on nodes, but the actual enablement requires a RuntimeClass to select the runsc handler at pod creation time. Option C is wrong because PodSecurityPolicy (deprecated in 1.21) controls security contexts and admission, not runtime selection; gVisor is not a PSP feature. Option D is wrong because SecurityContext does not have a 'runtime' field; runtime selection is done via RuntimeClass, not via pod security context settings.

418
MCQhard

You are auditing your cluster's supply chain security. You need to generate a Software Bill of Materials (SBOM) for a container image. Which tool should you use?

A.Trivy
B.Kubesec
C.Checkov
D.Syft
AnswerD

Syft is an SBOM generation tool that inspects container image layers and outputs a package inventory in SPDX or CycloneDX formats. It directly satisfies the supply chain audit requirement to produce a Software Bill of Materials, unlike scanners such as Trivy or Grype, which report vulnerabilities rather than catalogue components.

Why this answer

Syft is a CLI tool specifically designed to generate a Software Bill of Materials (SBOM) from container images and filesystems. It uses a pluggable cataloger engine to extract package metadata (e.g., dpkg, RPM, APK, Python, Java) and outputs the SBOM in standard formats like CycloneDX or SPDX, directly addressing the requirement for supply chain security auditing.

Exam trap

Candidates often confuse vulnerability scanning (Trivy) with SBOM generation (Syft), leading them to choose Trivy because it is more widely known, even though Syft is the dedicated tool for producing a Software Bill of Materials.

How to eliminate wrong answers

Option A is wrong because Trivy is a vulnerability scanner that can also produce SBOMs, but its primary purpose is scanning for CVEs, not dedicated SBOM generation; Syft is the specialized tool for this task. Option B is wrong because Kubesec is a static analysis tool for Kubernetes resource manifests (e.g., PodSecurityPolicy, security contexts), not for container image SBOM generation. Option C is wrong because Checkov is a policy-as-code scanner for IaC templates (Terraform, CloudFormation, Kubernetes YAML) and does not extract package-level metadata from container images.

419
Multi-Selectmedium

Which TWO of the following are valid ways to enforce that containers cannot run as root in a Kubernetes cluster? (Select TWO.)

Select 2 answers
A.Create a Gatekeeper Constraint that requires runAsNonRoot
B.Use a NetworkPolicy to block root containers
C.Set the kubelet flag --run-non-root
D.Enable the PodSecurity admission controller with the 'restricted' profile
E.Use a ServiceAccount to restrict root
AnswersA, D

Gatekeeper is a validating admission controller that extends Kubernetes with policies written in OPA Rego. A ConstraintTemplate defines the validation logic (e.g., requiring `runAsNonRoot: true`), and a Constraint then applies that rule to objects such as Pods. Because it evaluates every resource at admission time, it can reject any Pod whose security context allows root—enforcing the policy before the Pod is persisted. This makes it a valid, flexible way to enforce non-root execution, going beyond the built-in PodSecurity profiles.

Why this answer

Gatekeeper, using the Open Policy Agent (OPA) framework, can enforce custom policies via ConstraintTemplates. A Constraint requiring `runAsNonRoot: true` in the Pod security context ensures containers cannot run as root, providing a flexible, admission-time control that works across all namespaces.

Exam trap

The exam often tests the distinction between network-layer controls (NetworkPolicy) and identity objects (ServiceAccount) versus admission controllers that enforce security contexts, leading candidates to overestimate the scope of NetworkPolicies or ServiceAccounts.

420
MCQeasy

Which command is used to sign a container image with Cosign?

A.cosign attest
B.cosign sign
C.cosign generate
D.cosign verify
AnswerB

cosign sign is the exact command that generates a digital signature for a container image, producing a signature payload stored in an OCI registry (typically as an image tag suffixed with `-sig`). It signs the image digest using a key pair, and the resulting signature can later be verified with `cosign verify`. This command is the core mechanism for asserting the identity of the signer and ensuring the image's content has not been tampered with.

Why this answer

The `cosign sign` command is used to sign container images and other artifacts, creating a digital signature that is stored alongside the image in the registry. This signature can later be verified with `cosign verify` to ensure the image's integrity and origin. The other options serve different purposes: `cosign attest` attaches an in-toto attestation, `cosign generate` creates key pairs, and `cosign verify` checks signatures.

Exam trap

A common pitfall on the CKS exam is confusing `cosign sign` (which creates a signature) with `cosign attest` (which creates an in-toto attestation) or `cosign verify` (which checks a signature). Candidates must remember that `sign` is the action that produces the cryptographic signature, while `verify` and `attest` are separate operations.

How to eliminate wrong answers

Option A is wrong because `cosign attest` is used to create an in-toto attestation (a signed statement about the image's build process or metadata), not to sign the image itself. Option C is wrong because `cosign generate` generates a key pair for signing, but does not perform the signing operation. Option D is wrong because `cosign verify` is used to validate an existing signature, not to create one.

421
MCQhard

A cluster uses Kubernetes v1.24 with Pod Security Admission enabled. The cluster administrator wants to enforce that all pods in the 'production' namespace run with the 'restricted' policy level, but some existing deployments use privileged containers. Which approach ensures that only new pods violating the policy are rejected, while existing pods continue to run?

A.Patch existing deployments to remove privileged containers, then add the label 'pod-security.kubernetes.io/enforce=restricted' to the namespace.
B.Add the namespace label 'pod-security.kubernetes.io/enforce=restricted' and leave existing pods unchanged; new pods violating the policy will be rejected.
C.Create a PodSecurityPolicy that restricts privileged containers and bind it to all service accounts in the namespace.
D.Set the namespace label 'pod-security.kubernetes.io/enforce=restricted' and use the 'inform' mode to allow existing pods.
AnswerB

Setting the namespace label 'pod-security.kubernetes.io/enforce=restricted' is the correct admission-control mechanism in v1.24: it makes the built-in Pod Security Admission controller reject any new pod that fails the restricted profile. Existing pods are exempt because admission only runs when a pod is created or updated, so running workloads are left untouched. The restricted profile specifically disallows privileged containers, so all future deployments in that namespace must conform or be rejected.

Why this answer

Pod Security Admission (PSA) in Kubernetes v1.24 enforces policies via namespace labels. Setting `pod-security.kubernetes.io/enforce=restricted` on the 'production' namespace will reject any new pod that violates the restricted policy, but existing pods are not re-evaluated and continue running. This behavior is by design: PSA evaluates pods at creation or update time, not retroactively, so existing workloads are unaffected.

Exam trap

The trap here is that candidates confuse Pod Security Admission with the deprecated PodSecurityPolicy, or assume that setting an enforce label will retroactively terminate existing pods, when in fact PSA only applies to new or updated pods.

How to eliminate wrong answers

Option A is wrong because patching existing deployments to remove privileged containers is unnecessary and contradicts the requirement to let existing pods continue running; PSA does not require modifying existing workloads. Option C is wrong because PodSecurityPolicy (PSP) was deprecated in Kubernetes v1.21 and removed in v1.25, and the question specifies v1.24 with Pod Security Admission enabled, making PSP irrelevant and non-functional. Option D is wrong because setting the label to 'enforce=restricted' already enforces the policy; 'inform' mode would only log violations without rejecting pods, which does not meet the requirement to reject new violating pods.

422
MCQmedium

An administrator runs kube-bench and receives a failing result for CIS control 1.1.1. What does this control typically check?

A.That the API server pod specification file permissions are set to 644 or more restrictive
B.That etcd is using TLS
C.That the API server audit log path is configured
D.That anonymous authentication is disabled on the API server
AnswerA

The failing kube-bench result corresponds to control 1.1.1, which checks that the API server pod specification file (typically /etc/kubernetes/manifests/kube-apiserver.yaml) has permissions set to 644 or more restrictive. If this file is group- or world-writable, a local attacker could modify the manifest to inject malicious flags, replace certificates, or alter the API server's configuration without authentication. Kube-bench flags this as a failure when the file mode allows write access beyond the owner. This is exactly the check being reported.

Why this answer

CIS control 1.1.1 specifically checks that the API server pod specification file (typically /etc/kubernetes/manifests/kube-apiserver.yaml) has permissions set to 644 or more restrictive (e.g., 600 or 640). This ensures that only authorized users (root or the kube-apiserver process) can read or modify the file, preventing unauthorized changes to critical API server configuration.

Exam trap

CNCF often tests candidates' ability to map CIS control numbers to their exact checks, so the trap here is that candidates confuse control 1.1.1 (file permissions) with other common API server hardening controls like TLS, audit logging, or authentication settings.

How to eliminate wrong answers

Option B is wrong because etcd TLS configuration is covered under a different CIS control (e.g., 2.1 or 2.2), not 1.1.1. Option C is wrong because API server audit log path configuration is checked under CIS control 1.2.1 or similar audit-related controls, not 1.1.1. Option D is wrong because disabling anonymous authentication on the API server is a separate control (e.g., 1.2.3 or 1.2.4), not part of control 1.1.1 which focuses on file permissions.

423
Multi-Selecteasy

Which TWO of the following are recommended practices for securing the Kubernetes API server? (Select TWO)

Select 2 answers
A.Set --cors-allowed-origins=* for easy access.
B.Disable TLS to improve performance.
C.Enable audit logging.
D.Set --insecure-port=8080 to allow non-TLS access.
E.Set --anonymous-auth=false.
AnswersC, E

Enabling audit logging on the API server records a chronological, policy-filtered set of metadata and request/response details for every administrative and user action. These logs give operators visibility into who performed which operation, when it happened, and whether it was authorized, enabling rapid detection of anomalous behavior, insider threats, or attempted privilege escalation. Audit logs also serve as forensic evidence for incident response and are a prerequisite for satisfying compliance frameworks that demand traceability of cluster changes.

Why this answer

Enabling audit logging on the API server records all requests to the cluster, providing an immutable record for security monitoring, incident response, and compliance. Audit logs are essential for detecting unauthorized access attempts, misconfigurations, and policy violations, and are a core requirement for Kubernetes security hardening.

Exam trap

CNCF often tests the misconception that disabling security features (like TLS or authentication) improves performance or simplifies access, when in fact these actions directly violate the principle of defense in depth and are explicitly discouraged in Kubernetes security best practices.

424
MCQeasy

You are a platform engineer for a financial services company. Your Kubernetes cluster runs on bare-metal nodes with Ubuntu 20.04 and uses containerd as the container runtime. The cluster is in production with 50 worker nodes. A recent security scan shows that all nodes have the 'overlayfs' kernel module loaded, which is not required. The security policy requires minimal kernel modules. You need to disable the module without disrupting running containers. What should you do?

A.Restart containerd on each node to unload the module
B.Add 'blacklist overlayfs' to /etc/modprobe.d/ and run 'update-initramfs -u', then reboot nodes one by one after draining
C.Use 'rmmod overlayfs' after stopping all containers
D.Use 'modprobe -r overlayfs' on each node immediately
AnswerB

Adding 'blacklist overlayfs' to /etc/modprobe.d/ prevents the kernel's module autoload mechanism from loading the module during normal boot, but because overlayfs is often pulled in by the initramfs or as a dependency of another module, 'update-initramfs -u' is required to rebuild the initial RAM disk without it. Draining each node before reboot ensures that all pods are gracefully rescheduled to other nodes, so the reboot itself does not interrupt workloads. This is the only persistent and non-disruptive method to disable the module across reboots.

Why this answer

It permanently disables the overlayfs kernel module by adding it to the modprobe blacklist and updating the initramfs, ensuring the module is not loaded on subsequent boots. Draining and rebooting nodes one by one avoids disrupting running containers, as pods are rescheduled to other nodes before the node is taken offline. This approach aligns with the security policy of minimizing kernel modules while maintaining production uptime.

Exam trap

CNCF often tests the misconception that unloading a kernel module with 'rmmod' or 'modprobe -r' is safe while containers are running, but in reality, overlayfs is actively used by the container runtime and cannot be removed without causing filesystem errors or container crashes.

How to eliminate wrong answers

Option A is wrong because restarting containerd does not unload kernel modules; containerd is a user-space runtime that uses overlayfs, but unloading the module requires kernel-level operations, not a service restart. Option C is wrong because 'rmmod overlayfs' will fail if the module is in use by any container or filesystem, and stopping all containers on a node would disrupt running workloads, violating the requirement to avoid disruption. Option D is wrong because 'modprobe -r overlayfs' immediately unloads the module, which will fail if any process (including containerd or running containers) is using overlayfs, and even if it succeeds, it could cause container failures or filesystem errors without proper draining.

425
Multi-Selecteasy

Which TWO of the following are tools that can be used to generate an SBOM for a container image?

Select 2 answers
A.Trivy
B.Cosign
C.Syft
D.Clair
E.Kubesec
AnswersA, C

Trivy is a versatile security scanner that can also generate SBOMs through its built-in subcommands such as `trivy image --format cyclonedx` and `trivy fs --format spdx`. It enumerates installed packages and libraries from image layers and filesystems using multiple package managers and language ecosystems, then serializes the discovered components into an SBOM document. While Trivy is commonly known for vulnerability scanning, its ability to produce SBOMs in standard formats makes it a correct answer for this question.

Why this answer

Trivy is a comprehensive vulnerability scanner that can also generate Software Bill of Materials (SBOM) for container images. It supports multiple output formats such as CycloneDX and SPDX, making it a valid tool for SBOM generation. Syft is specifically designed to generate SBOMs from container images and filesystems, producing output in formats like CycloneDX, SPDX, and Syft's own JSON format.

Both tools are widely used in supply chain security workflows.

Exam trap

The CKS exam often tests the distinction between tools that generate SBOMs (like Syft and Trivy) versus tools that consume, sign, or attach SBOMs (like Cosign), causing candidates to confuse signing capabilities with SBOM generation.

426
MCQmedium

A security engineer wants to integrate image scanning into a CI/CD pipeline. They are using a tool that can scan the filesystem of the build context before building the image. Which tool is best suited for this purpose?

A.Trivy (trivy fs)
B.Kubesec
C.Notary
D.Cosign
AnswerA

Trivy's trivy fs command scans a filesystem directory, such as a Docker build context, for known vulnerabilities by inspecting OS package manager files and language-specific lock files. It matches installed versions against comprehensive vulnerability databases (e.g., NVD, GHSA) and produces a report without requiring a built image. This makes it ideal for shifting security left in CI/CD pipelines, catching vulnerable dependencies before they are baked into a container image.

Why this answer

Trivy's `fs` subcommand scans the filesystem of a build context (directory) for vulnerabilities and misconfigurations before the container image is built. This allows the security engineer to catch issues early in the CI/CD pipeline, such as vulnerable application dependencies or insecure configurations in Dockerfiles, without needing a built image. Trivy is purpose-built for this filesystem scanning use case, making it the correct choice.

Exam trap

The CKS exam often tests the distinction between tools that scan build context filesystems (like Trivy fs) versus tools that scan built container images (like Trivy image or Grype), causing candidates to confuse the pipeline stage where each tool applies.

How to eliminate wrong answers

Option B is wrong because Kubesec is a static analysis tool for Kubernetes resource manifests (YAML/JSON), not for scanning filesystem contents or build contexts. Option C is wrong because Notary is a tool for signing and verifying container image metadata (using TUF framework), not for scanning filesystems. Option D is wrong because Cosign is a tool for signing and verifying container image signatures (part of Sigstore), not for scanning build context filesystems.

427
MCQeasy

Which Pod Security Standard level allows the most relaxed security controls?

A.restricted
B.default
C.baseline
D.privileged
AnswerD

Privileged is the most relaxed Pod Security Standard level, imposing virtually no security restrictions on pods. It allows privileged containers, all Linux capabilities, host namespaces (network, PID, IPC), arbitrary seccomp or AppArmor overrides, and ephemeral containers, making it suitable only for system-level or trusted workloads. This design intentionally matches the behavior of running with no Pod Security admission restrictions, hence it is the correct answer.

Why this answer

The privileged Pod Security Standard (PSS) level imposes no restrictions on pod behavior, allowing unrestricted access to host resources, capabilities, and security contexts. This makes it the most relaxed level, as it does not enforce any of the constraints found in baseline or restricted profiles.

Exam trap

The trap here is that candidates may confuse 'default' with a valid PSS level, or assume 'baseline' is the most relaxed because it sounds less restrictive than 'restricted', but privileged explicitly allows all controls without limitation.

How to eliminate wrong answers

Option A is wrong because restricted is the most restrictive PSS level, enforcing strict security contexts, read-only root filesystems, and dropping all capabilities. Option B is wrong because 'default' is not a valid Pod Security Standard level; the three defined levels are privileged, baseline, and restricted. Option C is wrong because baseline applies a moderate set of restrictions (e.g., preventing hostPID, hostNetwork, and privileged containers) but is less relaxed than privileged.

428
MCQhard

You want to run a workload in a sandboxed container using gVisor. You have created a RuntimeClass named 'gvisor' that references the 'runsc' handler. Which of the following Pod specs correctly uses this RuntimeClass?

A.apiVersion: v1 kind: Pod metadata: name: sandbox-pod annotations: runtimeClass: gvisor spec: containers: - name: app image: nginx
B.apiVersion: v1 kind: Pod metadata: name: sandbox-pod spec: runtimeClassName: gvisor containers: - name: app image: nginx
C.apiVersion: v1 kind: Pod metadata: name: sandbox-pod spec: nodeSelector: runtime: gvisor containers: - name: app image: nginx
D.apiVersion: v1 kind: Pod metadata: name: sandbox-pod spec: runtimeClass: name: gvisor containers: - name: app image: nginx
AnswerB

Setting runtimeClassName: gvisor in the pod spec instructs the kubelet to select the gvisor RuntimeClass, which maps to the runsc handler and runs containers through gVisor's user-space kernel for sandboxing. This is the correct field; nodeName or annotations would not engage the sandbox runtime.

Why this answer

The `runtimeClassName` field in the Pod spec is the standard Kubernetes API field used to specify a RuntimeClass for a Pod. The RuntimeClass named 'gvisor' must be defined in the cluster with a handler 'runsc', and setting `runtimeClassName: gvisor` in the Pod spec instructs the kubelet to use the gVisor runtime (runsc) to run the containers in a sandboxed environment, minimizing microservice vulnerabilities.

Exam trap

The CNCF-CKS exam often tests the distinction between `runtimeClassName` (a flat string field) and incorrect nested or annotation-based approaches, as candidates may confuse it with other Pod spec fields like `nodeSelector` or `annotations`.

How to eliminate wrong answers

Option A is wrong because it uses an annotation `runtimeClass: gvisor` instead of the proper `runtimeClassName` field; annotations are not processed by the kubelet for runtime selection. Option C is wrong because `nodeSelector` selects nodes based on labels, not runtime classes; it does not invoke gVisor and would run the container with the default runtime. Option D is wrong because `runtimeClass` is not a nested object with a `name` field; the correct syntax is a flat string field `runtimeClassName`.

429
Multi-Selectmedium

Which TWO of the following are best practices for securing the software supply chain in a CI/CD pipeline?

Select 2 answers
A.Use the 'latest' tag for base images to get the newest features
B.Store sensitive credentials directly in the pipeline YAML file
C.Scan all container images for known vulnerabilities before deployment
D.Ignore critical CVEs if they are in development environments
E.Sign container images to ensure integrity and authenticity
AnswersC, E

Scanning every container image for known vulnerabilities before deployment is essential because it maps the image's package and dependency versions against public CVE databases such as NVD and identifies exploitable flaws before they reach runtime. This proactive step lets you choose a patched base image, add remediation layers, or reject the image entirely, thereby minimizing the attack surface. Automated scanners like Trivy, Clair, or Grype inserted into the CI/CD pipeline provide continuous assurance and make security part of the deployment workflow rather than an afterthought.

Why this answer

Scanning container images for known vulnerabilities (e.g., using Trivy, Clair, or Grype) before deployment is a fundamental supply chain security practice. It ensures that only images free of critical or high-severity CVEs are promoted to production, reducing the attack surface and preventing exploitation of known flaws.

Exam trap

The CKS exam often tests the misconception that 'latest' tags are safe for CI/CD pipelines, but the trap is that they undermine reproducibility and security, and the exam expects you to recognize that immutable, versioned tags (e.g., SHA256 digests) are the correct practice.

430
MCQmedium

A container runs with the default seccomp profile but the application needs to make a specific syscall that is blocked. Which approach should be taken?

A.Use the RuntimeDefault profile and add capabilities
B.Change the seccomp profile to another runtime default
C.Set seccompProfile to Unconfined
D.Create a custom seccomp profile that allows the syscall and apply it via type: Localhost
AnswerD

The correct approach is to create a custom seccomp profile, a JSON file with a syscall allowlist that explicitly permits the missing syscall while retaining the default deny/safe list for all other syscalls. Place the profile on the node under the kubelet seccomp root, normally /var/lib/kubelet/seccomp, then reference it in the pod spec as securityContext.seccompProfile.type: Localhost with localhostProfile set to the filename. This gives fine-grained control and keeps the container secure, only widening the filter exactly where needed. It is the recommended way to handle seccomp exceptions.

Why this answer

The default seccomp profile (RuntimeDefault) blocks a specific set of syscalls for security. When an application requires a blocked syscall, the proper approach is to create a custom seccomp profile that explicitly allows that syscall, then apply it to the container via `seccompProfile.type: Localhost` and reference the profile file. This maintains security by only relaxing the necessary restriction, rather than disabling the profile entirely.

Exam trap

CNCF often tests the misconception that capabilities can override seccomp restrictions, but in reality, seccomp and capabilities are independent security mechanisms; a blocked syscall cannot be unblocked by adding capabilities.

How to eliminate wrong answers

Option A is wrong because capabilities control privileged operations (e.g., CAP_SYS_ADMIN), not syscall filtering; adding capabilities does not unblock a syscall blocked by seccomp. Option B is wrong because there is only one runtime default profile (RuntimeDefault) in containerd/Docker; changing to another runtime default is not possible as it is the same profile. Option C is wrong because setting seccompProfile to Unconfined disables all seccomp filtering, which is overly permissive and violates the principle of least privilege; it should only be used when absolutely necessary and after careful consideration.

431
MCQmedium

You have created a ValidatingWebhookConfiguration to reject pods without resource limits. When you try to create a pod without limits, it is created successfully. What is the most likely reason?

A.The webhook is not matching the namespace labels
B.The webhook service is not running or is unreachable
C.The webhook is configured with failurePolicy: Fail
D.The pod is being created by a controller like a Deployment
AnswerB

An unreachable webhook service causes the API server's admission call to fail. With failurePolicy set to Ignore (the default), the API server permits the request, so the pod is created despite the ValidatingWebhookConfiguration. This satisfies the stem's constraint: rejection never occurs because the webhook cannot be evaluated.

Why this answer

The most likely reason a pod without resource limits is created successfully despite a ValidatingWebhookConfiguration is that the webhook service itself is not running or is unreachable. When the API server cannot contact the webhook endpoint, the default behavior (failurePolicy: Ignore) allows the request to proceed, so the pod is created without validation. If the webhook were functioning correctly, it would reject the pod; thus, the failure to reject indicates a connectivity or service issue.

Exam trap

Candidates may incorrectly assume the ValidatingWebhookConfiguration is misconfigured (e.g., missing objectSelector or wrong failurePolicy) when the actual issue is that the webhook backend service is unreachable. In Kubernetes, if the API server cannot reach the webhook server, the failurePolicy (default Ignore) allows the pod creation, so the pod passes through without validation. This is a common pitfall where the webhook service itself is not running or not accessible, rather than a configuration error.

How to eliminate wrong answers

Option A is wrong because the question does not mention namespace labels or any namespaceSelector in the webhook configuration; even if labels were mismatched, the webhook would simply not be invoked for that namespace, but the pod would still be created without limits — however, the most likely reason given the scenario is a service issue, not a label mismatch. Option C is wrong because failurePolicy: Fail would cause the API server to reject the pod if the webhook is unreachable, which contradicts the pod being created successfully; the default failurePolicy is Ignore, which allows the pod through when the webhook is down. Option D is wrong because controllers like Deployments still go through the same admission webhook process; the webhook would reject the pod regardless of whether it is created directly or via a controller.

432
MCQeasy

Which of the following is a BEST practice for container images to reduce the attack surface?

A.Use minimal base images like distroless
B.Use the 'latest' tag
C.Include debugging tools in the image
D.Run containers as root user
AnswerA

Distroless images ship only the application and its runtime dependencies, omitting package managers, shells and utilities. This directly shrinks the attack surface by removing binaries an attacker could exploit after gaining a foothold, satisfying the stem's requirement for minimal container images.

Why this answer

Distroless images contain only the application and its runtime dependencies, omitting package managers, shells, and other utilities that could be exploited. This drastically reduces the number of CVEs present in the image and limits the tools available to an attacker who gains code execution inside the container.

Exam trap

The CKS exam often tests the misconception that 'latest' is a safe default or that debugging tools are harmless because they are only for development, when in fact both practices increase the attack surface in production.

How to eliminate wrong answers

Option B is wrong because using the 'latest' tag introduces unpredictability; the image may change without explicit version control, potentially pulling a newer, untested version with unknown vulnerabilities. Option C is wrong because including debugging tools (e.g., curl, netcat, bash) provides attackers with utilities to perform reconnaissance, lateral movement, or data exfiltration if the container is compromised. Option D is wrong because running containers as root user grants the container process full privileges within its user namespace, increasing the risk of container escape via kernel vulnerabilities or misconfigured capabilities.

433
MCQmedium

An administrator wants to ensure that a service account used by a deployment cannot automatically mount its token. Which field should be set to `false` in the Pod spec?

A.mountServiceAccountToken
B.disableTokenMount
C.automountServiceAccountToken
D.automountToken
AnswerC

Setting `automountServiceAccountToken` to `false` in the Pod spec prevents the kubelet from automatically projecting the service account’s token into the container filesystem at `/var/run/secrets/kubernetes.io/serviceaccount`. This satisfies the administrator’s constraint to disable automatic token mounting for the deployment’s service account, reducing the risk of token exposure if the container is compromised.

Why this answer

The `automountServiceAccountToken` field in the Pod spec controls whether the service account token is automatically mounted into the container. Setting this field to `false` prevents the automatic mounting of the token, which is a security best practice to reduce the attack surface for compromised pods. This field can be set at the Pod level or overridden at the ServiceAccount level.

Exam trap

The trap here is that candidates often confuse the field name with similar-sounding but incorrect options like `automountToken` or `disableTokenMount`, or they mistakenly think `mountServiceAccountToken` is the correct field, when the exact API field is `automountServiceAccountToken`.

How to eliminate wrong answers

Option A is wrong because `mountServiceAccountToken` is not a valid field in the Pod spec; the correct field name is `automountServiceAccountToken`. Option B is wrong because `disableTokenMount` is not a recognized Kubernetes field; no such field exists in the Pod or ServiceAccount API. Option D is wrong because `automountToken` is an incorrect abbreviation; the actual field name is `automountServiceAccountToken`, which must be spelled out exactly as defined in the Kubernetes API.

434
MCQhard

An organization uses Kubernetes with multiple namespaces and wants to ensure that containers running as non-root cannot escalate to root via setuid binaries. Which combination of security contexts and Pod Security Standards achieves this?

A.Use an AppArmor profile to block setuid syscalls.
B.Apply the 'restricted' Pod Security Standard at the namespace level.
C.Set 'securityContext.runAsUser: 1000' on each pod spec.
D.Apply the 'baseline' Pod Security Standard with 'seccompProfile: RuntimeDefault'.
AnswerB

The 'restricted' Pod Security Standard (PSS) is the most stringent namespace-level admission policy. It requires runAsNonRoot: true, sets allowPrivilegeEscalation: false, prohibits privileged containers, and enforces a seccomp profile of RuntimeDefault or Localhost. Applying this at namespace level ensures every pod is evaluated by the PodSecurity admission controller, directly blocking privileged escalation and setuid-based uid transitions.

Why this answer

The 'restricted' Pod Security Standard (PSS) enforces the strongest set of security constraints, including preventing containers from running as root and disallowing privilege escalation. Specifically, it requires `securityContext.allowPrivilegeEscalation: false` and prohibits running as root, which directly blocks escalation via setuid binaries. Applying this standard at the namespace level ensures all pods in that namespace inherit these controls, meeting the requirement.

Exam trap

CNCF often tests the misconception that simply running as a non-root user (e.g., `runAsUser: 1000`) is sufficient to prevent privilege escalation, but without `allowPrivilegeEscalation: false`, setuid binaries can still be exploited to gain root.

How to eliminate wrong answers

Option A is wrong because AppArmor profiles can block specific syscalls, but they are not the standard Kubernetes-native mechanism for preventing privilege escalation via setuid binaries; the question specifically asks for a combination of security contexts and Pod Security Standards, not a third-party tool. Option C is wrong because setting `runAsUser: 1000` only changes the user ID but does not prevent the container from using setuid binaries to escalate to root; it still allows privilege escalation unless `allowPrivilegeEscalation: false` is also set. Option D is wrong because the 'baseline' PSS does not enforce `allowPrivilegeEscalation: false`; it only prevents known privilege escalation paths like host namespaces but allows setuid binaries, and `seccompProfile: RuntimeDefault` alone does not block setuid escalation.

435
MCQmedium

An administrator wants to run a container that requires the SYS_TIME capability. Which field should be used in the securityContext to add this capability?

A.capabilities.add
B.privileged: true
C.allowPrivilegeEscalation: true
D.capabilities.drop
AnswerA

The `capabilities.add` field in a container's securityContext is the precise mechanism for granting individual Linux capabilities, such as NET_ADMIN or SYS_TIME, to a specific container without affecting the host or other containers. By explicitly adding only the required capabilities, the container runs with the least privilege necessary, adhering to the principle of least privilege. This field accepts a list of capability names, which are then unioned with the default capability set of the container runtime.

Why this answer

The `capabilities.add` field in the `securityContext` is specifically designed to add Linux capabilities (such as `SYS_TIME`) to a container without granting full root privileges. This follows the principle of least privilege, allowing only the required capability to modify the system clock.

Exam trap

The trap here is that candidates often confuse `privileged: true` (which grants all capabilities but is overly permissive) with the more precise `capabilities.add` approach, or they mistakenly think `allowPrivilegeEscalation` is related to adding capabilities.

How to eliminate wrong answers

Option B is wrong because `privileged: true` grants all capabilities (including SYS_TIME) but also disables all security restrictions, which is excessive and violates the principle of least privilege. Option C is wrong because `allowPrivilegeEscalation: true` controls whether a process can gain more privileges than its parent (e.g., via setuid binaries), not the addition of specific capabilities. Option D is wrong because `capabilities.drop` is used to remove capabilities from the default set, not to add them.

436
Multi-Selectmedium

Which TWO of the following are best practices for securing the container supply chain? (Select 2)

Select 2 answers
A.Disable image pull secrets to reduce complexity
B.Scan container images for vulnerabilities
C.Hardcode secrets in the Dockerfile for convenience
D.Use minimal base images like Alpine or distroless
E.Run containers as root to simplify permissions
AnswersB, D

Scanning container images for known vulnerabilities with tools like Trivy, Clair, or Grype is a critical proactive security control. It identifies CVEs in base images and application dependencies before deployment, allowing teams to patch or choose alternative images. Integrating scanning into a CI/CD pipeline ensures that only trusted images reach the cluster, reducing the risk of exploiting known weaknesses.

Why this answer

Using minimal base images reduces the attack surface, and scanning images for vulnerabilities helps identify and fix security issues before deployment.

437
Multi-Selectmedium

Which TWO of the following are valid ways to restrict access to the Kubernetes API server?

Select 2 answers
A.Use static token file
B.Use webhook token authentication
C.Enable NodeRestriction admission plugin
D.Configure RBAC authorization
E.Enable anonymous access
AnswersB, D

Webhook token authentication offloads token validation to an external webhook service, such as an OIDC provider, custom authentication server, or policy engine. When a user presents a token, the API server sends a TokenReview to the webhook endpoint and applies the returned status, allowing dynamic validation, immediate revocation, and integration with enterprise SSO. This is a secure and flexible authentication method that can be combined with RBAC to enforce fine-grained authorization after a user’s identity is reliably established.

Why this answer

Webhook token authentication (Option B) is a valid method to restrict API server access because it delegates token validation to an external service via a webhook, allowing custom authentication logic. This is a supported authentication strategy in Kubernetes, enabling fine-grained control over who can access the API server.

Exam trap

CNCF often tests the distinction between authentication (who you are) and authorization (what you can do), so candidates may confuse RBAC (authorization) with authentication mechanisms like webhook tokens, but the question asks for ways to 'restrict access,' which includes both authentication and authorization controls.

438
Multi-Selecteasy

You are auditing a cluster's supply chain security. You find that many pods are running images from public registries without any pinning or verification. Which TWO actions would most effectively reduce the risk of pulling malicious images?

Select 2 answers
A.Configure all deployments to use image digests instead of tags.
B.Set up a private registry proxy that mirrors approved public images and disable direct access to public registries via containerd configuration.
C.Implement RBAC to restrict which users can create pods.
D.Enforce PodSecurityStandard baseline or restricted to block privileged containers.
E.Apply a network policy that blocks egress traffic to public registries.
AnswersA, B

Pinning images to content-addressable digests (e.g., sha256:...) makes the container runtime pull the exact manifest that was vetted at admission time, because tags are mutable references that can be overwritten in a registry. A tag like :latest may be shifted to a compromised build, whereas a digest is a hash of the image manifest, and any change to the image content alters that hash. This prevents tag-based mutation, typo-squatting, and stale cached pulls, and it is the foundation for verifying image signatures and provenance attestations.

Why this answer

Using image digests (e.g., `nginx@sha256:abc123...`) pins the image to an immutable content hash, ensuring that the exact same image is pulled every time, even if the tag is updated to a malicious version. This prevents tag-mutation attacks where an attacker replaces a benign image tag with a compromised one. Digests are verified by the container runtime (containerd) against the registry's manifest, providing cryptographic assurance of image integrity.

Exam trap

CNCF often tests the distinction between runtime security controls (PodSecurityStandards, network policies) and supply chain controls (image pinning, registry proxies), and candidates mistakenly think blocking egress or restricting pod creation mitigates the risk of pulling malicious images, when those controls do not affect the image pull process itself.

439
Multi-Selectmedium

Which two of the following are best practices for securing a CI/CD pipeline that builds and deploys container images? (Select TWO.)

Select 2 answers
A.Scan container images for vulnerabilities in the pipeline
B.Store secrets as environment variables in the pipeline configuration
C.Sign container images after building them
D.Run the build process as root to avoid permission issues
E.Grant all permissions to the pipeline service account to avoid failures
AnswersA, C

Scanning images in the pipeline catches known CVEs in base layers and dependencies before deployment, satisfying the stem's requirement to secure the build stage. This shifts vulnerability detection left, so flawed artefacts never reach the registry or cluster.

Why this answer

Option A is correct because integrating automated image vulnerability scanning (e.g., Trivy, Clair, or Grype) into the pipeline catches known CVEs in base images and dependencies before the image is pushed or deployed, enabling fail-fast remediation. Option C is correct because signing images after building them (e.g., with Cosign/Notation using Sigstore or Docker Content Trust) establishes provenance and integrity, allowing admission controllers to verify signatures before deployment and preventing tampered or unauthorized images from running. Option B is not a best practice because secrets stored as plaintext environment variables in pipeline configuration can leak through logs, build artifacts, or repository access; a dedicated secrets manager (HashiCorp Vault, AWS Secrets Manager) or OIDC-based short-lived credentials should be used instead.

Option D is wrong because running builds as root violates least privilege and increases the blast radius of a compromised build step; rootless builds (e.g., Buildah, Kaniko, or Docker rootless mode) are preferred. Option E is wrong because granting the pipeline service account all permissions violates least privilege and dramatically expands the impact of a supply-chain compromise; scoped, minimal RBAC roles should be assigned per stage.

Exam trap

The CKS exam often tests the distinction between 'best practice' and 'common but insecure shortcut' — candidates may mistakenly think storing secrets as environment variables is acceptable because it works, but the exam expects knowledge of secure alternatives like vault or encrypted CI/CD variables.

440
MCQmedium

Which flag must be set on the API server to enable audit logging?

A.--audit-log-maxage=30
B.--audit-log-format=json
C.--audit-log-path=/var/log/audit.log
D.--audit-policy-file=/etc/kubernetes/audit-policy.yaml
AnswerC

This flag is the essential switch that activates the file-based audit logging backend on the kube-apiserver. By specifying a destination file path (e.g., /var/log/audit.log), the API server persists audit events to disk. While an audit policy file determines which events are captured, without this flag no audit log entries are written at all.

Why this answer

The `--audit-log-path` flag is the mandatory parameter that enables audit logging in the kube-apiserver. Without specifying a file path for the audit log, the API server will not write any audit events, even if other audit-related flags are set. This flag tells the API server where to persist the audit log entries, effectively activating the audit logging feature.

Exam trap

The trap here is that candidates often assume setting the audit policy file (`--audit-policy-file`) alone enables auditing, but without `--audit-log-path` the API server does not write any audit logs, making the policy effectively useless.

How to eliminate wrong answers

Option A is wrong because `--audit-log-maxage=30` only controls the maximum number of days to retain old audit log files; it does not enable audit logging itself. Option B is wrong because `--audit-log-format=json` specifies the output format of the audit log (e.g., JSON or legacy format) but does not turn on audit logging. Option D is wrong because `--audit-policy-file` defines the rules for which events to audit, but without `--audit-log-path` the API server will not write any audit log output, making the policy file ineffective.

441
MCQeasy

Which of the following is a best practice for storing sensitive data like passwords in Kubernetes?

A.Store them in ConfigMaps
B.Store them in Secrets and mount them as volumes
C.Store them as environment variables in the Pod spec
D.Store them as labels on Pods
AnswerB

Storing Secrets and mounting them as volumes is a best practice because this method exposes data to the container as files on a filesystem, avoiding leakage through environment variables or process listings. Mounted Secrets support file-level permissions (e.g., read-only) and can be updated in place, allowing applications to pick up changes without redeployment. Additionally, the use of Secrets with volume mounts enables fine-grained RBAC controls and integrates with etcd encryption for Secrets, providing defense in depth for sensitive data.

Why this answer

Kubernetes Secrets are designed to store sensitive data such as passwords, API keys, and certificates. Mounting a Secret as a volume ensures the data is written to a tmpfs in-memory filesystem (not to disk), reducing the risk of exposure via host filesystem access. This approach also avoids leaking secrets through environment variable dumps or logs, and supports automatic rotation when the Secret is updated.

Exam trap

A common trap is believing that environment variables are safe for secrets because they are 'not written to disk', but they are exposed via /proc/<pid>/environ, appear in logs, crash dumps, and can be read by any process with access to the container's environment.

How to eliminate wrong answers

Option A is wrong because ConfigMaps store data in plaintext and are intended for non-sensitive configuration, not secrets; they lack encryption at rest by default and are often logged or exposed in etcd snapshots. Option C is wrong because storing secrets as environment variables in the Pod spec makes them visible in the container's environment, accessible via /proc/self/environ, and can be leaked in logs or debugging tools; they also cannot be rotated without Pod restart. Option D is wrong because labels on Pods are metadata used for selection and organization, not for storing sensitive data; they are visible in API responses and logs, and are not encrypted.

442
MCQmedium

An administrator needs to enforce the restricted Pod Security Standard on a namespace 'secure-ns'. Which kubectl command should they use?

A.kubectl label namespace secure-ns pod-security.kubernetes.io/enforce=restricted
B.kubectl label namespace secure-ns security=restricted
C.kubectl create podsecuritypolicy restricted -n secure-ns
D.kubectl annotate namespace secure-ns pod-security.kubernetes.io/enforce=restricted
AnswerA

Labelling the namespace with the enforce label makes the Pod Security admission controller reject any pod violating the restricted profile at creation time. This satisfies the requirement to enforce, rather than merely warn or audit, the restricted standard namespace-wide.

Why this answer

The Pod Security Standards (PSS) are enforced via labels on namespaces, using the key `pod-security.kubernetes.io/enforce` with the value `restricted`. This instructs the built-in Pod Security Admission controller to reject any pod that violates the restricted profile in the `secure-ns` namespace.

Exam trap

The trap here is that candidates confuse labels with annotations or think that the old `PodSecurityPolicy` API is still the correct mechanism, but the CKS exam tests the modern Pod Security Standards via namespace labels.

How to eliminate wrong answers

Option B is wrong because `security=restricted` is not a recognized label for Pod Security Standards; the correct label key is `pod-security.kubernetes.io/enforce`. Option C is wrong because `PodSecurityPolicy` (PSP) is deprecated and removed since Kubernetes v1.25, and the command `kubectl create podsecuritypolicy` is not the correct way to enforce the restricted standard; PSS uses admission controller labels, not PSP objects. Option D is wrong because `kubectl annotate` uses annotations, not labels, and the Pod Security Admission controller specifically reads labels (not annotations) to determine the enforcement level.

443
MCQmedium

A pod is configured with securityContext: runAsUser: 1000 runAsGroup: 3000 fsGroup: 2000 The volume mounted at /data is owned by user 1000 and group 2000. The container process inside the pod writes to /data. Which statement about file ownership is true?

A.Files created in /data will be owned by root:root because of the volume mount.
B.Files created in /data will be owned by user 1000 and group 2000.
C.Files created in /data will be owned by user 1000 and group 3000.
D.Files created in /data will be owned by user 1000 and group 1000.
AnswerB

The pod's securityContext defines runAsUser: 1000, so the process UID is 1000. Additionally, fsGroup: 2000 causes the mounted volume to be group-owned by GID 2000 and adds that group to the container's supplementary groups. Therefore, files created in /data are owned by user 1000 and group 2000, as the kernel assigns the effective UID and the volume's group (via setgid) to new files.

Why this answer

The `fsGroup: 2000` in the pod's securityContext causes Kubernetes to recursively change the group ownership of the volume to group 2000 and enable a setgid bit on the mount directory. When the container process (running as user 1000) writes new files to /data, those files inherit the group ownership of the directory (2000) due to the setgid bit, while the user ownership remains 1000 (the runAsUser). Thus, new files are owned by user 1000 and group 2000.

Exam trap

The CKS exam often tests the distinction between runAsGroup (the process's primary group) and fsGroup (the group ownership applied to the volume), leading candidates to incorrectly assume that new files inherit the runAsGroup instead of the fsGroup-controlled directory group.

How to eliminate wrong answers

Option A is wrong because the volume mount does not override the pod's securityContext; the container process runs as user 1000, not root, so files are not owned by root:root. Option C is wrong because the group ownership of new files is determined by the fsGroup (2000) and the setgid bit on the directory, not by the runAsGroup (3000). Option D is wrong because the group ownership is set to fsGroup (2000), not to the user's primary group (1000).

444
MCQeasy

A security engineer wants to scan a container image for vulnerabilities using Trivy. Which command should they use?

A.trivy image <image-name>
B.trivy scan <image-name>
C.trivy repo <image-name>
D.trivy fs <image-name>
AnswerA

`trivy image <image-name>` targets the container image artefact directly, pulling and unpacking its layers to inspect OS packages and language dependencies for known CVEs. This satisfies the stem's requirement to scan an image, unlike filesystem or repository scans, which analyse different targets.

Why this answer

Trivy uses the `image` subcommand to scan a container image for vulnerabilities. The correct syntax is `trivy image <image-name>`, which pulls the image (if not already present) and scans its layers against known vulnerability databases (e.g., NVD, Red Hat, Debian). This is the standard command for container image scanning in Trivy.

Exam trap

The exam often tests the distinction between Trivy's subcommands (`image` vs `repo` vs `fs`), where candidates mistakenly use `trivy scan` (which does not exist) or confuse `trivy repo` (for Git repos) with container image scanning.

How to eliminate wrong answers

Option B is wrong because `trivy scan` is not a valid Trivy subcommand; Trivy uses `image`, `repo`, `fs`, and `config` as primary subcommands. Option C is wrong because `trivy repo` scans a remote Git repository for vulnerabilities in its dependencies, not a container image. Option D is wrong because `trivy fs` scans a local filesystem for vulnerabilities in files and directories, not a container image.

445
MCQmedium

A security admin wants to drop all Linux capabilities for a container and then add only CAP_NET_BIND_SERVICE. Which YAML snippet correctly achieves this?

A.securityContext: capabilities: drop: ['ALL'] add: ['NET_BIND_SERVICE'] privileged: true
B.securityContext: capabilities: drop: ['NET_BIND_SERVICE'] add: ['ALL']
C.securityContext: capDrop: ['ALL'] capAdd: ['NET_BIND_SERVICE']
D.securityContext: capabilities: drop: ['ALL'] add: ['NET_BIND_SERVICE']
AnswerD

This is correct because it first removes every capability from the container's permitted and effective sets, then adds back exactly one capability, NET_BIND_SERVICE, which is required to bind sockets to ports below 1024. This follows the principle of least privilege, ensuring the container only has the minimum kernel access needed. It is the standard pattern for running unprivileged containers that still need low-port binding.

Why this answer

It uses the standard Kubernetes `securityContext.capabilities` field with `drop: ['ALL']` to remove all Linux capabilities from the container, then `add: ['NET_BIND_SERVICE']` to grant only the `CAP_NET_BIND_SERVICE` capability. This is the proper YAML syntax for the desired capability set.

Exam trap

CNCF often tests the distinction between the correct `capabilities` object syntax and the incorrect flat field names like `capDrop`/`capAdd`, and the trap is that candidates confuse `privileged: true` with a fine-grained capability control, when in fact it bypasses all capability restrictions.

How to eliminate wrong answers

Option A is wrong because setting `privileged: true` grants all capabilities and disables most security restrictions, completely negating the effect of dropping and adding capabilities. Option B is wrong because it drops `NET_BIND_SERVICE` and adds `ALL`, which would grant all capabilities instead of only `NET_BIND_SERVICE`. Option C is wrong because `capDrop` and `capAdd` are not valid Kubernetes securityContext fields; the correct field names are `capabilities.drop` and `capabilities.add`.

446
MCQeasy

Which of the following is the best practice for providing sensitive data like passwords to a pod?

A.Mount secrets as volumes into the pod.
B.Use environment variables to inject secrets directly.
C.Pass secrets via command-line arguments.
D.Hardcode the secret in the container image.
AnswerA

Mounting secrets as volumes provides a filesystem-based interface that keeps the secret out of process listings, environment variables, and command-line arguments. The volume is mounted read-only and backed by tmpfs, so the secret is never written to a container's writable layer. You can also use defaultMode to set strict file permissions, limiting access to the specific UID/GID of the container. This approach also enables secrets to be updated (with some delay) by simply changing the Secret object, without a coordinated environment variable update.

Why this answer

Mounting secrets as volumes into the pod is the best practice because it ensures that secrets are stored in a tmpfs (RAM-backed) filesystem, which is never written to disk and is automatically cleaned up when the pod terminates. This approach also allows the kubelet to update the secret contents in the volume without restarting the pod, and it avoids exposing the secret in process listings, logs, or environment variable dumps.

Exam trap

A common trap is thinking that environment variables are safe because they are not in the image, but they are still exposed in the pod spec, logs, and process listings, making them less secure than volume mounts.

How to eliminate wrong answers

Option B is wrong because environment variables can be leaked through the pod's spec, logs, or /proc filesystem, and they are not automatically rotated when the secret changes. Option C is wrong because command-line arguments are visible in the process table (e.g., via `ps aux`) and are stored in the pod's definition, making them easily accessible to anyone with read access to the pod's metadata. Option D is wrong because hardcoding secrets in a container image embeds them in the image layers, which can be inspected by anyone with access to the registry and violates the principle of immutable infrastructure.

447
MCQeasy

An admin runs 'kubectl get pods' and sees a pod in 'CrashLoopBackOff' state. The pod's containers have a restart policy of 'Always'. What is the most likely cause?

A.The image pull secret is missing
B.The pod's resource requests exceed node capacity
C.The node is out of memory
D.The container's command fails immediately after start
AnswerD

If the container's main command exits with a non-zero code immediately after startup, the kubelet sees a stopped container and, with the default restartPolicy of Always, schedules another attempt. Each restart fails again, and the kubelet applies exponential backoff, eventually reporting CrashLoopBackOff. This is the exact scenario the exam question refers to: a successfully launched container that fails at runtime, not a scheduling or image-pull problem.

Why this answer

A CrashLoopBackOff state indicates that the container starts, fails, and is repeatedly restarted by kubelet due to the 'Always' restart policy. The most likely cause is that the container's command or entrypoint fails immediately after start (e.g., a non-zero exit code from a misconfigured binary or script), triggering the restart loop. Unlike resource or node-level issues, this is a container-level failure that produces the rapid restart pattern characteristic of CrashLoopBackOff.

Exam trap

Candidates often confuse CrashLoopBackOff (container starts but fails) with ImagePullBackOff (container never starts due to image issues), leading them to mistakenly select image-related options like missing pull secrets.

How to eliminate wrong answers

Option A is wrong because a missing image pull secret would cause an ImagePullBackOff state, not CrashLoopBackOff, as the container never starts. Option B is wrong because resource requests exceeding node capacity would prevent the pod from being scheduled (Pending state with insufficient resources), not cause a running container to crash. Option C is wrong because an out-of-memory node would lead to OOMKilled containers or pod eviction, but the pod would not enter CrashLoopBackOff; instead, it would show OOMKilled in the container status or be terminated by the kubelet.

448
MCQmedium

An administrator runs 'kubectl auth can-i --list --as=system:serviceaccount:ns1:my-sa' and sees that the service account has 'create pods' permission via a RoleBinding. Which command can be used to delete that RoleBinding?

A.kubectl delete serviceaccount my-sa -n ns1
B.kubectl delete role <role-name> -n ns1
C.kubectl delete rolebinding <binding-name> -n ns1
D.kubectl delete clusterrolebinding <binding-name>
AnswerC

The `kubectl delete rolebinding <binding-name> -n ns1` command targets the exact RBAC resource that connects a Role to subjects such as users, groups, or ServiceAccounts. Because RoleBindings are namespaced, specifying the namespace ensures you're deleting the correct binding for that namespace. This is the definitive way to revoke the permissions that the binding granted, as it removes the association object entirely.

Why this answer

The `kubectl auth can-i --list` output shows that the service account `my-sa` has `create pods` permission via a RoleBinding. To remove that permission, you must delete the RoleBinding object itself, not the service account or the role (unless the role is exclusively used by this binding). Option C correctly uses `kubectl delete rolebinding` with the specific binding name and namespace to revoke the RBAC grant.

Exam trap

CNCF often tests the misconception that deleting the role or the service account is equivalent to removing the permission, but the correct action is to delete the RoleBinding that grants the permission.

How to eliminate wrong answers

Option A is wrong because deleting the service account removes the identity but does not directly delete the RoleBinding; the binding would become orphaned, and the permission would still exist in the cluster (though unusable). Option B is wrong because deleting the role removes the permission definition, but the RoleBinding would still reference a non-existent role, potentially causing errors or leaving the binding in an invalid state; the correct approach is to delete the binding itself. Option D is wrong because the permission was granted via a RoleBinding (namespaced), not a ClusterRoleBinding; deleting a ClusterRoleBinding would not affect a namespaced RoleBinding.

449
Multi-Selectmedium

Which THREE of the following are recommended practices for securing the etcd datastore?

Select 3 answers
A.Disable peer client cert authentication
B.Bind etcd to localhost only if not required to be accessible from other nodes
C.Allow anonymous access to etcd for performance
D.Enable encryption at rest for etcd data
E.Use TLS for all etcd client-to-server communication
AnswersB, D, E

Binding etcd to localhost only is a recommended practice when the etcd instance does not need to be reached from other nodes, such as when kube-apiserver runs on the same host. By listening only on the loopback interface, you eliminate the entire external network attack surface, preventing remote attackers from even connecting to etcd. This is a simple but effective network-layer security control that reduces exposure to unauthorized access.

Why this answer

Binding etcd to localhost (127.0.0.1) when it does not need to be accessed from other nodes restricts network exposure, reducing the attack surface. This is a fundamental network hardening practice that prevents unauthorized remote access to the etcd datastore, which stores all cluster state and secrets.

Exam trap

The trap here is that candidates may think disabling authentication (Option A) or enabling anonymous access (Option C) improves performance or simplifies setup, but the CKS exam strictly enforces that security controls like mTLS and authentication must never be weakened for any reason.

450
MCQeasy

You suspect a container is running an unexpected process. Which crictl command can you use to list all running containers on the node?

A.crictl stats
B.crictl pods
C.crictl ps
D.crictl images
AnswerC

crictl ps is correct because, like `docker ps`, it lists the currently running containers managed by the container runtime, showing the container ID, image, state, and name. Once you have the container ID from `crictl ps`, you can use `crictl inspect` or `crictl exec` to enumerate actual processes, making it the essential starting point for investigating a suspected unexpected process in a Kubernetes node's container.

Why this answer

The `crictl ps` command lists all running containers on a node by querying the CRI-compatible container runtime (containerd or CRI-O) through the Container Runtime Interface. It returns container ID, image, state, name, and pod association, making it the correct tool for identifying unexpected processes running inside containers on a Kubernetes node.

Exam trap

CKS often tests confusion between crictl subcommands — candidates must distinguish `ps` (running containers) from `pods` (sandboxes), `images` (image cache), and `stats` (resource metrics).

How to eliminate wrong answers

Option A is wrong because `crictl stats` reports live resource usage (CPU, memory, disk, network) for containers, not a listing of running containers. Option B is wrong because `crictl pods` lists pod sandboxes, not the individual containers running inside them. Option D is wrong because `crictl images` lists container images present on the node, not running container instances.

Page 5

Page 6 of 12

Page 7