KCSA · Domain 4: Kubernetes Threat Model · 16% of the exam
Task 4.4: Malicious Code Execution and Compromised Applications in Containers
Limiting what a compromised container can do: security contexts, seccomp and AppArmor, read-only filesystems and runtime detection.
Study it
Persistence, malicious code, attackers on the network, sensitive data and privilege escalation
Lesson coming
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
To keep a compromised process from writing outside its data directory, a team sets securityContext.appArmorProfile with type Localhost and localhostProfile k8s-deny-write on a Deployment's containers. The profile has been loaded on only some of the nodes. What happens to the Deployment's Pods that are placed on a node where the profile is not loaded?
AThe kubelet rejects them, because every specified profile must be loaded on the node
BThey start unconfined, and the kubelet records a warning event
CThey start with the container runtime's default profile instead
DThe scheduler avoids those nodes, because loaded profiles are published as node labels
Show the answer and why
AThe kubelet rejects them, because every specified profile must be loaded on the node
Correct
The AppArmor tutorial says that if any of the specified profiles is not loaded in the kernel, the kubelet rejects the Pod.
BThey start unconfined, and the kubelet records a warning event
Incorrect
The kubelet does not fall back to running without AppArmor when a requested profile is missing; it rejects the Pod.
CThey start with the container runtime's default profile instead
Incorrect
The runtime default is used only when the type is RuntimeDefault; a Localhost profile that is missing is not replaced.
DThe scheduler avoids those nodes, because loaded profiles are published as node labels
Incorrect
Profiles loaded on a node are not reported to the scheduler; the tutorial suggests making sure they are loaded on every node a Pod might use.
A Localhost AppArmor profile must already be loaded on the node. If it is not, the kubelet rejects the Pod rather than running it with weaker confinement, so profiles have to be present on every node where the workload can land.
A security team wants an alert within seconds whenever a shell starts inside any running container, including containers built from third-party images it cannot change. Which CNCF project is designed for this kind of runtime threat detection?
AKyverno
Bcert-manager
CNotary Project
DFalco
Show the answer and why
AKyverno
Incorrect
Kyverno is a policy-as-code project; it checks and changes resources as they are admitted, not what processes do inside running containers.
Bcert-manager
Incorrect
cert-manager provisions and manages TLS certificates in Kubernetes; it does not watch running containers.
CNotary Project
Incorrect
Notary Project signs and verifies artifacts; it does not watch running containers.
DFalco
Correct
CNCF describes Falco as the cloud-native runtime security project and the de facto Kubernetes threat detection engine.
Detecting suspicious behavior such as a shell spawning in a running container is runtime threat detection, the role of Falco among CNCF projects. Admission-time policy engines and registries act before a container runs.
A container's securityContext sets seccompProfile with type Localhost and localhostProfile profiles/audit.json. Where does the kubelet look for that file?
AIn a ConfigMap named audit.json in the Pod's namespace
BInside the container image at /etc/seccomp/profiles/audit.json for that container
CRelative to the kubelet's seccomp directory, such as /var/lib/kubelet/seccomp
DOn the API server, which sends it to the kubelet
Show the answer and why
AIn a ConfigMap named audit.json in the Pod's namespace
Incorrect
Localhost profiles are files on the node, not ConfigMaps.
BInside the container image at /etc/seccomp/profiles/audit.json for that container
Incorrect
The profile must exist on the node, not in the image.
CRelative to the kubelet's seccomp directory, such as /var/lib/kubelet/seccomp
Correct
The seccomp tutorial loads profiles into the kubelet's seccomp directory (/var/lib/kubelet/seccomp/profiles) and refers to them with a path relative to it.
DOn the API server, which sends it to the kubelet
Incorrect
The API server does not distribute seccomp profiles; they must be present on each node.
A Localhost seccomp profile names a file that must already be on the node, given as a path relative to the kubelet's seccomp profile root. Profiles therefore have to be distributed to every node where the Pod can run.
According to the Kubernetes page on kernel security constraints, what does allowPrivilegeEscalation: false do besides preventing processes from gaining new capabilities?
AIt makes the container's root filesystem read-only for every process inside
BIt stops unprivileged users from loosening the applied seccomp profile
CIt drops all Linux capabilities from the container
DIt runs the container in a separate user namespace
Show the answer and why
AIt makes the container's root filesystem read-only for every process inside
Incorrect
That is readOnlyRootFilesystem.
BIt stops unprivileged users from loosening the applied seccomp profile
Correct
The page notes that, when set to false, it prevents processes from gaining new capabilities and restricts unprivileged users from changing the applied seccomp profile to a more permissive one.
CIt drops all Linux capabilities from the container
Incorrect
Dropping capabilities is done in the capabilities field.
DIt runs the container in a separate user namespace
Incorrect
User namespaces are a separate Pod-level feature; allowPrivilegeEscalation does not create one.
allowPrivilegeEscalation: false sets no_new_privs on the process, so it cannot gain privileges through setuid binaries or file capabilities, and an unprivileged process cannot loosen its seccomp filter.