Skip to content

KCSA · Domain 2: Kubernetes Cluster Component Security · 22% of the exam

Task 2.7: Pod

Pod and container security contexts, capabilities, privileged mode, host namespaces and hostPath, and the service account token a Pod receives.

Study it

Sample questions

Try each one before opening the answer. Every option is explained, with the CNCF documentation page that proves it.

Question 1 · choose 1

A web server must listen on port 80 inside its container and runs as UID 1000. Its namespace enforces the Restricted Pod Security Standard, and the Pod already meets every other Restricted requirement. Which container setting is admitted and grants the container the capability for binding ports below 1024?

  1. AKeep the default capabilities and allow privilege escalation so the binary can gain the capability
  2. BDrop ALL capabilities and add back only NET_BIND_SERVICE
  3. CSet hostNetwork: true so that the server binds port 80 on the node instead
  4. DAdd NET_BIND_SERVICE and leave the runtime's other default capabilities in place
Show the answer and why
  • AKeep the default capabilities and allow privilege escalation so the binary can gain the capability

    Incorrect

    Restricted requires allowPrivilegeEscalation to be false, so a Pod that sets it to true is rejected.

  • BDrop ALL capabilities and add back only NET_BIND_SERVICE

    Correct

    Restricted requires containers to drop ALL capabilities and permits adding back only NET_BIND_SERVICE, the capability for binding ports below 1024.

  • CSet hostNetwork: true so that the server binds port 80 on the node instead

    Incorrect

    Sharing host namespaces is forbidden already at the Baseline level, so Restricted rejects the Pod.

  • DAdd NET_BIND_SERVICE and leave the runtime's other default capabilities in place

    Incorrect

    Restricted requires the drop list to include ALL; adding a capability without dropping the rest does not meet the profile.

Under the Restricted profile, containers must drop ALL capabilities and may add back only NET_BIND_SERVICE, and allowPrivilegeEscalation must be false. Dropping everything and adding NET_BIND_SERVICE is the only capability set among these that the profile admits and that includes the port binding capability.

Question 2 · choose 1

A Pod sets runAsUser: 1000 in its Pod-level securityContext, and one of its containers sets runAsUser: 2000 in its own securityContext. Which user does that container run as?

  1. A1000, because Pod-level settings always win over container settings
  2. BRoot, because conflicting values are ignored
  3. CThe Pod is rejected for conflicting values
  4. D2000, since container-level settings override Pod-level ones
Show the answer and why
  • A1000, because Pod-level settings always win over container settings

    Incorrect

    Pod-level values apply to all containers unless a container sets its own value, which then takes precedence.

  • BRoot, because conflicting values are ignored

    Incorrect

    There is no conflict rule that falls back to root; the container's own value applies.

  • CThe Pod is rejected for conflicting values

    Incorrect

    Setting a value at both levels is allowed; the container-level value takes precedence.

  • D2000, since container-level settings override Pod-level ones

    Correct

    The security context task explains that settings at the container level override the same settings made at the Pod level.

A Pod's securityContext applies to all its containers, and a container's securityContext can override individual fields. Where both set runAsUser, the container-level value is used for that container.

Question 3 · choose 1

A container's securityContext does not mention allowPrivilegeEscalation. What value applies?

  1. Afalse, because Kubernetes denies escalation unless it is requested
  2. BIt depends on the namespace's ResourceQuota
  3. Ctrue, so its processes may gain more privileges than their parent
  4. DIt is unset, and the kubelet refuses to start the container
Show the answer and why
  • Afalse, because Kubernetes denies escalation unless it is requested

    Incorrect

    The default is the permissive one; it must be set to false explicitly.

  • BIt depends on the namespace's ResourceQuota

    Incorrect

    Quotas limit resource consumption; they do not set security context defaults.

  • Ctrue, so its processes may gain more privileges than their parent

    Correct

    The security context task says that if allowPrivilegeEscalation is not defined, it defaults to true.

  • DIt is unset, and the kubelet refuses to start the container

    Incorrect

    An unset value is valid; the documented default of true applies.

allowPrivilegeEscalation controls the no_new_privs flag on the container process. Left unset it defaults to true, which is why hardening guides and the Restricted profile ask for it to be set to false explicitly.

Practice domain 2 →Practice all domains →