Courseiva
mediumMultiple ChoiceObjective-mapped

CAS-004 Mitigate SQL injection Practice Question

An application uses a relational database and constructs SQL queries by concatenating user input. Which secure coding practice should be implemented to mitigate SQL injection?

⚠ Common exam trap

The CAS-004 exam often tests the misconception that stored procedures or ORMs are inherently safe, but the trap is that both can still be vulnerable if they allow dynamic SQL construction or raw query execution without parameterization.

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

Implement parameterized queries / prepared statements

Parameterized queries (prepared statements) separate SQL logic from user data by using placeholders (e.g., `?` in MySQLi or `:param` in PDO). The database driver automatically escapes the input values, ensuring they are treated as data, not executable code. This directly prevents SQL injection because the query structure is fixed before user input is bound.

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 stored procedures exclusively

    Why it's wrong here

    Stored procedures can still be vulnerable if dynamic SQL is used within them.

  • Escape all user input with a database-specific escaping function

    Why it's wrong here

    Escaping is error-prone and not as reliable as parameterized queries.

  • Use an ORM (Object-Relational Mapping) framework

    Why it's wrong here

    ORMs can reduce risk but may still generate dynamic SQL if not used carefully.

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-005 exam frequently reuses these exact scenarios with slightly different constraints.

Implement parameterized queries / prepared statementsCorrect answer
Use stored procedures exclusivelyWrong answer — click to see why

Why this is wrong here

Stored procedures can still be vulnerable if dynamic SQL is used within them.

Escape all user input with a database-specific escaping functionWrong answer — click to see why

Why this is wrong here

Escaping is error-prone and not as reliable as parameterized queries.

Use an ORM (Object-Relational Mapping) frameworkWrong answer — click to see why

Why this is wrong here

ORMs can reduce risk but may still generate dynamic SQL if not used carefully.

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

About these practice questions

This CAS-005 question is part of Courseiva's 968-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 →

How Courseiva writes practice questions · Editorial policy

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.