Question 870 of 1,013
SY0-701 Threats, Vulnerabilities, and Mitigations Practice Question
A security analyst discovers that an organization's web application is vulnerable to SQL injection. The application uses a legacy database driver that does not support parameterized queries. Which of the following is the BEST mitigation to prevent this vulnerability?
⚠ Common exam trap
Many candidates choose a WAF (Option A) as a quick fix, overlooking that it only mitigates symptoms rather than eliminating the root cause, which is the lack of parameterized query support in the database driver.
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
✓
Update the database driver to a version that supports parameterized queries.
The root cause of the SQL injection vulnerability is the legacy database driver that does not support parameterized queries. Updating the driver to a modern version that supports parameterized queries (also known as prepared statements) allows the application to separate SQL logic from user-supplied data, effectively preventing SQL injection at the database layer. This addresses the fundamental flaw rather than relying on external filtering or encoding.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Implement a web application firewall (WAF) to filter malicious input.
Why it's wrong here
A WAF can provide some protection by detecting and blocking common SQL injection patterns, but it is a compensating control and can be bypassed. It does not fix the underlying vulnerability in the application code.
When this WOULD be correct
A WAF would be the best mitigation if the question stated that the database driver cannot be updated (e.g., due to vendor lock-in or legacy system constraints) and the organization needs a compensating control to reduce risk.
- ✓
Update the database driver to a version that supports parameterized queries.
Why this is correct
Parameterized queries, also known as prepared statements, separate the SQL statement structure from user-supplied data by sending the query template to the database first and then binding input values as parameters. This ensures that even if an attacker submits malicious SQL fragments, they are treated strictly as data values, never as executable command text. Updating the database driver to a version that fully supports these APIs is the definitive root-cause fix, because it eliminates the injection vulnerability instead of merely detecting or filtering attack payloads.
- ✗
Encode all user input using HTML encoding.
Why it's wrong here
HTML encoding is an output-encoding technique designed to neutralize cross-site scripting (XSS) by converting characters like <, >, and & into HTML entities before the browser renders them. SQL injection, however, occurs during database query parsing, where the database engine interprets the raw input as part of the SQL grammar—HTML entities have no special meaning to SQL and will not prevent a malicious clause from executing. Moreover, applying HTML encoding to input can corrupt legitimate data (e.g., storing < instead of <) and provides zero protection at the database layer, making it a fundamentally different and ineffective countermeasure for this threat.
When this WOULD be correct
This would be correct if the question asked for the best mitigation against cross-site scripting (XSS) in a web application that reflects user input in HTML output.
- ✗
Disable error messages that reveal database schema.
Why it's wrong here
Disabling verbose database error messages is a valid defensive hardening step that reduces information disclosure by preventing attackers from seeing table names, column names, or query syntax in application responses. However, it does not alter the execution of the injected SQL—the malicious query still runs and may return data or modify records; it only deprives the attacker of visible clues. Skilled attackers can exploit blind SQL injection techniques, such as time-based delays or boolean-based page differences, to enumerate the schema and exfiltrate data even when errors are suppressed, so the underlying code flaw remains completely unaddressed.
When this WOULD be correct
This would be correct in a question asking for the best mitigation to prevent information disclosure via database error messages, such as in a scenario where the primary concern is leaking schema details through verbose errors.
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 SY0-701 exam frequently reuses these exact scenarios with slightly different constraints.
✓Update the database driver to a version that supports parameterized queries.Correct answer▾
Why this is correct
Parameterized queries, also known as prepared statements, separate the SQL statement structure from user-supplied data by sending the query template to the database first and then binding input values as parameters. This ensures that even if an attacker submits malicious SQL fragments, they are treated strictly as data values, never as executable command text. Updating the database driver to a version that fully supports these APIs is the definitive root-cause fix, because it eliminates the injection vulnerability instead of merely detecting or filtering attack payloads.
✗Implement a web application firewall (WAF) to filter malicious input.Wrong answer — click to see why▾
Why this is wrong here
A WAF can filter known SQL injection patterns but does not fix the root cause; it can be bypassed with obfuscated payloads. The best mitigation is to use parameterized queries, which the legacy driver does not support.
★ When this WOULD be the correct answer
A WAF would be the best mitigation if the question stated that the database driver cannot be updated (e.g., due to vendor lock-in or legacy system constraints) and the organization needs a compensating control to reduce risk.
Why candidates choose this
Candidates may think a WAF is a quick, effective solution without understanding that it only provides partial, bypassable protection, and they may overlook the importance of fixing the root cause.
✗Encode all user input using HTML encoding.Wrong answer — click to see why▾
Why this is wrong here
HTML encoding prevents XSS but does not stop SQL injection, as SQL injection exploits database query structure, not HTML rendering.
★ When this WOULD be the correct answer
This would be correct if the question asked for the best mitigation against cross-site scripting (XSS) in a web application that reflects user input in HTML output.
Why candidates choose this
Candidates confuse input encoding with input sanitization, thinking encoding universally prevents injection attacks, but SQL injection requires query parameterization or escaping, not HTML encoding.
✗Disable error messages that reveal database schema.Wrong answer — click to see why▾
Why this is wrong here
Disabling error messages does not prevent SQL injection; it only hides error details from users. The vulnerability remains exploitable via blind SQL injection techniques.
★ When this WOULD be the correct answer
This would be correct in a question asking for the best mitigation to prevent information disclosure via database error messages, such as in a scenario where the primary concern is leaking schema details through verbose errors.
Why candidates choose this
Candidates may think that hiding error messages stops attackers from gathering information, but it does not address the root cause of SQL injection.
Analysis generated from the official SY0-701blueprint 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
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 →
Last reviewed: Jun 11, 2026
This SY0-701 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 SY0-701 exam.
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.
Sign in to join the discussion.