easyMultiple Choice
CAS-004 Practice Question: A web application generates an Ansible playbook…
Exhibit
input_user = request.args.get('user')
playbook = """
- hosts: all
tasks:
- name: Greet {{ user }}
debug:
msg: "Hello {{ user }}"
""".replace('{{ user }}', input_user)A web application generates an Ansible playbook from user input as shown. What is the primary security risk?
⚠ Common exam trap
CompTIA CASP+ often tests the distinction between generic injection types (SQL, LDAP) and technology-specific injection (Ansible modules, PowerShell, Terraform HCL), so candidates mistakenly choose a familiar injection type instead of recognizing the automation framework context.
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
✓
The user input could be crafted to execute arbitrary Ansible modules.
The application directly incorporates user input into an Ansible playbook without sanitization or validation. An attacker can inject arbitrary YAML or Ansible module directives (e.g., `shell`, `command`, `raw`) to execute unauthorized commands on managed hosts. This is a classic injection vulnerability specific to automation frameworks, not a generic injection type.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The application is vulnerable to SQL injection.
Why it's wrong here
The playbook is YAML, not a SQL query, so no SQL parser or database executes the injected input; the risk is code injection into the generated playbook. SQL injection would apply if user input were concatenated into a database query, which this scenario does not describe.
- ✓
The user input could be crafted to execute arbitrary Ansible modules.
Why this is correct
Crafted input can inject arbitrary Ansible module calls into the generated playbook, since Ansible executes whatever modules the YAML specifies. This directly satisfies the stem's constraint: untrusted user input flows into playbook generation without validation, enabling remote code execution on managed hosts under the automation controller's privileges.
- ✗
The application is vulnerable to LDAP injection.
Why it's wrong here
No LDAP directory lookup occurs here; the application writes user input into a YAML playbook, so the injection target is Ansible's module execution, not directory queries. LDAP injection would be the risk if input were concatenated into a directory search filter.
- ✗
The playbook may fail to run if input contains special characters.
Why it's wrong here
Malformed YAML causing a run failure is a reliability symptom, not the security risk; an attacker can craft valid YAML that executes arbitrary modules on managed hosts. Input validation for special characters would be the concern in a data-entry form where only well-formed values are expected.
Go deeper
Related to this question
About these practice questions
This CAS-005 question is part of Courseiva's 973-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CAS-005 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-005 exam.