Courseiva

CCNA Cks Supply Chain Questions

75 of 164 questions · Page 2/3 · Cks Supply Chain topic · Answers revealed

76
Matchingmedium

Match each Kubernetes API server flag to its security function.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Enables RBAC authorization

Comma-separated list of admission controllers to enable

Disables anonymous requests to the API server

Path to a CA file for verifying kubelet certificates

File containing PEM-encoded x509 RSA or ECDSA private or public keys for service account token signing

Why these pairings

Correct matches: --authorization-mode=RBAC enables RBAC; --anonymous-auth=false disables anonymous auth; --profiling=false disables profiling. Common confusions involve mixing authorization and authentication flags.

77
Multi-Selecthard

Which THREE of the following are valid approaches to prevent containers from running as root in a Kubernetes cluster?

Select 3 answers
A.Use Pod Security Admission with the 'restricted' profile
B.Set the container's entrypoint to 'sudo'
C.Use OPA/Gatekeeper with a constraint that requires runAsNonRoot: true
D.Use a Seccomp profile that blocks root system calls
E.Use Kyverno with a policy that validates runAsNonRoot
AnswersA, C, E

Pod Security Admission with the 'restricted' profile is a native Kubernetes admission controller that enforces the most stringent Pod Security Standard. It requires each container to set `securityContext.runAsNonRoot: true`, and it also fails pods if the image is configured to run as UID 0 unless an explicit non-root user is set. Because it is built into the kube-apiserver, it requires no extra components and can be enforced per-namespace via labels, making it a reliable and straightforward approach to prevent root execution.

Why this answer

Pod Security Admission (PSA) is a built-in Kubernetes admission controller that enforces Pod Security Standards (PSS). The 'restricted' profile, as defined in the Kubernetes documentation, requires that containers run with `runAsNonRoot: true`, preventing root execution at the admission level without needing external tools.

Exam trap

The CKS exam often tests the distinction between preventing root execution (via `runAsNonRoot` or user ID constraints) and limiting kernel capabilities (via Seccomp or AppArmor), leading candidates to mistakenly choose Seccomp as a root-prevention mechanism.

78
MCQhard

A user creates a Deployment with image 'alpine:3.18' and the Pod status is 'ErrImagePull'. The admin checks the image policy and sees that only images with SHA digests are allowed. What is the fix?

A.Enable the AlwaysPullImages admission controller
B.Change the image to 'alpine:latest'
C.Add a non-root user to the Dockerfile
D.Change the image to 'alpine@sha256:...'
AnswerD

Changing the image to alpine@sha256:... provides a content-addressable reference that uniquely pins the image manifest to its cryptographic digest. This mutability is eliminated: even if the original tag is moved, the deployment will always pull the exact verified image, and this format precisely satisfies the immutable-reference policy.

Why this answer

The cluster policy requires images to be identified by SHA digest rather than tags. Using an image reference like 'alpine@sha256:...' ensures the image is pulled by its immutable digest, bypassing tag-based resolution and satisfying the policy. This is a common supply chain security measure to prevent tag mutability and ensure image integrity.

Exam trap

The trap here is that candidates often confuse admission controllers (like AlwaysPullImages) with image reference policies, or assume that changing to a different tag (like 'latest') will bypass the restriction, when in fact the policy explicitly requires a digest-based reference.

How to eliminate wrong answers

Option A is wrong because enabling the AlwaysPullImages admission controller forces image pulls on every Pod creation but does not address the requirement to use SHA digests; the image tag 'alpine:3.18' would still be rejected by the policy. Option B is wrong because changing the tag to 'alpine:latest' still uses a mutable tag, which violates the policy that only SHA digests are allowed; it would also introduce a different security risk by pulling an unpredictable version. Option C is wrong because adding a non-root user to the Dockerfile improves container security but has no effect on image pull policies or digest requirements; the Pod would still fail with ErrImagePull due to the tag-based reference.

79
MCQhard

A cluster uses Kyverno to enforce that all images come from a trusted registry. A new Deployment fails with a message that the image 'docker.io/library/nginx:latest' is not allowed. What Kyverno policy rule likely caused this?

A.A validate rule that checks the container's resource limits
B.A validate rule that checks the image registry
C.A generate rule that creates a ConfigMap
D.A mutating rule that adds a label to the pod
AnswerB

A validate rule that checks the image registry is the correct enforcement mechanism in Kyverno. Such a rule can use a pattern, a deny condition, or CEL expression to inspect the image field and reject any container whose registry is not in an allowed list. When the rule evaluates to deny, Kubernetes admission control fails, and the pod or workload is not created. This directly matches the requirement to enforce that all images come from approved registries.

Why this answer

Kyverno uses validate rules to enforce policies by checking resource attributes against defined conditions. The error message indicates that the image 'docker.io/library/nginx:latest' was rejected because it does not come from a trusted registry. A validate rule with a pattern or deny condition that inspects the image field (e.g., `spec.containers[*].image`) and restricts it to a specific registry prefix (like `trusted-registry.io/*`) would cause this rejection.

Exam trap

The trap here is that candidates confuse Kyverno's 'validate' rules (which deny non-compliant resources) with 'mutate' or 'generate' rules, which do not block admission; the explicit rejection message indicates that a validate rule with a condition on the image registry denied the deployment.

How to eliminate wrong answers

Option A is wrong because a validate rule checking resource limits would reject a Pod based on CPU/memory constraints, not image registry origin. Option C is wrong because a generate rule creates or synchronizes resources (like ConfigMaps) but does not block or validate existing resources. Option D is wrong because a mutating rule modifies resources (e.g., adding labels) but does not enforce admission denials; it would not produce a rejection message.

80
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.

81
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.

82
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.

83
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.

84
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.

85
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.

86
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.

87
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.

88
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.

89
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.

90
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.

91
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.

92
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.

93
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.

94
MCQmedium

A DevOps engineer is setting up a CI/CD pipeline to scan container images for vulnerabilities. They want to fail the pipeline if any critical vulnerabilities are found. Which command should they use to scan the image and produce a JSON output that can be parsed?

A.trivy fs --severity CRITICAL --output json .
B.trivy image --severity CRITICAL --format json myimage:tag
C.trivy image --format table myimage:tag
D.trivy image --severity HIGH myimage:tag
AnswerB

This is the correct command because it targets the container image (`trivy image`), restricts results to only critical-severity vulnerabilities with `--severity CRITICAL`, and outputs machine-readable JSON via `--output json`. The JSON format is ideally suited for CI/CD automation, allowing the pipeline to parse vulnerability data programmatically (e.g., with jq) and enforce policy based on exact vulnerability IDs. It directly matches the requirement to scan the built image and flag critical issues.

Why this answer

`trivy image` scans a container image. Use `--severity CRITICAL` to filter only critical vulnerabilities and `--format json` to produce machine-parseable JSON output. This lets the pipeline parse the JSON and fail on critical vulnerabilities.

Note: `--output` specifies an output file path, not the report format.

Exam trap

The trap is confusing `trivy fs` with `trivy image`, and confusing `--format` (which controls output format, such as JSON) with `--output` (which specifies a file path). The command must use `--format json`, not `--output json`.

How to eliminate wrong answers

Option A is wrong because `trivy fs` scans a filesystem or directory, not a container image, so it would not scan the image layers for vulnerabilities. Option C is wrong because `--format table` produces human-readable table output, not JSON, making it unsuitable for programmatic parsing in a pipeline. Option D is wrong because `--severity HIGH` filters for high-severity vulnerabilities, not critical, and it lacks `--output json` so the output is not in JSON format.

95
Multi-Selectmedium

A security team is implementing supply chain security for their Kubernetes cluster. They want to ensure that only container images that have been signed and verified are deployed. They are evaluating admission controllers and tools. Which TWO of the following are valid approaches to enforce image signature verification at admission time? (Choose two.)

Select 2 answers
A.Use the PodSecurity admission controller with the restricted profile to enforce image signing.
B.Use the NodeRestriction admission controller to restrict which images can be pulled by kubelets.
C.Use the AlwaysPullImages admission controller to ensure images are always pulled and verified by the container runtime.
D.Use the ImagePolicyWebhook admission controller with a custom webhook that calls cosign verify.
E.Use a Kyverno policy that verifies image signatures using the verifyImages rule.
AnswersD, E

The ImagePolicyWebhook admission controller allows an external webhook to make admission decisions based on image policies. By implementing a webhook that uses cosign verify to check signatures, the cluster can enforce that only signed images are admitted. This is a valid and flexible approach, though it requires deploying and maintaining the webhook service.

Why this answer

Enforcing image signature verification at admission time can be achieved through the ImagePolicyWebhook admission controller with a custom webhook that calls cosign verify, or through a Kyverno policy that uses the verifyImages rule. Both approaches intercept pod creation and validate image signatures before allowing the pod. The other options do not provide signature verification capabilities.

Exam trap

The trap here is assuming that pod security or image pull policies can enforce signature verification, but they operate at different layers and do not validate cryptographic signatures.

96
MCQhard

An OPA/Gatekeeper constraint is configured to allow only images from 'trusted-registry.io'. A pod is created with image 'trusted-registry.io/app:v1' but is denied. Which is the MOST likely cause?

A.The constraint is only applied in the default namespace
B.The image tag is not pinned to a digest
C.The image is not signed
D.The constraint uses regex and the image does not match the pattern
AnswerD

The constraint is built with a regex pattern (or a glob converted to regex) that defines exactly which image registry paths are allowed, and Gatekeeper uses this pattern to match against the full image reference. If the image reference omits a required path segment, uses a different registry host, or otherwise fails to satisfy the regex anchors, the constraint fails and blocks the image. So the denial happens because the image string does not match the precise pattern that the constraint's `allowedPattern` (or similar field) enforces.

Why this answer

The most likely cause is that the OPA/Gatekeeper constraint uses a regex pattern to match allowed image registries, and the image 'trusted-registry.io/app:v1' does not match that pattern. Gatekeeper constraints often rely on Rego rules that check image strings against regex patterns; if the pattern is too restrictive or incorrectly defined (e.g., requiring a trailing slash or specific path), valid images can be denied. This is a common misconfiguration where the regex does not account for the full image reference format.

Exam trap

The CNCF-CKS exam often tests the misconception that image signing or digest pinning is required for registry-based constraints, when in fact the issue is typically a regex mismatch in the OPA policy.

How to eliminate wrong answers

Option A is wrong because Gatekeeper constraints are cluster-scoped by default and apply to all namespaces unless explicitly scoped via a namespaceSelector; a constraint that only applies to the default namespace would not deny pods in other namespaces, but the question does not specify a namespace restriction. Option B is wrong because pinning to a digest is a best practice for immutability but is not required by a constraint that only checks the registry; the constraint would still allow 'trusted-registry.io/app:v1' if the registry matches. Option C is wrong because image signing (e.g., with cosign or notary) is a separate security control; Gatekeeper constraints do not inherently verify signatures unless a custom rule is written to check attestations, and the question does not mention signature verification.

97
Multi-Selecthard

Which THREE are valid methods to verify the integrity and origin of a container image? (Select 3)

Select 3 answers
A.Trivy fs
B.Notary
C.Syft
D.Cosign verify
E.ImagePolicyWebhook
AnswersB, D, E

Notary is an open-source project that implements The Update Framework (TUF), providing a secure mechanism for publishing and verifying signed collections of content, including container images. It uses signed metadata files that list the cryptographic digests of image manifests and layers, enabling clients to confirm that the image came from the expected publisher and has not been altered. This makes Notary a valid, standards-based approach to image integrity and authenticity verification.

Why this answer

Notary is correct because it is a tool that enables the signing and verification of container images using The Update Framework (TUF), ensuring both integrity (the image has not been tampered with) and origin (the image was signed by a trusted publisher). It works by managing cryptographic signatures and metadata in a trusted collection, allowing clients to verify the signature chain before pulling an image.

Exam trap

The CNCF CKS exam often tests the distinction between tools that scan/inventory images (like Trivy fs and Syft) and tools that cryptographically verify image signatures (like Notary and Cosign), so the trap here is confusing vulnerability scanning or SBOM generation with integrity and origin verification.

98
MCQmedium

Which of the following is a best practice for Dockerfiles to improve supply chain security?

A.Use the latest tag for base images to get the newest features
B.Run the container as root by default
C.Use a distroless base image
D.Hardcode secrets directly in the Dockerfile
AnswerC

Distroless images ship only the application and its runtime dependencies, omitting package managers, shells and utilities. This shrinks the attack surface and removes tooling attackers commonly abuse after exploiting a container, strengthening supply chain security.

Why this answer

Distroless base images contain only the application and its runtime dependencies, significantly reducing the attack surface by eliminating package managers, shells, and other utilities that could be exploited. This aligns with the principle of minimalism in supply chain security, as fewer components mean fewer potential vulnerabilities and a smaller blast radius in case of compromise.

Exam trap

CKS often tests the misconception that 'latest' is safe because it's up-to-date, but the trap is that 'latest' is a mutable tag that undermines supply chain integrity and reproducibility, while distroless images are a concrete security hardening technique.

How to eliminate wrong answers

Option A is wrong because using the latest tag introduces unpredictability; the image can change without notice, potentially pulling in unverified or vulnerable versions, breaking reproducibility, and making it impossible to audit the exact base image used. Option B is wrong because running containers as root by default violates the principle of least privilege; if the container is compromised, an attacker gains root access on the host (via kernel namespace escape), and Kubernetes security contexts should enforce non-root users. Option D is wrong because hardcoding secrets directly in the Dockerfile embeds sensitive data in image layers, making them visible to anyone with access to the image registry or history, and violates best practices for secret management (e.g., using Kubernetes Secrets or external vaults).

99
MCQmedium

To verify a signed container image, which command should be used?

A.cosign verify myimage:latest
B.trivy verify myimage:latest
C.kubectl verify myimage:latest
D.cosign validate myimage:latest
AnswerA

cosign verify validates a container image's signature against the specified public key or keyless identity, confirming the image was signed by a trusted party and has not been tampered with. This is the standard Sigstore command for signature verification in supply-chain security workflows.

Why this answer

The `cosign verify` command is the correct tool for verifying the cryptographic signature of a signed container image stored in an OCI-compliant registry. Cosign, part of the Sigstore project, uses public-key or keyless signing to ensure image integrity and authenticity. The command checks the signature against the image manifest and the provided public key or Fulcio certificate, confirming that the image has not been tampered with since signing.

Exam trap

The CNCF-CKS exam often tests the distinction between `cosign verify` and `cosign validate` (or similar-sounding commands), where candidates confuse signature verification with attestation verification or assume a generic 'validate' verb exists, leading them to pick a plausible but incorrect option.

How to eliminate wrong answers

Option B is wrong because `trivy verify` is not a valid command; Trivy is a vulnerability scanner, not a signature verification tool, and it does not implement the Cosign verification protocol. Option C is wrong because `kubectl verify` does not exist; kubectl is for managing Kubernetes resources, not for verifying container image signatures. Option D is wrong because `cosign validate` is not a real subcommand; Cosign uses `verify` for signature verification, while `validate` is used in other tools like `cosign validate` for attestation verification (which is a different operation) or does not exist in the standard Cosign CLI.

100
Multi-Selectmedium

Which TWO of the following are valid methods to ensure only signed images are deployed in a Kubernetes cluster?

Select 2 answers
A.Configure ImagePolicyWebhook to require signatures
B.Set imagePullPolicy: Always
C.Run 'cosign verify' manually before every deployment
D.Use Kyverno policy to verify image signatures
E.Use NodeRestriction admission controller
AnswersA, D

This admission controller intercepts Pod creation requests and sends the image reference to an external webhook endpoint that performs signature verification (e.g., using sigstore/cosign) before returning an admission response. If the webhook rejects the image as unsigned, the API server refuses to admit the Pod, enforcing the policy cluster-wide at admission time. Because the check happens automatically during the API request lifecycle, it cannot be skipped by operators or developers.

Why this answer

The ImagePolicyWebhook admission controller can be configured to reject pods that reference images without valid signatures. It works by sending an admission review request to an external webhook service (e.g., using Cosign or Notary) that validates the image signature before allowing the pod to be created. This enforces signature verification at admission time, preventing unsigned images from running in the cluster.

Exam trap

CNCF CKS often tests the distinction between admission control mechanisms and runtime or manual verification; the trap here is that candidates may think manual verification (Option C) or pull policies (Option B) are sufficient for cluster-wide enforcement, when in fact only admission controllers or policy engines that intercept pod creation can guarantee that only signed images are deployed.

101
MCQmedium

In a CI/CD pipeline, at which stage should container image scanning be performed?

A.Only when a vulnerability is reported
B.After deployment to production
C.Before code commit
D.After building the image but before pushing to registry
AnswerD

Scanning after the image is built but before it is pushed to the registry is the earliest and most effective security gate because the image has been fully assembled into its final layered form. This stage lets you catch vulnerabilities in the base OS packages, application dependencies, and any added binaries before the image is stored in a trusted registry and made available for deployment. By blocking the push of non-compliant images, you keep vulnerable artifacts out of the supply chain entirely, ensuring that only vetted images reach Kubernetes clusters or runtime environments.

Why this answer

Container image scanning should be performed after building the image but before pushing it to the registry (Option D). This ensures that vulnerabilities are detected before the image is stored and distributed, preventing insecure images from being deployed. Scanning at this stage integrates security into the CI/CD pipeline, allowing teams to fail the build or trigger remediation before the image reaches production.

Exam trap

The CKS exam tests the concept of 'shift left' in security, and the trap here is that candidates may think scanning before code commit (Option C) is valid, but container images are not built until after the commit, so scanning must occur on the built image artifact.

How to eliminate wrong answers

Option A is wrong because scanning only when a vulnerability is reported is reactive and leaves the pipeline open to known vulnerabilities that could have been caught earlier. Option B is wrong because scanning after deployment to production violates the principle of shifting security left, as vulnerabilities are already running in the live environment, increasing risk and remediation cost. Option C is wrong because scanning before code commit is impractical—container images don't exist yet at that stage; scanning should occur on the built artifact, not source code.

102
Multi-Selecteasy

Which THREE of the following are valid flags for the 'trivy image' command to output results in different formats?

Select 3 answers
A.--format table
B.--format sarif
C.--format xml
D.--format yaml
E.--format json
AnswersA, B, E

The --format table flag explicitly selects the default human-readable output format for Trivy. It prints a tabular view with columns such as Library, Vulnerability, Severity, and Installed Version, making it ideal for terminal inspection but unsuitable for automated parsing. Using this flag is redundant if no format is specified, but it is valid and often used for clarity in scripts.

Why this answer

The `trivy image` command supports multiple output formats via the `--format` flag. The valid formats include `table`, `sarif`, and `json`, which are explicitly documented in Trivy's CLI help. `table` produces a human-readable summary, `sarif` outputs results in the SARIF (Static Analysis Results Interchange Format) standard, and `json` provides structured data for programmatic consumption.

Exam trap

The CKS exam often tests the distinction between Trivy's supported output formats and common but unsupported formats like XML or YAML, exploiting the assumption that any common data serialization format would be valid.

103
MCQeasy

A security best practice for Dockerfiles is to avoid hardcoded secrets. Which Dockerfile instruction is MOST likely to contain a hardcoded secret?

A.ENV
B.EXPOSE
C.RUN
D.FROM
AnswerA

ENV is the correct answer because it explicitly bakes environment variables into the image layer, and any secret placed there becomes visible in `docker history`, `docker inspect`, and persists for all containers started from that image. Hardcoded secrets in ENV are a classic anti-pattern because they are exposed to anyone who can pull the image, contrary to using BuildKit's `RUN --mount=type=secret` or secret-build hooks to keep credentials out of the final image.

Why this answer

The ENV instruction in a Dockerfile is used to set environment variables, which are often used to store sensitive data like API keys, passwords, or tokens. Hardcoding secrets in ENV is a security risk because the values persist in the image layers and can be extracted by anyone with access to the image, violating the principle of least privilege and secret management best practices.

Exam trap

A common pitfall is assuming that RUN is the most likely instruction to contain secrets because it executes commands, but the trap is that ENV is the instruction where secrets are most commonly and persistently hardcoded as environment variables, making it the primary security concern in Dockerfiles.

How to eliminate wrong answers

Option B (EXPOSE) is wrong because it only documents which ports the container listens on at runtime; it does not contain or store any secret values. Option C (RUN) is wrong because while it executes commands during build, any secrets passed via shell commands (e.g., using --build-arg) are not hardcoded in the Dockerfile itself; hardcoded secrets in RUN would be visible in the command string but are less common than ENV for persistent secret storage. Option D (FROM) is wrong because it specifies the base image and never contains secrets; it only defines the starting point for the build.

104
MCQmedium

A security audit reveals that a container image running in production contains a critical vulnerability (CVE-2024-1234). The image was built from a base image that had the vulnerability. What is the MOST effective long-term solution to prevent such issues?

A.Use a runtime security tool like Falco to detect exploitation attempts.
B.Patch the vulnerability by installing a security update inside the running container.
C.Add an admission controller that rejects images with vulnerabilities.
D.Rebuild the image using a patched base image and integrate vulnerability scanning into the CI pipeline.
E.Switch to a different container runtime that is immune to the vulnerability.
AnswerD

Rebuilding the image from a patched base image directly eliminates the vulnerable package from the image filesystem, ensuring that the vulnerability is no longer present in the artifact itself. Integrating vulnerability scanning into the CI pipeline shifts security left, allowing teams to detect and block vulnerable images before they are pushed to a registry or deployed. This approach is sustainable and reproducible, as every build is validated and known vulnerabilities trigger a pipeline failure, forcing developers to update dependencies promptly. It addresses the source of the issue rather than applying after-the-fact controls.

Why this answer

The most effective long-term solution because it addresses the root cause by rebuilding the image from a patched base image, eliminating the vulnerability at the source. Integrating vulnerability scanning into the CI pipeline ensures that future images are automatically checked for known CVEs before deployment, preventing vulnerable images from reaching production. This aligns with the principle of shifting security left in the software supply chain.

Exam trap

CNCF often tests the distinction between reactive runtime detection (Falco) and proactive supply chain fixes (rebuilding with patched base images), leading candidates to choose a runtime tool instead of addressing the root cause in the CI/CD pipeline.

How to eliminate wrong answers

Option A is wrong because Falco is a runtime security tool that detects exploitation attempts but does not prevent the vulnerable image from being deployed or fix the underlying vulnerability; it only provides detection and alerting. Option B is wrong because patching a running container is a temporary, non-repeatable fix that violates immutable infrastructure principles; the patch will be lost on container restart and does not address the base image issue. Option C is wrong because an admission controller that rejects images with vulnerabilities is a preventive control, but it does not fix the existing vulnerable images already in production and relies on a policy that may block legitimate updates; it also does not address the root cause in the CI pipeline.

Option E is wrong because switching to a different container runtime does not fix the vulnerability in the image; the runtime is not responsible for image content, and the CVE would still be present regardless of the runtime used.

105
Multi-Selectmedium

Which TWO of the following are best practices for Dockerfile security according to CKS guidelines?

Select 2 answers
A.RUN useradd -m myuser && USER root
B.COPY --from=builder /app /app
C.RUN adduser -D myuser && USER myuser
D.FROM scratch
E.FROM alpine:latest
AnswersC, D

This is correct because it creates a non-root user (myuser) without a password (using the -D flag for Alpine Linux) and then switches the active user to that account. All subsequent RUN, CMD, and ENTRYPOINT instructions execute as myuser, limiting the container to the least privileges needed for the application. This follows the security best practice of avoiding root inside containers, reducing the risk of privilege escalation if the application is compromised.

Why this answer

It creates a dedicated non-root user (`adduser -D myuser`) and then switches to that user with `USER myuser`, ensuring the container runs without root privileges. This aligns with the CKS best practice of least privilege, reducing the risk of privilege escalation if the container is compromised. The `-D` flag in Alpine's `adduser` creates a user without a password, which is appropriate for containerized environments.

Exam trap

CKS often tests the misconception that simply creating a user (without switching to it) or using multi-stage builds is sufficient for security, when the key is actually ensuring the container process runs as a non-root user.

106
MCQhard

A security policy requires that all container images must reference a specific SHA256 digest instead of a tag. You need to enforce this using Kyverno. Which Kyverno rule type and pattern would you use?

A.A generate rule that creates a ConfigMap with allowed digests
B.A mutate rule that replaces the image tag with a digest
C.A validate rule with a pattern that the image field matches '@sha256:'
D.A validate rule checking the annotation 'image.openshift.io/triggers'
AnswerC

A validate rule is the correct Kyverno mechanism because it asserts that the incoming resource matches a required pattern and rejects it otherwise. The pattern `spec.containers[*].image: "*@sha256:*"` enforces that every container image reference includes the immutable digest identifier, since a valid digest always appears as the `@sha256:` suffix. This directly implements the security policy at admission time, ensuring only images with explicit digests are deployed.

Why this answer

Kyverno's validate rules with a pattern can enforce that the image field in a Pod spec contains '@sha256:', ensuring only digest-based references are used. This directly meets the security policy requirement without altering the image reference or relying on external data.

Exam trap

The CKS exam often tests the distinction between validation and mutation rules, where candidates mistakenly choose a mutate rule to 'fix' the image reference instead of a validate rule to enforce the policy as written.

How to eliminate wrong answers

Option A is wrong because a generate rule creates resources like ConfigMaps but does not enforce image digest usage at admission time; it only provides data that must be referenced elsewhere. Option B is wrong because a mutate rule would automatically replace tags with digests, which violates the policy's intent to require explicit digest references from the user, not automatic remediation. Option D is wrong because the annotation 'image.openshift.io/triggers' is OpenShift-specific for triggering image updates, not a Kyverno mechanism for validating image references.

107
MCQmedium

An administrator runs 'trivy image --severity HIGH,CRITICAL myapp:v1.0' and sees no vulnerabilities. However, a security scan of the same image using a different tool reports several HIGH severity CVEs. What is the MOST likely reason for this discrepancy?

A.Trivy only scans the application layer and ignores the base image
B.The image was scanned with an outdated vulnerability database
C.Trivy cannot scan images stored in private registries
D.The other tool has false positives
AnswerB

Trivy's detection depends on its local vulnerability database. If that database is stale, newly published CVEs affecting the image's packages are absent from results, while a tool with a current feed flags them. Updating the database resolves the discrepancy.

Why this answer

Trivy relies on a local vulnerability database (e.g., the `trivy-db` or `trivy-java-db`) that must be regularly updated to include the latest CVE entries. If the database is outdated, Trivy will not detect recently published HIGH or CRITICAL vulnerabilities, even if they exist in the image. This is the most likely reason for the discrepancy, as a different tool may have a more current database.

Exam trap

Candidates may mistakenly think Trivy ignores base images or cannot handle private registries, when the real issue is an outdated CVE database. This discrepancy highlights that vulnerability scanners are only as good as their database freshness.

How to eliminate wrong answers

Option A is wrong because Trivy scans both the application layer and the base image layers (e.g., OS packages in Alpine, Ubuntu, etc.) by default; it does not ignore the base image. Option C is wrong because Trivy can scan images stored in private registries by using authentication (e.g., `--registry-auth` or environment variables like `TRIVY_USERNAME`/`TRIVY_PASSWORD`). Option D is wrong because while false positives are possible, the question states the other tool reports several HIGH severity CVEs, and the most likely explanation is an outdated database in Trivy, not systematic false positives in the other tool.

108
MCQhard

An admin runs 'kubectl run test-pod --image=nginx:latest' and the Pod is created but immediately enters 'CrashLoopBackOff'. 'kubectl describe pod test-pod' shows 'Back-off restarting failed container'. Which admission controller might cause this if misconfigured?

A.ValidatingAdmissionWebhook
B.MutatingAdmissionWebhook
C.PodSecurity
D.PersistentVolumeClaimResize
AnswerB

A MutatingAdmissionWebhook can modify the Pod spec before it is persisted, so even a simple nginx image could end up with an altered command, injected sidecar, or changed entrypoint. Once admitted, kubelet runs the mutated container, and if the mutation causes the main process to exit (e.g., a sidecar and no nginx, or an invalid argument), the resulting restart loop appears as CrashLoopBackOff. This explains why a mutation, not an outright rejection, matches the symptom.

Why this answer

A MutatingAdmissionWebhook can modify Pod specifications (e.g., injecting sidecar containers, changing image names, or adding init containers) before the Pod is persisted. If the webhook misconfigures the Pod—such as replacing the image with a non-existent one or adding a failing init container—the container may fail to start, causing a CrashLoopBackOff. The 'Back-off restarting failed container' message indicates the container itself is failing, which aligns with a mutation that breaks the Pod's runtime behavior.

Exam trap

The trap here is that candidates often assume a Pod entering CrashLoopBackOff must be due to a security policy (PodSecurity) or a validation rejection, but the 'Back-off restarting failed container' message indicates the container ran and failed, which points to a mutation that altered the container's runtime configuration, not a rejection or security constraint.

How to eliminate wrong answers

Option A is wrong because ValidatingAdmissionWebhooks only reject or allow requests based on validation logic; they do not modify the Pod spec, so they cannot cause a container to fail at runtime due to a misconfiguration injected into the Pod. Option C is wrong because PodSecurity (formerly PodSecurityPolicy) enforces security contexts (e.g., privileged, hostNetwork) and would either reject the Pod or allow it; it does not mutate the Pod spec to cause a container crash. Option D is wrong because PersistentVolumeClaimResize is an admission controller that handles PVC resize requests, not Pod creation or container execution, so it has no impact on a Pod entering CrashLoopBackOff.

109
MCQhard

A developer creates a Dockerfile with 'FROM ubuntu:latest'. The security team recommends using a minimal base image. Which change minimizes the attack surface?

A.FROM gcr.io/distroless/base:latest
B.FROM alpine:latest
C.FROM scratch
D.FROM ubuntu:20.04
AnswerA

Distroless images are purpose-built to contain only the libraries, system files, and configuration needed to run a specific runtime (such as glibc, CA certificates, and timezone data), with no shell, package manager, or debugging tools. This strips out utilities an attacker could leverage and keeps the filesystem small, while still supporting dynamically linked applications — unlike scratch, which requires you to provide every dependency yourself.

Why this answer

The `gcr.io/distroless/base:latest` image is a minimal, language-specific base image that contains only the essential runtime dependencies (e.g., glibc, libssl) and no package manager, shell, or utilities. This drastically reduces the attack surface by eliminating unnecessary binaries and tools that could be exploited. In contrast, `ubuntu:latest` includes a full userland with apt, bash, and other utilities, increasing the potential for privilege escalation or supply chain attacks.

Exam trap

The CKS exam often tests the misconception that `alpine:latest` is the most minimal secure base image, but distroless images are even more minimal because they strip out the shell and package manager entirely, which is the key differentiator for attack surface reduction.

How to eliminate wrong answers

Option B is wrong because `alpine:latest` uses musl libc and BusyBox, which still includes a shell and common Unix utilities, providing more surface area than a distroless image. Option C is wrong because `FROM scratch` is an empty image that lacks even the minimal runtime libraries (e.g., glibc) required by most compiled applications, making it impractical for anything other than static binaries. Option D is wrong because `ubuntu:20.04` is still a full Ubuntu distribution with a package manager, shell, and numerous pre-installed tools, offering no reduction in attack surface compared to `ubuntu:latest`.

110
MCQeasy

Which of the following is a static analysis tool for Kubernetes manifests?

A.Kubesec
B.Cosign
C.Trivy
D.Syft
AnswerA

Kubesec is a static analysis tool that directly inspects Kubernetes resource manifests (YAML/JSON) without requiring a live cluster. It applies security best-practice rules—such as disallowing privileged containers, ensuring runAsNonRoot is set, and checking for dangerous capabilities—and produces a weighted risk score from 0 to 10. This validates exactly the kind of declarative security posture that the question asks about.

Why this answer

Kubesec is a static analysis tool specifically designed to evaluate Kubernetes manifests against a set of security best practices. It parses YAML or JSON resource definitions and scores them based on pod security contexts, container privilege escalation, and other runtime hardening rules, without executing the manifests.

Exam trap

CNCF often tests the distinction between static analysis (Kubesec) and runtime scanning or signing tools (Cosign, Trivy, Syft), leading candidates to confuse Trivy's IaC scanning capability with a dedicated Kubernetes manifest static analyzer.

How to eliminate wrong answers

Option B is wrong because Cosign is a tool for signing and verifying container images and blobs, not for static analysis of Kubernetes manifests. Option C is wrong because Trivy is primarily a vulnerability scanner for container images, filesystems, and Git repositories, though it can scan IaC files, it is not a dedicated static analysis tool for Kubernetes manifests in the same focused manner as Kubesec. Option D is wrong because Syft is a software bill of materials (SBOM) generator that produces a list of packages and dependencies from container images or filesystems, not a static analysis tool for Kubernetes manifests.

111
MCQhard

You are configuring ImagePolicyWebhook admission controller to reject images not signed by a trusted authority. After deploying the webhook, you notice that pods are being rejected even for images that are properly signed. Which configuration change is MOST likely to fix this?

A.Increase the memory limit of the API server
B.Change the webhook from 'MutatingAdmissionWebhook' to 'ValidatingAdmissionWebhook'
C.Set failurePolicy to Ignore in the webhook configuration
D.Grant the webhook service account cluster-admin role
AnswerC

When the webhook cannot be reached, the API server rejects the request. Setting failurePolicy: Ignore allows pods to be admitted even if the webhook is unavailable, but this is a temporary fix. The root cause might be network connectivity to the webhook service.

Why this answer

The ImagePolicyWebhook admission controller uses a webhook to validate images. When the webhook is unreachable or returns an error, the default behavior is to reject the request. Setting `failurePolicy` to `Ignore` allows the API server to admit the pod when the webhook fails, which is necessary if the webhook is temporarily unavailable or misconfigured but images are properly signed.

Exam trap

The CKS exam often tests the distinction between `failurePolicy: Fail` (default) and `failurePolicy: Ignore`, tricking candidates into thinking the issue is with webhook type or permissions rather than the failure handling behavior.

How to eliminate wrong answers

Option A is wrong because increasing the API server's memory limit does not affect webhook communication or failure handling; it addresses resource constraints, not admission control logic. Option B is wrong because ImagePolicyWebhook is inherently a validating admission webhook, not a mutating one; changing the type does not resolve failures from webhook errors. Option D is wrong because granting cluster-admin to the webhook service account would not fix image rejection due to webhook failures; it would only escalate privileges unnecessarily and does not affect the admission controller's failure policy.

112
MCQhard

A pod is stuck in Pending state. 'kubectl describe pod' shows the event: '0/4 nodes are available: 1 node had taint {node-role.kubernetes.io/control-plane: }, that the pod didn't tolerate, 3 Insufficient memory.' The pod YAML does not specify any tolerations. Which command would allow the pod to schedule on the control-plane node?

A.kubectl taint nodes control-plane node-role.kubernetes.io/control-plane-
B.kubectl cordon control-plane
C.Edit the pod YAML to add tolerations for node-role.kubernetes.io/control-plane
D.kubectl delete pod --all
AnswerC

Control-plane nodes in kubeadm clusters carry the taint `node-role.kubernetes.io/control-plane:NoSchedule`, so a pod must include a matching toleration such as `tolerations: - key: node-role.kubernetes.io/control-plane, operator: Exists, effect: NoSchedule` before the scheduler will consider that node. Adding this toleration to the pod's YAML makes it explicitly accept the taint, allowing the pod to be placed on the control-plane node. This is the targeted, least-invasive solution because it only affects the workload that needs to run there, without altering node-level security settings.

Why this answer

The pod is failing to schedule on the control-plane node due to the `node-role.kubernetes.io/control-plane` taint, which by default prevents pods without a matching toleration from being scheduled. Since the pod YAML does not specify any tolerations, editing it to add a toleration for that taint (e.g., `tolerations: - key: node-role.kubernetes.io/control-plane operator: Exists`) explicitly allows the pod to run on the control-plane node, resolving the Pending state.

Exam trap

The trap here is that candidates often choose to remove the taint (Option A) because it seems like a quick fix, but the CKS exam emphasizes security best practices—taints are a security mechanism to isolate control-plane components, and removing them globally is insecure and unnecessary when a toleration can be added to the specific pod.

How to eliminate wrong answers

Option A is wrong because `kubectl taint nodes control-plane node-role.kubernetes.io/control-plane-` removes the taint from the control-plane node, which would allow all pods to schedule there, but this is a cluster-wide change that violates security best practices (control-plane nodes should remain tainted to isolate critical components). Option B is wrong because `kubectl cordon control-plane` marks the node as unschedulable, which would prevent any new pods from being scheduled on it, making the problem worse. Option D is wrong because `kubectl delete pod --all` deletes all pods in the current namespace, which does not address the scheduling issue caused by the taint and may disrupt running workloads.

113
MCQmedium

A Kubernetes cluster has Kyverno installed. A policy requires that all images come from a trusted registry 'trusted.example.com'. A Deployment uses the image 'nginx:latest'. When the Deployment is created, it is blocked. What Kyverno policy action is being used?

A.validate with failureAction: enforce
B.audit
C.mutate
D.generate
AnswerA

A validate policy with failureAction: enforce configures Kyverno to actively reject any resource that does not match the required pattern. When the validation rule fails, the admission webhook returns a denial to the API server, preventing the resource from being created or updated. This is the correct way to make a 'require' policy block non-compliant resources.

Why this answer

Kyverno's `validate` policy with `failureAction: enforce` is the mechanism that blocks resource creation when validation rules are violated. In this scenario, the policy checks that the image comes from `trusted.example.com`, and since `nginx:latest` does not match, the policy actively denies the Deployment, which is the behavior of `enforce` mode.

Exam trap

The trap here is that candidates confuse `audit` mode (which reports violations but allows creation) with `enforce` mode (which blocks creation), or they mistakenly think `mutate` can block resources when it only modifies them after admission.

How to eliminate wrong answers

Option B is wrong because `audit` mode only generates a policy violation report without blocking the resource; the Deployment would be created but flagged. Option C is wrong because `mutate` policies modify resources to meet policy requirements (e.g., prepending a registry prefix) rather than blocking them; they do not deny creation. Option D is wrong because `generate` policies create additional resources (e.g., NetworkPolicies) based on triggers, not block or validate existing resources.

114
MCQmedium

A DevOps engineer runs 'trivy image myapp:latest' and finds a critical CVE in the base image. Which Dockerfile change would BEST address this?

A.Use an Alpine base image with the latest tag
B.Set USER root in the Dockerfile
C.Switch to a distroless base image with a SHA digest
D.Add a non-root user in the Dockerfile
AnswerC

Switching to a distroless base image (e.g., gcr.io/distroless) removes package managers, shells, and unused utilities, leaving only the minimal OS libraries required to run the application, which dramatically reduces the number of installable components where CVEs can live. Pinning the image by SHA-256 digest instead of a mutable tag ensures that the exact same immutable image is used every time, preventing a future 'latest' tag update from silently introducing known vulnerabilities or malicious code.

Why this answer

Switching to a distroless base image with a SHA digest (e.g., gcr.io/distroless/base@sha256:...) eliminates the vulnerable packages present in the original base image because distroless images contain only the minimal runtime dependencies (e.g., glibc, libssl) and no package manager or shell, drastically reducing the attack surface. Pinning the image by SHA digest ensures immutability and prevents the base image from being silently updated to a version that reintroduces the same or different vulnerabilities, which is critical for supply chain security.

Exam trap

The CKS exam often tests the misconception that simply using a smaller base image (like Alpine) or adding a non-root user is sufficient to fix a CVE, when in reality the vulnerability must be removed from the image entirely, and distroless with a SHA digest achieves that by eliminating the vulnerable components and pinning the image hash.

How to eliminate wrong answers

Option A is wrong because using an Alpine base image with the latest tag does not guarantee the CVE is fixed; the latest tag is mutable and can point to a vulnerable version, and Alpine itself may still contain the vulnerable package or a different CVE. Option B is wrong because setting USER root in the Dockerfile increases the attack surface by running the container with root privileges, which exacerbates security risks rather than addressing the vulnerable base image. Option D is wrong because adding a non-root user does not remediate the CVE in the base image; it only reduces the blast radius of a compromise but leaves the vulnerable packages intact.

115
MCQhard

A Kyverno policy is written to require all images to use SHA256 digests instead of tags. The policy uses a 'validate' rule with 'pattern' on 'spec.containers[*].image'. Which pattern would match an image reference like 'registry.example.com/myapp@sha256:abc123...'?

A.*@sha256*
B."*@*"
C."*@sha256:*"
D."*:*"
AnswerC

Correct: In Kyverno's wildcard matching, this pattern requires an image reference that has '@sha256:' followed by any sequence of characters. That means the immutable part of the reference is a SHA256 digest with the standard 'algorithm:digest' format; the leading '*' accounts for the registry/repository/name, and the trailing '*' consumes the 64-character hex digest. This precisely ensures images are pinned to a SHA256 digest and not to a mutable tag.

Why this answer

Option C ('*@sha256:*') correctly matches image references using SHA256 digest. It ensures the digest algorithm is exactly 'sha256' followed by a colon and digest. Option A ('*@sha256*') is too permissive as it matches any image reference containing 'sha256' as a substring, potentially allowing other algorithms like 'sha256-extra'.

Option B ('*@*') matches any digest algorithm, not specifically SHA256. Option D ('*:*') matches tags, not digests. Therefore, only C meets the requirement.

Exam trap

Candidates may mistakenly choose option A, noticing that both A and C contain 'sha256', but A is not strict enough and would match non-SHA256 digests. The difference between a wildcard match and a colon is subtle but crucial.

How to eliminate wrong answers

Option A is wrong because '*@sha256:*' is identical to Option C, but the question lists it as a duplicate with the same text, and only one is marked as correct; the correct answer is the one explicitly labeled [CORRECT]. Option B is wrong because '*@*' would match any image reference containing an '@' symbol, including those with non-SHA256 digests (e.g., 'registry.example.com/myapp@sha512:...' or even 'user@host' patterns), which does not enforce the SHA256 requirement. Option D is wrong because '*:*' matches image references using tags (e.g., 'registry.example.com/myapp:latest'), not digests, and would allow non-compliant tag-based references.

116
MCQeasy

In a CI/CD pipeline, which step is MOST effective for detecting known vulnerabilities in a container image before deployment?

A.Run a vulnerability scan on the container image
B.Check the image size
C.Run unit tests on the application code
D.Lint the Dockerfile
AnswerA

Scanning the built image against known vulnerability databases detects outdated packages and CVEs before the image reaches a registry or runtime. This catches known flaws at the earliest pipeline stage, whereas signing, linting or runtime monitoring do not identify known vulnerabilities in image contents.

Why this answer

Running a vulnerability scan on the container image (Option A) is the most effective step because it directly checks the image layers and installed packages against known Common Vulnerabilities and Exposures (CVEs) databases, such as the National Vulnerability Database (NVD). This identifies security flaws in base images and dependencies before deployment, which is a core requirement of supply chain security in Kubernetes.

Exam trap

The CKS exam often tests the distinction between static analysis of build files (like Dockerfile linting) and runtime or image-level security scanning, leading candidates to mistakenly choose linting as a vulnerability detection method.

How to eliminate wrong answers

Option B is wrong because checking the image size only helps with storage and performance optimization, not with detecting known vulnerabilities. Option C is wrong because unit tests validate application logic and functionality, not the security posture of the container image or its dependencies. Option D is wrong because linting the Dockerfile checks for syntax errors and best practices in the build instructions, but it does not scan the resulting image for known CVEs.

117
MCQeasy

Which command scans a Docker image for CVEs using Trivy?

A.trivy cve myapp:latest
B.trivy check myapp:latest
C.trivy image myapp:latest
D.trivy scan myapp:latest
AnswerC

The trivy image subcommand targets a container image reference directly, pulling and scanning its layers against vulnerability databases to report CVEs. Other Trivy subcommands scan filesystems, repositories, or configuration files, so only this form satisfies the image-scanning requirement.

Why this answer

`trivy image` is the specific Trivy subcommand used to scan a container image for vulnerabilities (CVEs). Trivy does not have a `cve`, `check`, or `scan` subcommand; the correct syntax is `trivy image <image-name>`.

Exam trap

The CNCF exam often tests the exact subcommand syntax of security tools like Trivy, expecting candidates to know that `trivy image` is the correct command, not generic verbs like `scan` or `check`.

How to eliminate wrong answers

Option A is wrong because `trivy cve` is not a valid Trivy subcommand; Trivy uses `trivy image` to scan images for CVEs. Option B is wrong because `trivy check` does not exist; Trivy's subcommand for image scanning is `image`, not `check`. Option D is wrong because `trivy scan` is not a valid subcommand; the correct subcommand is `image`.

118
Multi-Selectmedium

Which TWO of the following are valid methods to verify the integrity of a container image in a Kubernetes supply chain? (Select 2)

Select 2 answers
A.Signing the image with Cosign and verifying the signature before deployment
B.Running the container in a separate namespace
C.Using a SHA256 digest instead of a tag in the image reference
D.Scanning the image for vulnerabilities using Trivy
E.Using a base image with the latest tag
AnswersA, C

Cosign image signing, backed by Sigstore, creates a cryptographic signature bound to the image digest and the signer's identity (such as an OIDC email). Verifying that signature before deployment confirms both that the image content is unmodified and that it came from an approved publisher, making it a true provenance and tamper-evidence check. Without this step, an attacker who compromises a registry can swap a signed-looking tag for a malicious image and the cluster would have no way to detect the substitution.

Why this answer

Cosign is a tool for signing container images using cryptographic keys, and verifying the signature before deployment ensures that the image has not been tampered with since it was signed. This provides integrity and authenticity in the software supply chain, as the signature can be validated against a trusted public key or a keyless identity (e.g., via Fulcio).

Exam trap

The CNCF CKS exam often tests the distinction between integrity verification (e.g., signatures, digests) and other security practices like vulnerability scanning or namespace isolation, leading candidates to mistakenly select scanning or isolation as valid integrity checks.

119
Multi-Selectmedium

Which TWO of the following are valid admission controllers in Kubernetes? (Select TWO)

Select 2 answers
A.PodSecurityPolicy
B.MutatingAdmissionWebhook
C.ImagePolicyWebhook
D.AdmissionReview
E.OPA
AnswersB, C

MutatingAdmissionWebhook is a built-in admission controller that intercepts API requests after authentication and authorisation, invoking external webhooks to modify objects before persistence. It satisfies the stem's requirement for a valid admission controller, operating in the mutating phase alongside validating webhooks. Kubernetes enables it by default in the recommended admission plugin set.

Why this answer

MutatingAdmissionWebhook, is a valid admission controller that intercepts API requests and can modify them before they are persisted. It is part of the dynamic admission control mechanism, allowing external webhooks to mutate objects. Option C, ImagePolicyWebhook, is also a valid admission controller that enforces image policy checks by querying an external webhook before admitting a pod, making it a key component for supply chain security.

Exam trap

The CKS exam often tests the distinction between deprecated/removed features (like PodSecurityPolicy) and still-valid controllers, and the trap here is that candidates may confuse OPA as a built-in admission controller when it is actually an external policy engine integrated via webhooks.

120
MCQhard

Refer to the exhibit. A cluster has the ClusterImagePolicy shown. A developer creates a pod with an image from registry.example.com/myapp:v1, which was built and signed by a GitHub Actions workflow that is NOT defined in the policy (different workflow). Which behavior will occur when the pod is created?

A.The pod is admitted because keyless signing does not enforce identity matching.
B.The pod is admitted because the policy only applies to images with a tag 'v*'.
C.The pod is admitted because the image is from the allowed registry.
D.The pod is denied because the image's signer identity does not match the policy.
AnswerD

Cosigned's admission webhook evaluates both the image reference and the signature's identity. Because the keyless certificate presented for this image has an issuer or subject that does not appear in the policy's `identities` array, the admission request is denied. This is the expected behavior when identity matching is enforced, so the pod cannot be admitted.

Why this answer

The ClusterImagePolicy enforces that images must be signed by a specific identity (the GitHub Actions workflow defined in the policy). The image from registry.example.com/myapp:v1 was signed by a different workflow, so the signer identity does not match the policy's required identity. Sigstore keyless signing verifies the OIDC identity embedded in the signature, and if the identity does not match the policy's `issuer` and `subject` patterns, the admission controller denies the pod.

Exam trap

CNCF often tests the misconception that keyless signing only verifies the signature's cryptographic validity, not the identity of the signer, but in reality the policy enforces identity matching via OIDC claims.

How to eliminate wrong answers

Option A is wrong because keyless signing does enforce identity matching via OIDC tokens; the policy specifies allowed identities, and mismatches cause denial. Option B is wrong because the policy uses a regex `v*` which matches any tag starting with 'v', and 'v1' matches that pattern, so the policy applies. Option C is wrong because the policy restricts based on signer identity, not just registry; the image is from an allowed registry but the signer identity does not match, so admission is denied.

121
MCQmedium

During a CI/CD pipeline, you run 'trivy image myapp:latest' and get a high number of vulnerabilities. What is the BEST action to reduce the vulnerability count?

A.Increase CPU and memory limits for the container
B.Switch to a distroless base image
C.Sign the image with Cosign
D.Remove all environment variables from the Dockerfile
AnswerB

Switching to a distroless base image removes unnecessary components like shells, package managers, and other utilities, leaving only the runtime dependencies required to run the application. This significantly reduces the number of installed packages that could contain known vulnerabilities, directly shrinking the attack surface and the scanner's vulnerability count. Distroless images are an established best practice for minimizing software footprint, making this the correct remediation.

Why this answer

Distroless base images contain only the essential runtime dependencies (e.g., glibc, libssl) and exclude package managers, shells, and other utilities that are common sources of CVEs. By switching to a distroless image, you drastically reduce the attack surface and the number of packages that Trivy scans, directly lowering the vulnerability count without changing application code.

Exam trap

CKS often tests the misconception that operational changes (like resource limits or environment variable removal) can fix supply chain vulnerabilities, when the correct answer always involves reducing the software footprint or patching dependencies at the image build level.

How to eliminate wrong answers

Option A is wrong because increasing CPU and memory limits does not affect the software packages or libraries present in the container image; resource limits only control runtime behavior, not the vulnerability surface. Option C is wrong because signing an image with Cosign provides integrity and provenance verification but does not remove or patch any vulnerabilities within the image. Option D is wrong because removing environment variables from the Dockerfile reduces the risk of secret leakage but has no impact on the vulnerability count reported by Trivy, which scans filesystem packages and libraries.

122
MCQmedium

A security engineer runs 'kubesec scan deployment.yaml' and receives a score of -1. What does this score indicate?

A.The deployment passed all security checks
B.The deployment is not secure and needs immediate attention
C.The scan failed due to an error or invalid YAML
D.The deployment has critical vulnerabilities
AnswerC

The kubesec CLI returns a score of -1 when it cannot complete a scan, typically because the input is invalid YAML, the file cannot be read, or the manifest is missing required fields. This is explicitly defined as a scan failure, not a security score. In practice, you should verify the deployment YAML with a YAML linter or run kubesec with verbose output to see the underlying parse error before concluding anything about the security posture.

Why this answer

In kubesec, a score of -1 indicates that the scan could not complete successfully, typically due to an error in the YAML file (e.g., invalid syntax, malformed structure) or a failure in the scanning process itself. Kubesec returns scores from 0 to 10 for valid deployments, where higher scores indicate better security; -1 is a special sentinel value reserved for scan failures, not a security assessment.

Exam trap

The CKS exam often tests the distinction between error codes and security scores; the trap here is that candidates assume -1 means 'worst security' (like a negative vulnerability score) rather than recognizing it as a sentinel value for scan failure.

How to eliminate wrong answers

Option A is wrong because a score of -1 is not a valid security score; kubesec returns positive scores (0-10) for successful scans, and a passed scan would yield a score of at least 0, not -1. Option B is wrong because -1 does not indicate a security posture; it signals a scan failure, and a deployment needing immediate attention would receive a low positive score (e.g., 0 or 1) with specific vulnerability details. Option D is wrong because critical vulnerabilities are reported with a low positive score (e.g., 0-2) and detailed findings, not a -1 error code.

123
Multi-Selectmedium

Which TWO of the following are valid methods to supply a Kubernetes manifest to kubesec for static analysis?

Select 2 answers
A.cat deploy.yaml | kubesec scan /dev/stdin
B.kubectl apply -f deploy.yaml | kubesec scan
C.kubectl get deployment myapp -o yaml | kubesec scan
D.kubesec scan deploy.yaml
E.kubesec curl https://example.com/deploy.yaml
AnswersA, D

Piping the manifest via cat to kubesec scan with /dev/stdin works because kubesec accepts a file path argument, and /dev/stdin is a valid readable path on Linux. This satisfies the requirement to supply the manifest through standard input rather than a named file.

Why this answer

Option A is correct because kubesec scan accepts a manifest from standard input, and piping the file content via cat deploy.yaml | kubesec scan /dev/stdin explicitly supplies the manifest through /dev/stdin, which kubesec reads as the scan target. Option D is correct because kubesec scan deploy.yaml passes the manifest file path directly as an argument, which is the standard documented way to scan a local YAML file. Option B is not valid because kubectl apply -f deploy.yaml sends the manifest to the Kubernetes API server and outputs the server's apply result, not the original manifest, so kubesec would receive non-manifest text.

Option C is not valid because kubectl get deployment myapp -o yaml returns a live Deployment object with runtime metadata and status fields, not a clean input manifest, and kubesec expects a manifest to analyze. Option E is not valid because kubesec has no curl subcommand; it cannot fetch a remote URL in that manner.

Exam trap

Kubernetes often tests the distinction between static analysis tools that operate on manifest files versus cluster state commands, leading candidates to mistakenly think `kubectl get` output is equivalent to a raw manifest for scanning.

124
Multi-Selecteasy

Which THREE of the following are best practices for writing Dockerfiles?

Select 3 answers
A.Minimize the number of layers
B.Use the 'latest' tag for base images
C.Use specific tags or digests for base images
D.Install all packages that might be needed for debugging
E.Run containers as a non-root user
AnswersA, C, E

Each Dockerfile instruction creates a layer, so combining related commands with && and cleaning caches in the same RUN reduces layer count. Fewer layers shrink the final image and reduce the attack surface, satisfying the best-practise goal of lean, minimal container images.

Why this answer

Option A is correct because minimizing the number of layers reduces image size and improves build efficiency, typically achieved by combining related RUN commands with && and cleaning up caches in the same layer. Option C is correct because pinning base images to specific tags or SHA256 digests ensures reproducible, deterministic builds and protects against unexpected upstream changes or supply-chain attacks. Option E is correct because running containers as a non-root user (via the USER instruction) follows the principle of least privilege and limits the impact of a container breakout.

Option B is wrong because the 'latest' tag is mutable and non-deterministic, leading to inconsistent builds and potential breakage. Option D is wrong because installing unnecessary debugging packages bloats the image, increases the attack surface, and violates the practice of keeping images minimal.

Exam trap

The CNCF CKS exam often tests the misconception that using the 'latest' tag is convenient and safe, but the trap is that 'latest' is a mutable tag that breaks deterministic builds and can silently introduce supply chain vulnerabilities.

125
MCQmedium

You are tasked with ensuring that all container images in your cluster are scanned for vulnerabilities before being deployed. You have set up Trivy in your CI/CD pipeline and want to enforce that only images with no critical vulnerabilities are allowed. Which admission controller should you configure to reject pods using non-compliant images?

A.ImagePolicyWebhook
B.ValidatingAdmissionWebhook
C.PodSecurityPolicy (PSP)
D.ResourceQuota
AnswerA

ImagePolicyWebhook is a dedicated Kubernetes admission controller that intercepts Pod creation and update requests, extracts the image references, and sends them to an external HTTP(S) backend for a decision based on scanning or policy rules. It is designed specifically for image policy enforcement, with configuration for fail-open/fail-closed behavior and support for default image policies like allowed registries or prefixes. This makes it the standard mechanism to reject images that fail security scanning before they are scheduled.

Why this answer

The ImagePolicyWebhook admission controller is specifically designed to evaluate container images against an external policy backend (e.g., Trivy) before they are admitted into the cluster. It intercepts pod creation requests, sends the image reference to an external webhook for validation, and rejects pods whose images contain critical vulnerabilities. This makes it the correct choice for enforcing image vulnerability policies at admission time.

Exam trap

A common trap is confusing ImagePolicyWebhook (purpose-built for image policy) with ValidatingAdmissionWebhook (generic validation). Candidates often choose ValidatingAdmissionWebhook because they overlook the specialized nature of ImagePolicyWebhook for image scanning enforcement in Kubernetes.

How to eliminate wrong answers

Option B (ValidatingAdmissionWebhook) is wrong because it is a generic mechanism for any custom validation logic, but it is not purpose-built for image scanning policies; you would have to implement the entire image-checking logic yourself, whereas ImagePolicyWebhook is designed specifically for this use case. Option C (PodSecurityPolicy) is wrong because it enforces security context constraints (e.g., privileged containers, host namespaces) and does not evaluate container image vulnerabilities. Option D (ResourceQuota) is wrong because it only limits resource consumption (CPU, memory, storage) and has no capability to inspect or reject images based on vulnerability scans.

126
MCQhard

A security engineer wants to ensure that all container images in a Kubernetes cluster have a non-root user. Which admission controller can enforce this requirement?

A.ServiceAccount
B.PodSecurityPolicy (deprecated)
C.NodeRestriction
D.Kyverno
AnswerD

Kyverno is a Kubernetes-native policy engine running as an admission controller that can validate, mutate, and generate resources. It can define a ClusterPolicy requiring runAsNonRoot: true on every pod, and can even automatically mutate pods to set a non-root security context. Kyverno uses validating and mutating webhooks to intercept pod creation, making it a robust and current tool for guaranteeing container images run as non-root across the cluster.

Why this answer

Kyverno is a Kubernetes-native policy engine that can enforce custom admission control rules, such as requiring containers to run as a non-root user. Unlike deprecated or built-in controllers, Kyverno allows you to define fine-grained policies (e.g., `autogen-check`) that validate or mutate Pod specs to ensure `runAsNonRoot: true` or `runAsUser: >0`.

Exam trap

A common pitfall is selecting PodSecurityPolicy because it was the traditional way to enforce security policies, but it is deprecated and removed in newer Kubernetes versions. The question specifically asks for an admission controller that can enforce a non-root user requirement. Built-in controllers like ServiceAccount or NodeRestriction cannot enforce custom pod security policies.

Kyverno (and OPA/Gatekeeper) are Kubernetes-native policy engines that act as dynamic admission controllers to validate or mutate pod specs. Candidates often overlook that Kyverno is a valid admission controller for such custom rules.

How to eliminate wrong answers

Option A is wrong because ServiceAccount is an API object for identity and access control, not an admission controller that can enforce container image user requirements. Option B is wrong because PodSecurityPolicy is deprecated and removed in Kubernetes v1.25, and while it could enforce non-root users, it is no longer a viable solution for current CKS exam objectives. Option C is wrong because NodeRestriction is an admission controller that limits Node API modifications, not container security contexts.

127
Multi-Selectmedium

Which TWO of the following are benefits of using an SBOM (Software Bill of Materials) in supply chain security?

Select 2 answers
A.It allows for faster image pulls
B.It helps in identifying known vulnerabilities in dependencies
C.It ensures license compliance by tracking open source components
D.It reduces the size of the container image
E.It automatically patches vulnerabilities
AnswersB, C

An SBOM enumerates every direct and transitive dependency along with its version range, enabling deterministic cross-checks against vulnerability intelligence feeds such as CVE records, OSV entries, or vendor security advisories. This turns an opaque binary artifact into a structured inventory that tools can map to known flaws, so remediation prioritization and impact analysis become reproducible rather than based on guesswork.

Why this answer

An SBOM lists all components and dependencies in a software artifact, enabling teams to cross-reference against vulnerability databases (e.g., NVD) to identify known CVEs. This proactive identification is a core supply chain security practice, as mandated by frameworks like SLSA and EO 14028.

Exam trap

A common trap in the CKS exam is confusing the passive inventory role of an SBOM with active security actions or performance improvements. Candidates may think an SBOM directly patches vulnerabilities or speeds up image pulls, but it is merely a list of components that enables other tools to act.

128
MCQhard

You have a Kyverno policy that validates image registries. The policy should allow only images from `myregistry.example.com`. Which Kyverno rule field should be used to check the image registry?

A.mutate
B.resources
C.imageRegistry
D.generate
AnswerC

`imageRegistry` is a dedicated field inside a Kyverno `validate` rule that defines a list of allowed image registries (e.g., `registry.mycompany.com/*`). When a target resource like a Pod is created or updated, Kyverno evaluates all container image references against this allowlist and denies admission if any image comes from a registry outside the list. This is the correct and direct way to enforce image registry validation, making it the answer for this question.

Why this answer

The `imageRegistry` field in a Kyverno policy rule is specifically designed to validate image registries by matching the registry hostname against a pattern. In this case, setting `imageRegistry: "myregistry.example.com/*"` ensures only images from that registry are allowed, blocking others at admission time.

Exam trap

The trap here is that candidates confuse `imageRegistry` with `resources` or think validation is done via `mutate`, but only `imageRegistry` directly checks the registry portion of the container image reference.

How to eliminate wrong answers

Option A is wrong because `mutate` is used to modify resources during admission, not to validate image registries. Option B is wrong because `resources` defines which Kubernetes resource types the rule applies to (e.g., Pods), not the image registry check. Option D is wrong because `generate` creates new resources based on a template, not for validation of existing image registries.

129
MCQmedium

A security scan report shows that a container image has several high-severity CVEs. The team wants to implement automated scanning in CI/CD pipeline. Which tool would you recommend for scanning container images in a CI pipeline?

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

Trivy scans container images for OS package and language dependency vulnerabilities, integrating cleanly into CI pipelines as a CLI step that fails builds on high-severity CVEs. It satisfies the automated scanning requirement without needing a running cluster or registry-side agent, unlike runtime-focused alternatives.

Why this answer

Trivy is a comprehensive, open-source vulnerability scanner specifically designed for container images, filesystems, and Git repositories. It integrates seamlessly into CI/CD pipelines, detects high-severity CVEs by cross-referencing image layers against multiple vulnerability databases (e.g., NVD, Red Hat, Alpine), and provides actionable remediation advice. This makes it the correct choice for automated scanning of container images in a CI pipeline.

Exam trap

The CKS exam often tests the distinction between SBOM generation tools (like Syft) and vulnerability scanners (like Trivy), causing candidates to confuse the purpose of each tool in the supply chain security context.

How to eliminate wrong answers

Option A (Syft) is wrong because Syft is a software bill of materials (SBOM) generation tool, not a vulnerability scanner; it catalogs packages in an image but does not check for CVEs. Option B (Checkov) is wrong because Checkov is a static analysis tool for Infrastructure as Code (IaC) misconfigurations (e.g., Terraform, Kubernetes manifests), not for scanning container images for vulnerabilities. Option C (Kubesec) is wrong because Kubesec is a security risk assessment tool for Kubernetes pod specifications (YAML/JSON), evaluating pod security contexts and capabilities, not container image vulnerabilities.

130
Multi-Selectmedium

Which TWO of the following are valid methods to verify the integrity of a container image? (Select 2)

Select 2 answers
A.Use trivy image to check for vulnerabilities
B.Compare the image SHA digest with a known good digest
C.Use cosign verify to check the image signature
D.Use docker history to view layers
E.Use kubectl describe pod to check image details
AnswersB, C

Comparing the image SHA digest against a known-good digest is a direct integrity check because the digest is a cryptographic hash of the image manifest and content. If the computed digest matches the trusted reference, the image is byte-for-byte identical to the verified original; any modification would produce a different digest. This is considered a reliable and tamper-evident method, provided the known-good digest comes from a trusted source and is transmitted over a secure channel.

Why this answer

Container images are identified by a content-addressable digest (SHA256 hash) that uniquely represents the image manifest. Verifying that the SHA digest of a pulled image matches a known good digest from a trusted source ensures the image has not been tampered with or altered in transit, as any change to the image layers or configuration would result in a different digest.

Exam trap

Candidates often confuse vulnerability scanning tools (which find known vulnerabilities) with integrity verification methods (which detect tampering). Trivy is a vulnerability scanner, not an integrity verification tool.

131
MCQeasy

Which of the following is a best practice for securing container images in a CI/CD pipeline?

A.Using a minimal base image such as Alpine
B.Using the 'latest' tag for all base images to ensure the newest features
C.Running the container as root to avoid permission issues
D.Installing all available packages to ensure the application has all dependencies
AnswerA

A minimal base image such as Alpine dramatically reduces the attack surface because it contains only the essential binaries and libraries needed to run the application. With fewer packages, there are fewer known CVEs to patch, and the smaller footprint also limits the potential impact of a compromised dependency. Distroless images take this further by removing package managers and shells, but Alpine is a practical middle ground that keeps the image size small and the tooling familiar.

Why this answer

Using a minimal base image like Alpine reduces the attack surface by minimizing the number of installed packages and potential vulnerabilities.

132
MCQmedium

An administrator wants to enforce that only images signed by a trusted key can run in the cluster. They have configured cosign and want to use a Kubernetes admission controller. Which tool should they deploy?

A.Helm
B.Kube-bench
C.Prometheus
D.Kyverno with a verifyImages rule
AnswerD

Kyverno is a purpose-built policy engine that functions as a dynamic admission controller in the API request path. Its verifyImages rule integrates with Sigstore/cosign to check an image's cryptographic signature against configured public keys or Keyless authorities, and it can reject or patch any Pod that uses an unsigned or improperly signed image. Kyverno's rule can be scoped to namespaces and supports both failure modes, making it the appropriate tool to enforce this requirement.

Why this answer

Kyverno is a Kubernetes-native policy engine that can enforce admission controls via policies. Its `verifyImages` rule uses Cosign to check that container images are signed with a trusted public key before allowing them to run, making it the correct tool for this use case.

Exam trap

The trap here is that candidates may confuse tools like Helm or Prometheus with admission controllers, but only Kyverno (or OPA/Gatekeeper with custom rules) can enforce image signature verification via Cosign at the admission webhook level.

How to eliminate wrong answers

Option A is wrong because Helm is a package manager for Kubernetes used to deploy applications, not an admission controller for enforcing image signature verification. Option B is wrong because kube-bench is a security benchmark tool that checks clusters against CIS benchmarks, but it does not enforce admission policies or verify image signatures. Option C is wrong because Prometheus is a monitoring and alerting toolkit, not an admission controller; it cannot intercept API requests to validate image signatures.

133
MCQmedium

An administrator wants to verify that an image was signed by a specific key before deploying. Which Cosign command should be used?

A.cosign verify --key mykey.pub myimage
B.cosign sign --key mykey.pub myimage
C.cosign download myimage
D.cosign attest --predicate mypredicate myimage
AnswerA

The `cosign verify` command retrieves the image's signature artifacts from the registry and cryptographically verifies them against the specified public key. It recomputes the image digest from the manifest and checks that the signed payload matches, ensuring the image has not been modified. A successful exit status indicates the signature is valid and trusted, confirming the image was signed by the holder of the corresponding private key. This is the appropriate command for an administrator to verify provenance before deployment.

Why this answer

The `cosign verify` command is used to verify the signature of a container image against a public key. By specifying `--key mykey.pub`, the administrator confirms that the image was signed with the corresponding private key before it can be deployed, ensuring supply chain integrity.

Exam trap

CNCF often tests the distinction between signing (`cosign sign`) and verifying (`cosign verify`), expecting candidates to know that `verify` is the correct command for checking an image's signature before deployment, not `sign` or `attest`.

How to eliminate wrong answers

Option B is wrong because `cosign sign` creates a signature, not verifies one; it requires a private key to sign an image, not a public key. Option C is wrong because `cosign download` retrieves the image's signatures or attestations but does not perform verification against a specific key. Option D is wrong because `cosign attest` attaches an in-toto attestation to an image, which is a separate process from verifying an existing signature.

134
MCQeasy

A DevOps team wants to ensure that only signed images from a trusted registry are deployed in the cluster. They plan to use a webhook to intercept pod creation. Which tool is best suited for this task?

A.kubectl with --validate flag
B.Helm with signed charts
C.etcd with encryption at rest
D.Kyverno with a verifyImages rule
E.Prometheus with alerting rules
AnswerD

Kyverno with a verifyImages rule is correct because Kyverno runs as a dynamic admission controller inside the cluster and intercepts Pod creation requests before they are persisted. The verifyImages rule leverages cosign to check each container image's digital signature against the specified public keys, failing admission if the signature is missing or invalid. This enforces a policy that only signed images from trusted registries can run, at the exact point Kubernetes decides to allow the workload.

Why this answer

Kyverno is a Kubernetes-native policy engine that can enforce image signature verification via its `verifyImages` rule. It intercepts pod creation through a dynamic admission webhook, checking that container images are signed with a trusted key (e.g., using Sigstore/Cosign) before the pod is admitted. This directly meets the requirement to only allow signed images from a trusted registry.

Exam trap

The trap here is that candidates confuse Helm chart signing (which verifies chart provenance) with container image signing, leading them to select Option B, even though Helm does not verify the images inside the chart at pod creation time.

How to eliminate wrong answers

Option A is wrong because `kubectl --validate` only performs client-side schema validation on the manifest, not image signature verification. Option B is wrong because Helm with signed charts ensures the Helm chart itself is signed, but does not verify the container images referenced within the chart at deployment time. Option C is wrong because etcd encryption at rest protects data stored in etcd (e.g., Secrets) but does not intercept pod creation or verify image signatures.

Option E is wrong because Prometheus with alerting rules monitors metrics and triggers alerts, but cannot enforce admission control or block pod creation based on image signatures.

135
MCQeasy

Which tool is specifically designed to generate a Software Bill of Materials (SBOM) for container images?

A.Checkov
B.Cosign
C.Syft
D.Trivy
AnswerC

Syft scans container image layers and filesystem contents to produce an SBOM listing installed packages and their versions, satisfying the requirement to catalogue image components. Unlike general vulnerability scanners, its purpose is SBOM generation itself, outputting SPDX or CycloneDX formats directly from image references.

Why this answer

Syft is an open-source CLI tool developed by Anchore specifically for generating Software Bill of Materials (SBOMs) from container images and filesystems. It uses static analysis to catalog packages, libraries, and dependencies in formats such as CycloneDX and SPDX, making it the correct choice for this purpose.

Exam trap

CNCF-CKS often tests the distinction between tools that generate SBOMs (Syft) and tools that scan for vulnerabilities (Trivy) or sign images (Cosign), leading candidates to confuse Trivy's vulnerability scanning capability with SBOM generation.

How to eliminate wrong answers

Option A is wrong because Checkov is a static analysis tool for infrastructure as code (IaC) security scanning, not an SBOM generator. Option B is wrong because Cosign is a tool for signing and verifying container image signatures using Sigstore, not for generating SBOMs. Option D is wrong because Trivy is a vulnerability scanner for containers and filesystems, and while it can produce SBOM-like output, it is not specifically designed as a dedicated SBOM generator like Syft.

136
MCQhard

You are the lead security engineer for a large financial institution. The organization runs a Kubernetes cluster with 500+ microservices. The supply chain security team has implemented the following measures: (1) All images are built from a minimal base image (distroless) and scanned with Trivy before being pushed to a private registry. (2) Images are signed using cosign with a key stored in a hardware security module (HSM). (3) Kyverno policies enforce that only signed images from the private registry can run, and also enforce that containers run as non-root. (4) A binary authorization (binauthz) style admission controller verifies attestations. Recently, a critical vulnerability (CVE-2024-0001) was discovered in a popular open-source library used by several microservices. The library is included as a dependency in the base image. The vulnerability is remotely exploitable and has a CVSS score of 9.8. The security team needs to remediate this quickly. They have already patched the library and updated the base image. What is the BEST course of action to ensure all running pods use the new image?

A.Update the image tag in each Deployment's spec to point to the new patched image, then perform a rolling update. The admission controller will verify signatures and attestations for the new image.
B.SSH into each node, pull the new image, and use kubectl exec to update the library inside running containers.
C.Temporarily disable the admission controller that verifies signatures and then update the image tags.
D.Delete all running pods and let the ReplicaSets recreate them from the existing image.
AnswerA

Updating the image tag in each Deployment's PodTemplateSpec is the correct declarative approach: it triggers a rolling replacement of the underlying ReplicaSets, so old pods are terminated only after new ones become Ready. During pod creation, the cluster's validating/mutating admission controller (e.g., Kyverno or OPA via cosign) checks the image's cryptographic signature and attestations; if the patched image is signed and passes policy, the update proceeds. This ensures every pod runs a verified, patched image with zero downtime.

Why this answer

Updating the image tag in each Deployment triggers a rolling update, which creates new pods with the patched image. The admission controller (Kyverno) will verify the cosign signature and binary authorization attestation for the new image, ensuring supply chain security is maintained. This approach is the standard Kubernetes method for deploying image updates while preserving security controls.

Exam trap

CNCF often tests the misconception that manual intervention (SSH, exec) or disabling security controls is acceptable for urgent fixes, when in fact the correct path is to update the deployment manifest and let Kubernetes orchestrate the change while keeping all security checks active.

How to eliminate wrong answers

Option B is wrong because SSHing into nodes and using kubectl exec to update libraries inside running containers violates the immutable infrastructure principle; changes are ephemeral and lost on pod restart, and this bypasses admission controls, leaving pods unsigned and unverified. Option C is wrong because temporarily disabling the admission controller that verifies signatures creates a window where unsigned or malicious images could be deployed, undermining the entire supply chain security posture. Option D is wrong because deleting pods without updating the image tag causes ReplicaSets to recreate pods from the existing (vulnerable) image, failing to remediate the CVE.

137
MCQeasy

A developer runs 'trivy image myapp:latest' and gets a report with several CRITICAL CVEs. Which action would BEST address the supply chain security risk?

A.Ignore the report because the container is running in a sandboxed environment
B.Run 'trivy image myapp:latest --severity CRITICAL' to filter out lower severity findings
C.Rebuild the image using a minimal base image like distroless or alpine with no CVEs
D.Add a network policy to block outbound traffic from the container
AnswerC

Rebuilding the image with a minimal base image such as distroless or a slim alpine variant is the correct remediation because these bases contain only the runtime dependencies needed for the application, eliminating the package manager, shell, and other tools that often carry CVEs. By reducing the number of installed packages, the attack surface is significantly minimized, and many reported vulnerabilities are directly removed from the image. This approach addresses the root cause of the vulnerabilities rather than masking them, and aligns with the security principle of least privilege applied to container images.

Why this answer

Rebuilding the image using a minimal base image like distroless or Alpine directly eliminates the vulnerable packages that cause the CRITICAL CVEs. This addresses the root cause of the supply chain risk by ensuring the container image contains only the necessary runtime dependencies, reducing the attack surface and removing known vulnerabilities at the source.

Exam trap

This exam often tests the misconception that security controls like sandboxing or network policies are sufficient to fix vulnerabilities, when in fact supply chain security requires eliminating the vulnerable components at the image build stage.

How to eliminate wrong answers

Option A is wrong because a sandboxed environment (e.g., gVisor, Kata Containers) does not eliminate the underlying vulnerable code; it only adds a layer of isolation, and a CRITICAL CVE could still be exploited if the sandbox is bypassed or if the vulnerability allows privilege escalation. Option B is wrong because filtering the report with '--severity CRITICAL' only hides lower-severity findings from the output; it does not fix or remove the actual vulnerabilities, leaving the supply chain risk unaddressed. Option D is wrong because a network policy blocking outbound traffic (e.g., Kubernetes NetworkPolicy) mitigates data exfiltration but does not remove or patch the vulnerable packages; the CRITICAL CVE could still be exploited locally or via inbound attacks.

138
MCQhard

A security engineer is configuring a Kubernetes cluster to enforce that all container images are signed by a trusted key before deployment. They deploy the Cosign admission controller and configure it with a public key. However, they notice that some pods are still being admitted with unsigned images. What is the most likely cause?

A.The Cosign admission controller is configured with a failure policy of Ignore, so if the webhook is unavailable, pods are admitted.
B.The container runtime is configured to skip signature verification for images from certain registries.
C.The admission controller's namespaceSelector or objectSelector excludes the namespaces where these pods are being created.
D.The public key used by the admission controller is incorrect, causing it to fail open and admit all images.
AnswerC

Admission webhooks can be scoped using namespaceSelector or objectSelector. If the namespaces where unsigned pods are deployed are excluded, the webhook will not be invoked for those pods. This would allow unsigned images to be admitted without verification. This is a common misconfiguration that can silently bypass enforcement.

Why this answer

Admission webhooks can be selectively applied based on namespace or object labels. If the namespaceSelector in the webhook configuration does not match the namespaces where pods are created, the webhook is bypassed. This allows unsigned images to be admitted.

Checking the webhook's scope is essential to ensure it applies cluster-wide or to all relevant namespaces.

Exam trap

The trap here is overlooking the scope of admission webhooks, assuming that deploying the webhook automatically enforces the policy everywhere without checking selectors.

139
MCQmedium

An administrator wants to ensure that only signed container images are deployed in the cluster. Which admission controller can be used to enforce this policy?

A.ServiceAccount
B.AlwaysPullImages
C.ImagePolicyWebhook
D.NodeRestriction
AnswerC

ImagePolicyWebhook is a built-in Kubernetes admission controller that forwards pod creation requests to an external HTTPS endpoint for image policy evaluation. That webhook can verify signatures against a trusted key, rejecting unsigned images before they are admitted to the cluster.

Why this answer

The ImagePolicyWebhook admission controller allows a cluster to enforce a policy that only signed container images are deployed by intercepting image creation requests and validating them against an external webhook. This webhook can check image signatures (e.g., using Notary or Cosign) before admitting the pod, making it the correct choice for enforcing signed image policies.

Exam trap

The exam often tests the distinction between admission controllers that enforce image pull behavior (AlwaysPullImages) versus those that enforce image content validation (ImagePolicyWebhook), leading candidates to confuse pull policies with signature verification.

How to eliminate wrong answers

Option A is wrong because ServiceAccount admission controller manages service account tokens and automounting, not image validation or signature enforcement. Option B is wrong because AlwaysPullImages forces image pulls on every pod creation but does not verify image signatures or enforce signing policies. Option D is wrong because NodeRestriction limits node kubelet permissions to prevent privilege escalation, not image content or signature checks.

140
MCQhard

A CI pipeline fails with the error 'cosign: error: unable to verify image: no matching signatures' when running 'cosign verify --key pubkey.pem myregistry/myapp:latest'. The image was previously signed with a private key. What is the MOST likely cause?

A.The public key is incorrect
B.The registry requires authentication
C.Cosign is not installed correctly
D.The image tag was overwritten without signing
AnswerD

Cosign stores the signature for an image in a separate tag derived from the image digest (e.g., `sha256-<digest>.sig`) and does not use mutable tags like `latest` for signature lookup. When a CI pipeline overwrites a tag with a newly built image, the new image digest does not yet have a corresponding signature tag, so `cosign verify` finds no signatures for that digest. The old signature is still present but only applies to the previous digest, so verification fails with a "missing signature" error until the new image is explicitly signed after the push.

Why this answer

If the image tag was overwritten (e.g., pushed again without signing), the old signatures are lost and the new image is unsigned.

141
MCQmedium

Which command is used to sign a container image with Cosign and store the signature in an OCI registry?

A.cosign docker-sign myimage:latest
B.cosign verify --key cosign.pub myimage:latest
C.cosign sign --key cosign.key myimage:latest
D.cosign attach signature --key cosign.key myimage:latest
AnswerC

Cosign's sign subcommand with --key uses the supplied private key to create a signature, then uploads it to the same OCI registry as the image, attaching it as a referrer artefact. This satisfies the requirement to store the signature in the registry itself.

Why this answer

`cosign sign --key cosign.key myimage:latest` is the standard Cosign command to sign a container image using a private key and store the resulting signature in the OCI registry as an attached artifact (e.g., a `.sig` layer). This command generates a signature that is automatically pushed to the same registry alongside the image, enabling verification without external storage.

Exam trap

CNCF-CKS often tests the distinction between signing (`cosign sign`) and verifying (`cosign verify`), and the trap here is that candidates may confuse the `attach` subcommand (used for non-signature artifacts) with the signing process, or assume a non-existent `docker-sign` subcommand is valid.

How to eliminate wrong answers

Option A is wrong because `cosign docker-sign` is not a valid Cosign subcommand; the correct command for signing is `cosign sign`. Option B is wrong because `cosign verify --key cosign.pub myimage:latest` is used to verify an existing signature, not to create one. Option D is wrong because `cosign attach signature` is not a real Cosign command; Cosign uses `cosign sign` to generate and attach the signature, and `cosign attach` is used for attaching other artifacts (like SBOMs), not signatures.

142
MCQmedium

A security admin wants to ensure that only images signed with a specific key can run in the cluster. Which admission controller should be enabled?

A.PodSecurityPolicy
B.MutatingAdmissionWebhook
C.ImagePolicyWebhook
D.ValidatingAdmissionWebhook
AnswerC

ImagePolicyWebhook is the correct choice because it is a specialized admission controller that delegates image policy decisions to an external webhook service. The kubelet sends the image name, pull spec, and associated metadata to the configured webhook, which can then validate cryptographic signatures or enforce a deny-list/allow-list before the image is used. This design is the native Kubernetes mechanism for ensuring that only signed or pre-approved images enter the cluster, and it operates at the point of image resolution rather than at pod creation.

Why this answer

The ImagePolicyWebhook admission controller allows a cluster to enforce that only container images signed with a specific key can run. It intercepts pod creation requests and queries an external webhook to verify the image signature before admitting the pod. This directly meets the requirement of restricting execution to signed images.

Exam trap

The distinction between generic webhook controllers (MutatingAdmissionWebhook and ValidatingAdmissionWebhook) and the purpose-built ImagePolicyWebhook is a common point of confusion. Candidates often mistakenly choose a generic webhook when the question explicitly asks for the admission controller designed for image signature enforcement.

How to eliminate wrong answers

Option A is wrong because PodSecurityPolicy (deprecated in Kubernetes 1.21 and removed in 1.25) enforces security context constraints (e.g., privilege escalation, host namespaces) but does not verify image signatures. Option B is wrong because MutatingAdmissionWebhook can modify objects (e.g., inject sidecars) but does not inherently validate image signatures; it could be used to call an external service, but the question asks for the admission controller that should be enabled, and ImagePolicyWebhook is the dedicated built-in controller for image signature verification. Option D is wrong because ValidatingAdmissionWebhook validates objects against custom logic but, like MutatingAdmissionWebhook, is a generic webhook mechanism; the specific built-in controller for image signature enforcement is ImagePolicyWebhook.

143
MCQmedium

A security engineer needs to verify that a container image stored in a private OCI registry has not been tampered with before allowing it to run in a production cluster. The image was signed using Cosign with a key pair. The engineer has the public key. Which command should the engineer use to verify the signature?

A.cosign verify --key cosign.pub --registry-token $(cat token) registry.example.com/app:1.0
B.cosign verify --key cosign.pub --insecure registry.example.com/app:1.0
C.cosign verify-blob --key cosign.pub registry.example.com/app:1.0
D.cosign verify --key cosign.pub registry.example.com/app:1.0
AnswerD

This command uses Cosign to verify the signature of the specified image against the provided public key. It checks that the image was signed with the corresponding private key and that the signature is valid, ensuring integrity and authenticity. This is the correct approach for verifying a Cosign signature when the public key is available.

Why this answer

To verify a Cosign signature on a container image, the cosign verify command is used with the public key and the image reference. This checks the signature against the image digest. The other options either use the wrong subcommand, an invalid flag, or an unnecessary insecure flag that does not contribute to signature verification.

Exam trap

The trap here is confusing cosign verify with cosign verify-blob, which is meant for verifying signatures on arbitrary blobs rather than container images in a registry.

144
MCQeasy

Which of the following is a best practice for securing a Dockerfile?

A.Hardcode API keys as environment variables
B.Use a minimal base image like alpine
C.Run the container as root to avoid permission issues
D.Use the latest tag for all images
AnswerB

Alpine's musl libc and BusyBox base provide a far smaller package set than Debian or Ubuntu images, removing compilers, shells and unused daemons. Fewer installed packages mean fewer exploitable CVEs, satisfying the stem's Dockerfile hardening requirement.

Why this answer

Using a minimal base image like Alpine reduces the attack surface by including only essential packages and libraries, minimizing the number of potential vulnerabilities. This aligns with the principle of least functionality and is a key supply chain security practice for container images.

Exam trap

CKS often tests the misconception that running as root is simpler or more reliable, but the CKS emphasizes that containers should never run as root unless absolutely necessary, and even then, capabilities should be dropped.

How to eliminate wrong answers

Option A is wrong because hardcoding API keys as environment variables in a Dockerfile exposes secrets in plaintext within the image layers, making them accessible to anyone with image access; secrets should be injected at runtime via Kubernetes Secrets or a secrets manager. Option C is wrong because running the container as root violates the principle of least privilege, increasing the risk of host compromise if the container is breached; containers should run with a non-root user (e.g., via USER directive). Option D is wrong because using the 'latest' tag introduces unpredictability and potential supply chain risks, as it can silently pull a different, possibly vulnerable, version of the image; pinned digests or version tags should be used for reproducibility and security.

145
Multi-Selectmedium

Which TWO are recommended practices for securing a CI/CD pipeline that builds container images? (Select two.)

Select 2 answers
A.Run containers as root for compatibility
B.Scan images for vulnerabilities before pushing
C.Store secrets in the image as environment variables
D.Sign images after building
E.Use the 'latest' tag for simplicity
AnswersB, D

Scanning images for vulnerabilities before pushing catches known CVEs in dependencies and base layers while the artefact is still inside the pipeline, preventing flawed images from reaching the registry. This satisfies the requirement to gate builds on security findings before publication.

Why this answer

Option B is correct because scanning images for vulnerabilities before pushing them to a registry catches known CVEs in OS packages and application dependencies early, preventing flawed artifacts from ever entering the pipeline's downstream stages or production. Option D is correct because signing images after building (e.g., with Docker Content Trust/Notary or Sigstore cosign) provides cryptographic provenance and integrity, letting admission controllers verify that only trusted, unmodified images are deployed. Option A is wrong because running containers as root violates least-privilege and dramatically increases the impact of a container escape; images should use a non-root USER.

Option C is wrong because baking secrets into image layers as environment variables exposes them to anyone who can pull or inspect the image; secrets belong in a vault or secret manager injected at runtime. Option E is wrong because the mutable 'latest' tag makes builds non-reproducible and can silently pull a different, potentially compromised image; immutable, versioned tags or digests should be used.

Exam trap

The CKS exam often tests the distinction between build-time security (scanning, signing) and runtime security (least privilege, secret injection), and the trap here is that candidates may think storing secrets as environment variables is acceptable because it works, ignoring that they persist in image layers and are accessible via `docker history`.

146
MCQeasy

Which of the following is a best practice for securing container images in a Kubernetes environment?

A.Store secrets directly in the Dockerfile for convenience
B.Run containers as root to have full access to system resources
C.Use the latest tag for all base images to get the newest features
D.Use minimal base images such as distroless or Alpine to reduce attack surface
AnswerD

Minimal images like distroless or Alpine strip out package managers, shells, and extraneous system utilities, removing the tools an attacker would need to pivot, write files, or download additional binaries after breaking into a process. Distroless images provide a root filesystem with only the application and its runtime libraries, offering no interactive shell; Alpine achieves small size and a lower CVE count through BusyBox and musl libc. For maximum benefit, pair minimal images with non-root execution, read-only root filesystems, and regular scanning, since even minimal images still require patching for vulnerabilities in their included libraries.

Why this answer

Minimal base images like distroless or Alpine contain only the application and its runtime dependencies, drastically reducing the number of packages, libraries, and utilities that could contain vulnerabilities or be exploited post-compromise. Fewer components mean a smaller attack surface, faster pulls, and easier vulnerability management. This is a foundational CKS best practice for supply chain and runtime security.

Exam trap

CKS often tests the misconception that convenience (secrets in Dockerfile, root, latest tag) is acceptable; the exam expects minimal base images and least-privilege principles.

How to eliminate wrong answers

Option A is wrong because storing secrets in a Dockerfile embeds them in image layers, where they persist in the image history and can be extracted by anyone with pull access; secrets should be injected at runtime via Kubernetes Secrets or external vaults. Option B is wrong because running as root violates least privilege and allows container escape exploits to gain host-level access; CKS recommends non-root users and read-only root filesystems. Option C is wrong because the 'latest' tag is mutable and non-deterministic, breaking reproducibility and potentially pulling a vulnerable or incompatible version; images should be pinned by digest or immutable tag.

147
MCQmedium

An administrator wants to ensure that only images from a trusted registry 'myregistry.io' can run in the cluster. Which admission controller should be configured?

A.NodeRestriction
B.MutatingAdmissionWebhook
C.ImagePolicyWebhook
D.PodSecurity
AnswerC

ImagePolicyWebhook forwards image admission requests to an external HTTPS endpoint that approves or rejects them. Configuring it to permit only myregistry.io images enforces the trusted-registry constraint at admission time, blocking pods referencing any other registry.

Why this answer

The ImagePolicyWebhook admission controller enforces that only images from a trusted registry (e.g., 'myregistry.io') can run. It does this by querying an external webhook to validate the image source against a policy. Options A, B, and D are incorrect: NodeRestriction restricts node API access, MutatingAdmissionWebhook can mutate pods but is not specifically designed for image registry control, and PodSecurity handles pod security contexts, not image source validation.

Exam trap

The trap here is that candidates often confuse PodSecurity (or deprecated PodSecurityPolicy) with image registry control, but PodSecurity only handles pod-level security contexts, not image source validation. ImagePolicyWebhook is the correct admission controller for this purpose.

How to eliminate wrong answers

Option A is wrong because NodeRestriction limits the kubelet's ability to modify node and pod objects, not image source validation. Option B is wrong because MutatingAdmissionWebhook can modify resources but is not specifically designed for image policy enforcement; it would require custom logic and does not natively provide registry whitelisting. Option D is wrong because PodSecurity (formerly PodSecurityPolicy) enforces security context constraints (e.g., privilege escalation, SELinux) but does not validate the registry from which images are pulled.

148
MCQmedium

A CI/CD pipeline builds a Docker image and pushes it to a registry. To ensure supply chain security, the pipeline should scan the image for vulnerabilities before deployment. Which of the following is the correct command to scan a local Docker image using Trivy?

A.trivy fs --image myimage:latest
B.trivy image myimage:latest
C.trivy scan myimage:latest
D.trivy check myimage:latest
AnswerB

This is the correct command because `trivy image` is the dedicated subcommand for scanning container images. It resolves `myimage:latest` from the local Docker daemon cache or a remote registry, analyzes the image layers and SBOM of OS packages (like Alpine, Debian, CentOS) and language-specific dependencies (pip, npm, cargo, etc.), and then compares them against the Trivy vulnerability database to report CVEs. In a CI/CD pipeline, running this after `docker build` but before `docker push` catches vulnerable images before they are published.

Why this answer

`trivy image` is the specific subcommand used to scan a local Docker image for vulnerabilities. Trivy requires the `image` subcommand followed by the image name and tag (e.g., `myimage:latest`) to analyze the image layers and report CVEs. This command directly integrates with the local Docker daemon to access the image.

Exam trap

The CKAD/CKS exam often tests the distinction between Trivy subcommands (e.g., `image` vs. `fs` vs. `repo`) to catch candidates who assume a generic `scan` or `check` verb exists, mirroring common misconceptions from other tools like Docker Scout or Snyk.

How to eliminate wrong answers

Option A is wrong because `trivy fs` scans a filesystem or directory, not a Docker image; it is used for scanning local file paths or repositories, not container images. Option C is wrong because `trivy scan` is not a valid subcommand; Trivy uses specific subcommands like `image`, `fs`, `repo`, or `config` depending on the target. Option D is wrong because `trivy check` is not a valid subcommand; Trivy does not have a `check` command—the correct subcommand for image scanning is `image`.

149
MCQeasy

Which tool is commonly used to generate a Software Bill of Materials (SBOM) for a container image?

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

Syft is a dedicated, purpose-built SBOM generator from Anchore that catalogs packages from container images, OCI layout archives, and directory trees. It supports a broad range of ecosystems — dpkg, RPM, APK, Python, npm, Go modules, Java archives, etc. — and emits standardized formats like SPDX, CycloneDX, and its own custom Syft format. Because its sole mission is to inventory components with precise versions and package URLs, syft is the authoritative and most commonly used tool for generating SBOMs in cloud-native environments.

Why this answer

Syft is a CLI tool purpose-built for generating Software Bill of Materials (SBOMs) from container images and filesystems. It uses static analysis to extract package metadata (e.g., dpkg, RPM, APK, Python, Node.js) and outputs the SBOM in formats like CycloneDX or SPDX, which are the industry standards for supply chain transparency.

Exam trap

The CKS exam often tests the distinction between tools that generate SBOMs (Syft) and tools that scan for vulnerabilities (Trivy) or sign images (Cosign), leading candidates to confuse Trivy's SBOM capability with its primary vulnerability scanning role.

How to eliminate wrong answers

Option A is wrong because kubesec is a static analysis tool for Kubernetes resource manifests (YAML/JSON), not for generating SBOMs from container images. Option C is wrong because Trivy is primarily a vulnerability scanner that can also produce SBOMs as a secondary feature, but it is not the tool commonly associated with SBOM generation; Syft is the dedicated SBOM generator. Option D is wrong because cosign is used for signing and verifying container image signatures (e.g., using Sigstore), not for generating SBOMs.

150
MCQmedium

A security admin wants to ensure that all container images in a Kubernetes cluster are scanned for known vulnerabilities before being deployed. Which tool can be integrated into a CI/CD pipeline to scan container images for CVEs?

A.kubesec
B.Trivy
C.Helm
D.kubectl
AnswerB

Trivy scans container image layers and installed OS packages against vulnerability databases, reporting CVEs before deployment. Integrating it into the CI/CD pipeline satisfies the stem's requirement to detect known vulnerabilities pre-deployment, unlike admission controllers or runtime tools that act only after images reach the cluster.

Why this answer

Trivy is a comprehensive vulnerability scanner for container images, filesystems, and Git repositories. It can be integrated into CI/CD pipelines to automatically scan container images for known CVEs before deployment, making it the correct choice for this requirement.

Exam trap

The trap here is that candidates may confuse static analysis tools for Kubernetes manifests (like kubesec) with container image vulnerability scanners, or assume that Helm or kubectl have built-in scanning capabilities, when in fact they do not.

How to eliminate wrong answers

Option A is wrong because kubesec is a static analysis tool for Kubernetes resource manifests, not a container image vulnerability scanner. Option C is wrong because Helm is a package manager for Kubernetes that deploys applications via charts, not a vulnerability scanner. Option D is wrong because kubectl is the Kubernetes command-line tool for interacting with the cluster API, not a tool for scanning container images for CVEs.

← PreviousPage 2 of 3 · 164 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Cks Supply Chain questions.