mediumMultiple Choice
CAS-004 Practice Question: A security analyst reviews a web application that…
A security analyst reviews a web application that accepts user-supplied data to generate PDF reports. The application uses a legacy library that directly inserts user input into SQL queries and also includes user input in the PDF generation without sanitization. Which is the most effective countermeasure?
⚠ Common exam trap
CAS-005 often tests the misconception that a WAF is a sufficient countermeasure for injection flaws, when in fact it is only a compensating control and does not fix the root cause.
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
✓
Use parameterized queries and output encoding
The application has two distinct vulnerabilities: SQL injection (from direct insertion of user input into SQL queries) and likely cross-site scripting or PDF injection (from unsanitized user input in PDF generation). Parameterized queries prevent SQL injection by separating code from data, while output encoding neutralizes malicious content before it is rendered in the PDF. Together, these address the root causes of both flaws, making A the most effective countermeasure.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use parameterized queries and output encoding
Why this is correct
Parameterised queries send SQL structure separately from user-supplied values, eliminating injection, while output encoding neutralises injected markup in the generated PDF. Together they address both the database and PDF generation flaws in the legacy library.
- ✗
Enable HTTPS and HSTS
Why it's wrong here
HTTPS and HSTS encrypt transport between browser and server, leaving the SQL injection and unsanitised PDF generation untouched once requests arrive. It is tempting because transport security is a standard hardening step, and it would be correct for protecting credentials or session cookies in transit. The vulnerability here is server-side input handling, not interception.
- ✗
Implement a web application firewall (WAF) to block malicious input
Why it's wrong here
A WAF pattern-matches known malicious payloads at the perimeter, but crafted input can bypass signatures and the legacy library still concatenates user data into SQL and PDF content. It is tempting because a WAF is a legitimate compensating control for rapid virtual patching. The stem demands eliminating the injection flaw, which requires parameterised queries and sanitisation.
- ✗
Deploy a SIEM to log all database queries and PDF generation events
Why it's wrong here
A SIEM only records database queries and PDF events after the fact; it neither removes the SQL injection sink nor the unsanitised PDF input, so exploitation still succeeds. It is tempting because logging is a genuine detective control for incident response. Here the flaw is insecure code, so parameterised queries and output encoding are required.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CAS-005 question from scratch — 973 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
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.