All Linux Foundation / CNCF exams
Free CKS practice test: 30 questions with answers
30 original questions for Certified Kubernetes Security Specialist, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
All 30 CKS questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Monitoring, Logging and Runtime Security (5 questions)
Question 1
A security engineer wants an alert when a shell is started inside a running container. Which open-source runtime security tool detects this kind of behaviour?
- Akube-bench
- Betcdctl
- CTrivy
- DFalco
Show answer and explanationHide answer
Correct answer: DFalco watches system calls and Kubernetes events and raises alerts on suspicious behaviour, such as an interactive shell spawned in a container. Kube-bench checks configuration, Trivy scans images, and etcdctl is a database client.
Question 2
An audit policy must capture the full request and response bodies for changes to Secrets. Which audit level provides this?
- AMetadataOnly
- BRequestBodies
- CRequestResponse
- DNoAuditRecordsKept
Show answer and explanationHide answer
Correct answer: CRequestResponse records the request and response bodies in addition to metadata. Metadata records only who did what and when, and Request records the request body without the response.
Question 3
Which two statements about Kubernetes audit logging are correct? (Choose two.)
- AAn audit policy file controls which requests are recorded and at what level
- BMetadata-level logging records the full body of each request
- CAudit stages include RequestReceived and ResponseComplete
- DAudit logging is enabled by default with full request bodies
- EAudit events are generated only when the cluster runs in debug mode
Show answer and explanationHide answer
Correct answer: A, CThe audit policy file decides which requests are logged and at which level, and the stages describe points in the request lifecycle, such as RequestReceived and ResponseComplete. Metadata logging omits bodies, and audit logging needs explicit configuration rather than running in debug mode.
Question 4
In Falco, what does a rule consist of so that it can generate an alert when an event matches?
- AA cron schedule and a retention period stored in the rule
- BA container image digest and a signature for each pod
- CA pod selector and a network policy for ingress traffic
- DA condition expressed over event fields and an output message
Show answer and explanationHide answer
Correct answer: DA Falco rule has a condition, which is a filter over system call or event fields, and an output string that is written when the condition matches. Network policies, digests and cron schedules are not part of Falco rule definitions.
Question 5
A Falco rule fires whenever a process in a container opens a network socket to an address outside the cluster. The team wants the event forwarded to a SIEM. Which Falco capability enables this?
- AThe kubelet readOnlyPort setting in the node's config file
- BThe Kubernetes Horizontal Pod Autoscaler based on CPU utilization
- CA ResourceQuota on network bandwidth per namespace for ingress
- DFalcosidekick or another output channel configured in the Falco outputs
Show answer and explanationHide answer
Correct answer: DFalco outputs can be sent to a file, stdout, HTTP endpoint or other channels, and Falcosidekick forwards alerts to many backends including SIEM systems. The other options are unrelated to alert delivery.
Minimize Microservice Vulnerabilities (5 questions)
Question 6
A namespace must enforce the restricted Pod Security Standard so that non-compliant pods are rejected at creation. Which label should be applied to the namespace?
- Apodsecuritypolicy.kubernetes.io/enforce=restricted
- Bpod-security.kubernetes.io/enforce=restricted
- Csecurity.policy/restricted-mode=true
- Dpod-security.kubernetes.io/audit=restricted
Show answer and explanationHide answer
Correct answer: BThe enforce mode label rejects pods that violate the chosen Pod Security Standard. The audit label only records violations, and the other two labels are not recognised by Pod Security Admission, because PodSecurityPolicy has been removed from Kubernetes.
Question 7
Two microservices in a service mesh must authenticate each other and encrypt traffic, and plaintext connections must be refused. In Istio, which configuration enforces this for a namespace?
- AA ServiceEntry that lists the external IP addresses of the services
- BA VirtualService that routes all traffic to port 80
- CA PeerAuthentication resource with mtls mode set to PERMISSIVE
- DA PeerAuthentication resource with mtls mode set to STRICT
Show answer and explanationHide answer
Correct answer: DSTRICT mode in a PeerAuthentication policy requires mutual TLS for the workloads it covers, so plaintext connections are rejected. PERMISSIVE accepts both plaintext and mTLS, which leaves the risk in place. VirtualService and ServiceEntry control routing and external hosts, not peer authentication.
Question 8
Secrets are stored in etcd and the team wants them encrypted at rest. Which kube-apiserver setting provides this?
- A--audit-policy-file pointing to a secrets-only audit policy
- B--service-account-key-file pointing to a key file used for tokens
- C--encryption-provider-config pointing to an EncryptionConfiguration file
- D--enable-admission-plugins=SecretEncryption set on the API server
Show answer and explanationHide answer
Correct answer: CThe encryption provider configuration tells the API server which provider, such as aescbc, kms or secretbox, to use when writing resources such as Secrets to etcd. The audit policy records access without encrypting anything, and the other flags are not related to encryption at rest.
Question 9
A developer says Kubernetes Secrets are safe because the values are stored in encoded form. What is the accurate correction?
- ASecrets are kept in memory only on the worker node and are never written to disk
- BSecrets are encrypted by the kubelet with a node-local key before they are mounted into the pod as files
- CSecrets are encrypted with a cluster-wide key by default, so the developer is right
- DSecret values are only base64-encoded, and without encryption at rest they are readable in etcd
Show answer and explanationHide answer
Correct answer: DBase64 is an encoding, not encryption, so anyone who can read the etcd data or the object can decode the value. Encryption at rest must be configured explicitly with an encryption provider. Secrets are not memory-only, and the kubelet does not encrypt them before delivery.
Question 10
A container runs as root by default. Which securityContext setting makes the kubelet refuse to start the container if it would run as UID 0?
- ArunAsNonRoot: true
- Bprivileged: true
- CallowPrivilegeEscalation: true
- DreadOnlyRootFilesystem: false
Show answer and explanationHide answer
Correct answer: ArunAsNonRoot true causes the kubelet to verify that the container will not run as UID 0 and to refuse the start if it would. Privileged and privilege escalation settings do the opposite, and the filesystem setting does not affect the user.
Supply Chain Security (5 questions)
Question 11
A security team needs a software bill of materials for each container image to track which packages it contains. Which open-source tool generates this inventory?
- Akube-hunter
- BFalco
- Ckube-bench
- DSyft
Show answer and explanationHide answer
Correct answer: DSyft catalogs packages and produces SBOMs in formats such as SPDX and CycloneDX. Falco detects runtime behaviour, kube-bench checks cluster configuration against CIS benchmarks, and kube-hunter probes a cluster for weaknesses.
Question 12
An organization wants to block any container image that was not signed by its CI pipeline before it is admitted to the cluster. Which tooling pairing fits this requirement?
- AFalco rules that alert on image pulls and on unexpected binaries launched inside containers
- BTrivy scanning with a nightly cron job that reports known CVEs in the image layers
- CCosign signatures verified by an admission policy such as Kyverno or the Sigstore policy controller
- Dkubectl apply with the --dry-run flag to preview the manifest before admission runs
Show answer and explanationHide answer
Correct answer: CCosign signs images, and an admission controller such as Kyverno or the Sigstore policy controller verifies the signature before the pod is created. Trivy finds vulnerabilities but does not enforce signatures, and Falco observes runtime events after the fact.
Question 13
Why is referencing an image by digest, for example an @sha256 value, preferred over a mutable tag such as latest?
- AA digest points to a newer and patched version of the image once the registry publishes an update for that repository
- BA digest identifies one exact image content, so the tag cannot be silently repointed to different contents
- CA digest removes the need to scan the image for vulnerabilities because the hash already covers each layer in the image
- DA digest is shorter and loads faster on each node because the runtime skips the registry tag lookup on startup
Show answer and explanationHide answer
Correct answer: BA tag can be moved to a different image by whoever controls the registry, but a digest is a hash of the image manifest, so it always resolves to the same content. Digests do not make images newer or safer, and scanning is still needed.
Question 14
A cluster administrator wants the API server to ask an external service whether each image is allowed before a pod is admitted. Which mechanism provides this?
- AThe kube-proxy iptables mode
- BA LimitRange object in the namespace
- CImagePolicyWebhook admission controller
- DA PersistentVolume with a read-only access mode
Show answer and explanationHide answer
Correct answer: CThe ImagePolicyWebhook admission controller sends image information to an external webhook that returns allow or deny decisions. PersistentVolumes, kube-proxy and LimitRange do not evaluate images at admission time.
Question 15
Which two practices reduce the attack surface of a container image? (Choose two.)
- ARun the application process as root for simpler file access
- BUse multi-stage builds so compilers and build tools are not in the final image
- CInstall a shell and debugging utilities in the production image
- DUse a distroless or minimal base image
- EUse the latest tag so updates are picked up automatically
Show answer and explanationHide answer
Correct answer: B, DMinimal base images and multi-stage builds keep package managers, compilers and shells out of the shipped image, so there is less code an attacker can use. Running as root, floating tags and extra debugging tools all make the image easier to exploit.
Cluster Hardening (5 questions)
Question 16
A service account named report-reader in the dev namespace must only list and get pods, and only inside dev. Which combination grants exactly that?
- AA Role in dev allowing get and list on pods, plus a RoleBinding in dev that binds it to the service account
- BA ClusterRoleBinding that grants the built-in cluster-admin ClusterRole to the service account
- CA ClusterRole with wildcard verbs on pods, bound with a ClusterRoleBinding to the whole cluster
- DA Role created in kube-system with get and list on pods, bound to the service account by a RoleBinding
Show answer and explanationHide answer
Correct answer: AA namespaced Role with the minimal verbs and a RoleBinding in the same namespace limits the grant to dev. A ClusterRoleBinding would grant the rights in every namespace, and a Role in kube-system does not apply to pods in dev at all.
Question 17
A workload does not call the Kubernetes API, but its pods still receive a token for the default service account. Which change removes the token from the pod?
- ASet automountServiceAccountToken to false on the pod spec or its service account
- BSet readOnlyRootFilesystem to true in the container securityContext
- CSet hostNetwork to true in the pod spec so the pod shares the node network namespace and ports
- DRun the container as UID 0 with a privileged flag and the SYS_ADMIN capability added for host access
Show answer and explanationHide answer
Correct answer: AThe automountServiceAccountToken field controls whether the API credential is mounted into the pod. Setting it to false on the pod or on the service account removes the token, shrinking what an attacker gets after compromising the container. The other options change networking, filesystem writes or privileges, not API credentials.
Question 18
Which two controls reduce the damage a stolen kubelet client credential can do to the rest of the cluster? (Choose two.)
- ASet --anonymous-auth=true on every kubelet
- BExpose the kubelet read-only port 10255 for monitoring
- CUse the Webhook authorization mode on the kubelet so API requests are checked
- DDisable kubelet client certificate rotation
- EEnable the Node authorizer together with the NodeRestriction admission plugin
Show answer and explanationHide answer
Correct answer: C, EThe Node authorizer and NodeRestriction limit each kubelet to the objects on its own node, and Webhook mode on the kubelet delegates authorization decisions to the API server. Anonymous access, an exposed read-only port and disabled certificate rotation all widen the attack surface or extend the life of a stolen credential.
Question 19
A cluster is upgraded with kubeadm. Which command applies the upgrade plan to the control plane on the first control-plane node?
- Akubeadm upgrade apply
- Bkubectl upgrade cluster
- Ckubeadm init --upgrade
- Dhelm upgrade kube-system
Show answer and explanationHide answer
Correct answer: Akubeadm upgrade apply performs the control-plane upgrade on the first control-plane node, after the kubeadm binary itself has been updated. The other commands are not kubeadm upgrade operations.
Question 20
A user named alice should be able to view secrets but not create or delete them, across all namespaces. Which RBAC grant matches this request?
- AA Role in the default namespace granting create and patch on secrets, bound to alice
- BA ClusterRole allowing delete on secrets and other resources across every namespace, bound with a ClusterRoleBinding
- CA ClusterRoleBinding to the built-in edit role, which grants write access to secrets
- DA ClusterRole allowing get, list and watch on secrets, bound to alice with a ClusterRoleBinding
Show answer and explanationHide answer
Correct answer: DA ClusterRole that grants only get, list and watch on secrets, bound cluster-wide, gives read access in every namespace without write rights. The edit role includes write permissions on secrets, and a Role in one namespace is too narrow.
System Hardening (5 questions)
Question 21
A team wants a container to run under an AppArmor profile that is already loaded on the worker node. In a current Kubernetes release, which securityContext field sets this on a container?
- Aspec.containers[].securityContext.appArmorProfile with type Localhost and the profile name
- BA seccomp profile of type Unconfined set in the container securityContext, disabling checks
- Cspec.hostPID set to true so the pod shares the node's PID namespace with host processes running
- DThe --enable-admission-plugins=PodSecurity flag passed to the kubelet, which enforces Pod Security Standards
Show answer and explanationHide answer
Correct answer: AThe appArmorProfile field on a container security context selects the AppArmor profile, and Localhost refers to a profile loaded on the node. hostPID is a namespace setting unrelated to AppArmor, and the admission plugin enforces Pod Security Standards without choosing a profile.
Question 22
Which seccomp profile type applies the container runtime's built-in default syscall filter to a pod?
- ALocalhost with no profile file
- BAudit
- CRuntimeDefault
- DUnconfined
Show answer and explanationHide answer
Correct answer: CRuntimeDefault applies the default syscall filter that the container runtime ships with, which blocks many dangerous calls. Unconfined disables filtering, and the Localhost type needs a named profile file on the node, so it is not the runtime default.
Question 23
A container only needs to bind to port 443 and should have as few Linux capabilities as possible. Which securityContext configuration fits this requirement?
- ADrop ALL capabilities and add back only NET_BIND_SERVICE if binding ports below 1024 is required
- BAdd ALL capabilities to make the container work reliably and avoid permission errors on the worker node
- CSet privileged to true so the container can bind several ports, which exposes host devices and grants the full capability
- DDrop only NET_ADMIN and keep the other default capabilities enabled in the container
Show answer and explanationHide answer
Correct answer: ADropping ALL and adding back only the single capability needed follows least privilege. Port 443 is below 1024, so NET_BIND_SERVICE is the one capability required. Keeping the default set or running privileged gives the container far more power than it needs.
Question 24
A pod mounts the host path /var/run/docker.sock so that its application can start containers. Which two risks does this create? (Choose two.)
- AThe pod is forced into the host network namespace
- BThe kubelet stops scheduling other pods to that node
- CThe pod gains root-equivalent control over the host container runtime
- DThe pod can start privileged containers that mount the host filesystem
- EThe pod is limited to reading container logs
Show answer and explanationHide answer
Correct answer: C, DThe Docker socket is the control interface of the container runtime, so a process that can write to it effectively has root on the node and can launch privileged containers with host mounts. Reading logs is not what the socket grants, and mounting it does not change networking or scheduling.
Question 25
A pod should not be able to write to its root filesystem but needs a writable scratch directory. Which combination meets the requirement?
- ASet privileged to true and remove the volume so the container runs with host-level privileges
- BSet readOnlyRootFilesystem to true and mount an emptyDir volume at the scratch path
- CSet runAsUser to 0 and allowPrivilegeEscalation to true, with seccomp profile set to Unconfined
- DMount the host root directory read-write at / using a hostPath volume with write access
Show answer and explanationHide answer
Correct answer: BA read-only root filesystem blocks tampering with binaries, while an emptyDir volume gives the application a writable location that is discarded with the pod. The other options increase privilege or expose the host filesystem.
Cluster Setup (5 questions)
Question 26
A platform team wants every pod in the payments namespace to reject all inbound traffic unless another policy explicitly allows it. Which NetworkPolicy achieves this baseline?
- AA NetworkPolicy with an ingress rule that allows traffic from all namespaces
- BA NetworkPolicy that selects no pods and defines only egress rules
- CA NetworkPolicy with an empty podSelector, policyTypes set to Ingress, and no ingress rules
- DA ResourceQuota that limits the namespace to zero pods
Show answer and explanationHide answer
Correct answer: BA NetworkPolicy whose podSelector is empty selects every pod in the namespace. Listing Ingress in policyTypes with no ingress rules makes the default for inbound traffic deny. The allow-all rule is wrong because it opens traffic, and a ResourceQuota controls resource counts, not network flows.
Question 27
Security review finds that unauthenticated requests to the kube-apiserver are being accepted. Which kube-apiserver flag should be changed to stop anonymous requests from being treated as authenticated users?
- A--authorization-mode=AlwaysAllow
- B--anonymous-auth=false
- C--insecure-port=8080
- D--token-auth-file=/etc/kubernetes/tokens.csv
Show answer and explanationHide answer
Correct answer: BSetting --anonymous-auth=false makes the API server reject requests with no credentials instead of processing them as the system:anonymous user. AlwaysAllow is the opposite of what is wanted, and the insecure port bypasses authentication entirely.
Question 28
A kube-bench run reports that the kubelet exposes a read-only port that anyone on the network can query. Which kubelet configuration change closes this?
- ASet readOnlyPort to 10250
- BSet readOnlyPort to 0
- CSet authorizationMode to AlwaysAllow
- DSet anonymous authentication to true
Show answer and explanationHide answer
Correct answer: BSetting readOnlyPort to 0 disables the unauthenticated read-only endpoint on port 10255. Port 10250 is the authenticated kubelet API, and the other two settings weaken authentication.
Question 29
A team must protect the etcd cluster so that only the kube-apiserver can talk to it. Which measure satisfies this requirement?
- AMake the etcd client port reachable from every pod network through an open security group rule
- BRequire mutual TLS on the etcd client endpoints and allow only the API server certificate as a client
- CExpose etcd on a public load balancer with a shared password and an open firewall rule
- DDisable TLS because the cluster network is private and etcd may use plaintext on the VLAN
Show answer and explanationHide answer
Correct answer: BRequiring client certificates on etcd and accepting only the API server identity restricts who can read or write cluster state. Open networking, public exposure and disabling TLS each remove a protection that etcd depends on.
Question 30
A new worker node joins the cluster and the security team wants its kubelet to use certificates that renew automatically. Which kubelet setting controls this behaviour?
- AenforceNodeAllocatable
- BrotateCertificates
- CcpuManagerPolicy
- DtopologyManagerPolicy
Show answer and explanationHide answer
Correct answer: BrotateCertificates enables automatic rotation of the kubelet client certificate, which limits how long a stolen credential stays useful. The other settings control a read-only endpoint, static pod location and DNS configuration.
Want more CKS questions?
The full bank has 100 questions with answers and explanations, as a PDF, an online practice exam, or both.
Both formats together. The best value.
Instant access after payment, with 90 days of updates. Checkout is on our store, AIExamCerts.