Question 378 of 510
Scripting, Containers and AutomationmediumMultiple SelectObjective-mapped

Quick Answer

The correct answer is to use minimal base images like Alpine or distroless and to run containers as a non-root user. Minimal images drastically reduce the attack surface by eliminating unnecessary packages, libraries, and utilities that an attacker could exploit, while running as a non-root user enforces the principle of least privilege by ensuring that even if the application is compromised, the attacker cannot gain root-level control over the container or the host. On the CompTIA SecurityX CAS-004 exam, this question tests your understanding of container hardening within the broader domain of secure DevOps practices; a common trap is to focus only on network segmentation or image scanning, forgetting that the image itself and the runtime user context are foundational. A helpful memory tip is “lean and low” — keep the image lean with minimal content and keep the process running with low privileges.

CAS-004 Reduce container attack surface Practice Question

This CAS-004 practice question tests your understanding of scripting, containers and automation. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A DevOps engineer is automating the deployment of a web application using containers. Which of the following security practices should be implemented to reduce the attack surface of the containers? (Select TWO.)

Question 1mediummulti select
Full question →

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Run containers as a non-root user

Running containers as a non-root user (option A) is a fundamental security best practice because it limits the privileges available to processes inside the container. If an attacker compromises the application, they will not have root access to the host or the container runtime, reducing the potential for privilege escalation or host-level damage. This aligns with the principle of least privilege, which is critical for container security.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Build images with embedded database credentials

    Why it's wrong here

    Embedding secrets in images is insecure; they should be injected at runtime.

  • Expose port 22 for SSH debugging

    Why it's wrong here

    Exposing SSH adds an attack vector and is unnecessary in production.

  • Grant all Linux capabilities to the container

    Why it's wrong here

    Granting all capabilities weakens isolation; should drop all unnecessary capabilities.

Option-by-option analysis

Why each answer is right or wrong

Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The CAS-004 exam frequently reuses these exact scenarios with slightly different constraints.

Run containers as a non-root userCorrect answer
Build images with embedded database credentialsWrong answer — click to see why

Why this is wrong here

Embedding secrets in images is insecure; they should be injected at runtime.

Expose port 22 for SSH debuggingWrong answer — click to see why

Why this is wrong here

Exposing SSH adds an attack vector and is unnecessary in production.

Grant all Linux capabilities to the containerWrong answer — click to see why

Why this is wrong here

Granting all capabilities weakens isolation; should drop all unnecessary capabilities.

Analysis generated from the official CAS-004blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”

Common exam traps

Common exam trap: answer the scenario, not the keyword

CompTIA often tests the misconception that containers are inherently secure because they are isolated, but the trap here is that default root execution and bloated base images are common misconfigurations that dramatically increase the attack surface, and candidates may overlook the need to explicitly drop privileges and minimize image content.

Detailed technical explanation

How to think about this question

Under the hood, Docker and other container runtimes use Linux kernel features like namespaces and cgroups to isolate processes, but the default user inside a container is root (UID 0) unless explicitly changed. Running as non-root (e.g., USER 1000 in a Dockerfile) ensures that even if a kernel exploit occurs, the attacker's process lacks the privileges to escape the container or modify host-level resources. Minimal base images like Alpine (based on musl libc and BusyBox) or distroless images (from Google) reduce the attack surface by removing unnecessary binaries, libraries, and package managers, making it harder for an attacker to execute post-exploitation tools like netcat or curl.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A junior network technician can log in to a core router but cannot reach the enable prompt or configuration mode. The AAA server is authenticating the login — but the authorisation policy only grants privilege level 1, not 15. Authentication (who you are) is working; authorisation (what you can do) is not.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related CAS-004 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free CAS-004 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this CAS-004 question test?

Scripting, Containers and Automation — This question tests Scripting, Containers and Automation — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Run containers as a non-root user — Running containers as a non-root user (option A) is a fundamental security best practice because it limits the privileges available to processes inside the container. If an attacker compromises the application, they will not have root access to the host or the container runtime, reducing the potential for privilege escalation or host-level damage. This aligns with the principle of least privilege, which is critical for container security.

What should I do if I get this CAS-004 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more ways this is tested on CAS-004

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A security audit reveals that Docker containers are built with multiple unnecessary layers and utilities. Which practice reduces the attack surface of the container image?

hard
  • A.Use multi-stage builds
  • B.Use a base image with only the required packages
  • C.Combine multiple RUN commands into one
  • D.Delete the apt cache in the Dockerfile

Why B: Using a minimal base image with only required packages reduces the number of potential vulnerabilities. Multi-stage builds help but don't directly reduce the base image size.

Keep practising

More CAS-004 practice questions

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This CAS-004 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CAS-004 exam.