# Free KS practice questions

> 10 free KS practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/kubernetes-security/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/kubernetes-security/

### Question 1 of 10 (choose 2)

A cluster runs the ingress-nginx controller with its validating admission webhook reachable from any Pod in the cluster. Following disclosure of critical vulnerabilities in that webhook that allowed unauthenticated code execution in the controller, which TWO actions reduce exposure? (Choose two.)

- A. Set the webhook failurePolicy to Ignore so that broken requests are always allowed
- B. Restrict network access to the admission webhook so only the API server can reach it
- C. Upgrade the controller to a patched release, and plan migration because ingress-nginx is retired
- D. Move the controller's TLS certificates into a ConfigMap so that they are easier to rotate
- E. Give the controller's ServiceAccount the cluster-admin role so it can patch itself

**Answer:** B, C

**Explanation:** Patching removes the known flaws, and because the ingress-nginx project has been retired, teams should plan to move to a maintained controller or Gateway API implementation. The webhook only needs to be reachable from the API server, so a NetworkPolicy limiting it removes the in-cluster attack path. Granting cluster-admin would increase the impact of a compromise. failurePolicy controls behaviour when the webhook is down, not who can reach it. Certificates belong in Secrets, and their storage has nothing to do with the flaw.

### Question 2 of 10

A security team installs a validating admission webhook that blocks images from unapproved registries and sets failurePolicy to Fail. During a node outage the webhook pods were evicted and the cluster could not recreate any pods, including the webhook itself and CoreDNS. Which change keeps the control fail-closed for application workloads while avoiding this deadlock?

- A. Exclude kube-system and the webhook's own namespace with a namespaceSelector and run the webhook with multiple replicas and a PodDisruptionBudget
- B. Replace the webhook with an audit policy at RequestResponse level so that violations are recorded instead of blocked at admission
- C. Raise timeoutSeconds to 30 on the webhook configuration so that the API server waits much longer for the evicted webhook pods to be recreated
- D. Switch failurePolicy to Ignore for every namespace so that pods are always admitted whenever the webhook backend cannot be reached

**Answer:** A

**Explanation:** Scoping the webhook away from the namespaces it depends on (and from system components) prevents a circular dependency, and redundancy plus a PodDisruptionBudget reduces the chance it is unavailable, while application namespaces stay fail-closed. Ignore everywhere makes the control fail open whenever an attacker can disrupt the webhook. A longer timeout cannot help when the backend pods do not exist, and it slows every request. Auditing records violations but no longer enforces the registry rule.

### Question 3 of 10

An operator for a third-party database is installed and its ClusterRole includes the verbs 'bind' and 'escalate' on roles and clusterroles. The vendor says this is needed so the operator can create namespace Roles for the databases it manages. Which risk does this grant introduce?

- A. The operator can only bind roles that already exist, so the grant is safe as long as no new ClusterRoles are created
- B. The operator's ServiceAccount can create or bind roles with permissions it does not hold itself, including cluster-admin
- C. The operator can impersonate any user, so its requests appear in audit logs under the impersonated user's name
- D. The operator can approve CertificateSigningRequests and therefore mint client certificates for the system:masters group

**Answer:** B

**Explanation:** RBAC normally prevents a subject from creating or binding a role that grants more than it already has; escalate and bind are the verbs that lift that safeguard, so anyone controlling the operator's token can grant themselves cluster-admin. Scope them with resourceNames or to specific namespaces where possible. Impersonation needs the separate impersonate verb. CSR approval needs permissions on certificatesigningrequests/approval and signers. The bind verb allows binding powerful existing roles such as cluster-admin, so existing roles do not make it safe.

### Question 4 of 10

An external Vault cluster authenticates Kubernetes workloads using the Kubernetes auth method. Pods send their projected ServiceAccount tokens to Vault. Security wants to make sure a token stolen from one of these Pods cannot be replayed against the Kubernetes API server. What should be configured?

- A. Store the Vault token in a Kubernetes Secret and mount that instead of the ServiceAccount token in the Pod
- B. Request the projected token with a Vault-specific audience and configure Vault to require that audience
- C. Set the token's expirationSeconds to 24 hours so that a stolen token stays valid for less time than before
- D. Give the ServiceAccount no RBAC permissions, because Vault validates the token with its own signing key

**Answer:** B

**Explanation:** A projected token can carry a dedicated audience; the API server rejects tokens whose audience is not its own, and Vault can insist on its own audience, so a token stolen in transit to Vault is useless against the API. A 24-hour lifetime is longer than the typical default and only reduces exposure, it does not stop replay. Storing a long-lived Vault token in a Secret creates a new static credential. Vault normally verifies tokens via the TokenReview API or the cluster's public keys; having no RBAC does not limit what the token proves.

### Question 5 of 10

A namespace enforces the restricted Pod Security Standard. An SRE runs 'kubectl debug' to attach an ephemeral container with a profiling tool that needs SYS_PTRACE to a production Pod. What happens?

- A. The ephemeral container is admitted, but the kubelet silently drops SYS_PTRACE when it starts the container
- B. The whole Pod is evicted, because adding a privileged ephemeral container violates the namespace policy
- C. The ephemeral container is rejected, because Pod Security Admission also evaluates ephemeral containers
- D. The ephemeral container is admitted, because Pod Security Admission only evaluates the Pod at creation

**Answer:** C

**Explanation:** Updates to the ephemeralcontainers subresource are checked by Pod Security Admission, and adding SYS_PTRACE violates restricted, so the request is denied; teams need a debugging profile compatible with the namespace level or a separate break-glass process. PSA does not ignore later additions to the Pod. The kubelet does not silently strip capabilities. Admission rejects the request; it does not evict existing Pods.

### Question 6 of 10

One team asks to set the sysctl net.ipv4.ip_local_port_range in its Pods, and another team asks for net.core.somaxconn. Both namespaces enforce baseline Pod Security and the kubelets use default settings. How should the platform team handle these requests?

- A. Reject both, because baseline Pod Security blocks every sysctl that appears in a Pod's securityContext
- B. Allow the first, which is in the safe set; the second needs allowed-unsafe-sysctls on dedicated, isolated nodes
- C. Allow both, because every sysctl set in a Pod spec is namespaced to that Pod and can never affect other workloads
- D. Allow both only when the Pods also run as privileged, because sysctls can only be set in privileged mode

**Answer:** B

**Explanation:** net.ipv4.ip_local_port_range is in the kubelet's safe sysctl set, which baseline permits, while net.core.somaxconn is not in that set and is rejected by the kubelet unless explicitly enabled with allowed-unsafe-sysctls, ideally only on dedicated tainted nodes. Not every sysctl is isolated, which is why the safe list exists. Baseline does allow safe sysctls. Privileged mode is not needed to set sysctls and would be excessive.

### Question 7 of 10

A platform team needs to guarantee that, in every namespace now and in the future, traffic to the cluster's ingress controller namespace is always allowed and traffic to the database subnet is always denied, even if a namespace owner writes permissive NetworkPolicies. Which approach fits?

- A. An Istio AuthorizationPolicy in istio-system that denies all traffic to the database subnet for workloads that have sidecars injected
- B. Cluster-scoped policies from the CNI, such as Calico GlobalNetworkPolicy or CiliumClusterwideNetworkPolicy, evaluated before namespace policies
- C. A default-deny NetworkPolicy in every namespace plus a Git review requirement for any NetworkPolicy changes that namespace owners submit
- D. A NetworkPolicy in the ingress controller namespace that allows all ingress, plus one in the database namespace that denies all egress

**Answer:** B

**Explanation:** Standard NetworkPolicy is namespaced and purely additive, so namespace owners can always open more; cluster-scoped, tiered policies from the CNI let administrators set rules that namespace policies cannot override. Review processes depend on people and do not cover new namespaces automatically. Policies in two namespaces do not prevent other namespaces' egress to the database subnet. A mesh policy only covers meshed workloads and external subnets need egress controls at the network layer.

### Question 8 of 10

A CI system builds and pushes images using a long-lived registry password stored as a CI variable. Security wants to remove that password while keeping automated pushes. What is the BEST approach?

- A. Grant the CI runner node's instance role admin rights on all registries so that no credentials are needed
- B. Federate the CI job's OIDC token with cloud IAM to get short-lived registry credentials for each run
- C. Store the registry password in a Kubernetes Secret and mount it into the CI runner Pods for each build
- D. Encrypt the CI variable with a project-specific key and rotate the registry password manually each quarter

**Answer:** B

**Explanation:** OIDC federation lets each pipeline run exchange its identity token for short-lived, scoped credentials, so there is no static password to leak. Encrypting and rotating still leaves a long-lived secret in between rotations. Admin rights on all registries for the node role violate least privilege and are shared by every job on that node. Moving the password into a Secret keeps the same static credential.

### Question 9 of 10

An application team adds open-source dependencies freely. The security team wants a quick, automated signal of how well maintained and secured each upstream project is before it is adopted. Which tool provides this?

- A. Falco, which observes how the dependency behaves in production containers and assigns a risk score
- B. OpenSSF Scorecard, which checks practices like branch protection, code review and pinning
- C. Cosign, which reports whether a project's maintainers have signed every commit in the repository
- D. kube-bench, which scores each upstream project against the CIS Kubernetes Benchmark controls

**Answer:** B

**Explanation:** OpenSSF Scorecard runs automated checks on a project's repository practices and produces a score, which helps decide whether a dependency is trustworthy. kube-bench audits cluster configuration, not projects. Cosign signs and verifies artefacts and does not assess maintainer practices. Falco detects runtime behaviour after deployment, which is too late for an adoption decision.

### Question 10 of 10

Investigators suspect that a compromised node has a malicious static Pod defined on disk. Why would deleting the mirror Pod with kubectl not remove it?

- A. Static Pods are protected by a finalizer that only the cluster's original installer account can remove
- B. Static Pods are recreated by the DaemonSet controller whenever their mirror objects are deleted
- C. Static Pods are run by the kubelet from its manifest directory, and the API object is only a mirror
- D. Static Pods are stored only in etcd, and kubectl cannot delete objects that lack an owner reference

**Answer:** C

**Explanation:** The kubelet creates static Pods from files in its staticPodPath and publishes a read-only mirror Pod to the API; the container keeps running until the manifest file is removed from the node, which is why static Pods are a persistence technique on compromised nodes. There is no special finalizer. DaemonSets do not manage static Pods. Static Pods are defined on disk, not only in etcd.

Ready for a timed run? Take the free 15-question KS mini exam: https://devopscodelab.com/app/exams/kubernetes-security/mini/

DevOpsCode Lab is not affiliated with CNCF. KS and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
