- A
Using a `requests.Session` object to maintain cookies across requests
Why wrong: Maintaining cookies is helpful for session handling but does not directly influence the detection of successful injections.
- B
Parsing the response for specific error messages such as 'SQL syntax' or 'mysql_fetch_array'
This allows the script to confirm that the injection payload was processed by the database, reducing false negatives.
- C
Implementing a random delay between requests to avoid rate limiting
Why wrong: Delays help avoid detection by Web Application Firewalls but do not reduce false negatives in detecting vulnerabilities.
- D
Adding a function to automatically resend each payload multiple times
Why wrong: Resending payloads may increase coverage but does not improve the accuracy of detecting successful injections.
Quick Answer
The correct answer is parsing the response for specific error messages such as 'SQL syntax' or 'mysql_fetch_array' because this technique directly reduces false negatives in SQL injection testing by confirming that the injected payload reached and interacted with the database engine. When a tester relies solely on authentication bypass—such as a successful login—they miss blind injection scenarios where the query executes but the application logic still denies access, producing a false negative. Parsing error messages catches these cases by revealing database-level reactions, making it a more reliable indicator of injection success. On the CompTIA PenTest+ PT0-002 exam, this question tests your understanding of error-based SQL injection detection versus result-based detection, a common trap where testers overlook subtle database responses. Remember the memory tip: "Errors equal evidence"—if the database complains, the injection is working, even if the login page doesn't say welcome.
PT0-002 Tools and Code Analysis Practice Question
This PT0-002 practice question tests your understanding of tools and code analysis. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. A key principle to apply: error-based SQL injection relies on database error messages.. 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 penetration tester is reviewing a Python script that uses the `requests` library to send HTTP POST requests to a login endpoint. The script attempts to bypass authentication by sending SQL injection payloads in the username field. Which of the following code changes would MOST effectively help the tester identify successful injections by reducing false negatives?
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
Parsing the response for specific error messages such as 'SQL syntax' or 'mysql_fetch_array'
Option B is correct because parsing the HTTP response for database-specific error messages (e.g., 'SQL syntax', 'mysql_fetch_array') directly indicates that the SQL injection payload triggered a detectable database error, confirming a successful injection. This reduces false negatives by catching cases where the login fails but the injection still executes, rather than relying solely on authentication bypass (which may not occur if the injection is blind or the query structure differs).
Key principle: Error-based SQL injection relies on database error messages.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Using a `requests.Session` object to maintain cookies across requests
Why it's wrong here
Maintaining cookies is helpful for session handling but does not directly influence the detection of successful injections.
- ✓
Parsing the response for specific error messages such as 'SQL syntax' or 'mysql_fetch_array'
Why this is correct
This allows the script to confirm that the injection payload was processed by the database, reducing false negatives.
Related concept
Error-based SQL injection relies on database error messages.
- ✗
Implementing a random delay between requests to avoid rate limiting
Why it's wrong here
Delays help avoid detection by Web Application Firewalls but do not reduce false negatives in detecting vulnerabilities.
- ✗
Adding a function to automatically resend each payload multiple times
Why it's wrong here
Resending payloads may increase coverage but does not improve the accuracy of detecting successful injections.
Common exam traps
Common exam trap: answer the scenario, not the keyword
The trap here is that candidates often confuse session management (Option A) or evasion techniques (Option C) with detection logic, overlooking that the core goal is to reduce false negatives by explicitly checking for injection success indicators in the response.
Detailed technical explanation
How to think about this question
Under the hood, SQL injection detection via error-based techniques relies on the database server returning verbose error messages when malformed SQL is executed; parsing these messages (e.g., 'You have an error in your SQL syntax') confirms the injection point. In real-world scenarios, blind SQL injection (where no error is returned) requires alternative techniques like time-based or boolean-based inference, but error-based parsing remains the most direct method when errors are visible in the response body.
KKey Concepts to Remember
- Error-based SQL injection relies on database error messages.
- Specific keywords in HTTP responses indicate database processing.
- Parsing response bodies reduces false negatives in injection testing.
- Database-specific errors confirm successful payload execution.
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
Error-based SQL injection relies on database error messages.
Real-world example
How this comes up in practice
A SOC analyst notices unusual lateral movement in the network at 2 AM. The IR playbook dictates: identify and contain (isolate the affected machine), then eradicate (remove the malware), then recover (restore from backup), then document. Skipping containment before eradication risks the attacker regaining access. Questions like this test the sequence and rationale of incident response phases.
What to study next
Got this wrong? Here's your next step.
Review error-based SQL injection relies on database error messages., then practise related PT0-002 questions on the same topic to reinforce the concept.
- →
Tools and Code Analysis — study guide chapter
Learn the concepts, then practise the questions
- →
Tools and Code Analysis practice questions
Targeted practice on this topic area only
- →
All PT0-002 questions
509 questions across all exam domains
- →
CompTIA PenTest+ PT0-002 study guide
Full concept coverage aligned to exam objectives
- →
PT0-002 practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related PT0-002 practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Planning and Scoping practice questions
Practise PT0-002 questions linked to Planning and Scoping.
Information Gathering and Vulnerability Scanning practice questions
Practise PT0-002 questions linked to Information Gathering and Vulnerability Scanning.
Attacks and Exploits practice questions
Practise PT0-002 questions linked to Attacks and Exploits.
Reporting and Communication practice questions
Practise PT0-002 questions linked to Reporting and Communication.
Tools and Code Analysis practice questions
Practise PT0-002 questions linked to Tools and Code Analysis.
PT0-002 fundamentals practice questions
Practise PT0-002 questions linked to PT0-002 fundamentals.
PT0-002 scenario practice questions
Practise PT0-002 questions linked to PT0-002 scenario.
PT0-002 troubleshooting practice questions
Practise PT0-002 questions linked to PT0-002 troubleshooting.
Practice this exam
Start a free PT0-002 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 PT0-002 question test?
Tools and Code Analysis — This question tests Tools and Code Analysis — Error-based SQL injection relies on database error messages..
What is the correct answer to this question?
The correct answer is: Parsing the response for specific error messages such as 'SQL syntax' or 'mysql_fetch_array' — Option B is correct because parsing the HTTP response for database-specific error messages (e.g., 'SQL syntax', 'mysql_fetch_array') directly indicates that the SQL injection payload triggered a detectable database error, confirming a successful injection. This reduces false negatives by catching cases where the login fails but the injection still executes, rather than relying solely on authentication bypass (which may not occur if the injection is blind or the query structure differs).
What should I do if I get this PT0-002 question wrong?
Review error-based SQL injection relies on database error messages., then practise related PT0-002 questions on the same topic to reinforce the concept.
What is the key concept behind this question?
Error-based SQL injection relies on database error messages.
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 PT0-002 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 PT0-002 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.