nerdexam
CompTIA

PT0-001 · Question #244

A penetration tester has been hired to perform a penetration test for an organization. Which of the following is indicative of an error-based SQL injection attack?

The correct answer is A. a=1 or 1--. Error-based SQL injection deliberately triggers database type errors to extract information. Only option A uses a string literal 'a' compared to a numeric value, which causes a type conversion error rather than a boolean evaluation.

Attacks and exploits

Question

A penetration tester has been hired to perform a penetration test for an organization. Which of the following is indicative of an error-based SQL injection attack?

Options

  • Aa=1 or 1--
  • B1=1 or b--
  • C1=1 or 2--
  • D1=1 or a--

How the community answered

(22 responses)
  • A
    86% (19)
  • B
    9% (2)
  • D
    5% (1)

Why each option

Error-based SQL injection deliberately triggers database type errors to extract information. Only option A uses a string literal 'a' compared to a numeric value, which causes a type conversion error rather than a boolean evaluation.

Aa=1 or 1--Correct

The fragment 'a=1' compares a string literal against a numeric column value, forcing the database engine to raise a type mismatch or conversion error. This error-based technique causes the database to surface diagnostic output that can reveal schema details or version information. The trailing '--' comments out the remainder of the original query to prevent syntax errors.

B1=1 or b--

The '1=1' prefix is a numeric tautology that always evaluates to true without triggering an error, classifying this as a boolean-based blind injection pattern rather than an error-based one.

C1=1 or 2--

'1=1 or 2--' uses only valid numeric comparisons that evaluate silently without type mismatches, making it a boolean-based injection that returns a true condition rather than an error state.

D1=1 or a--

Despite ending with the string 'a', the leading '1=1' tautology classifies this as a boolean-based injection; the 'a' reference is ambiguous and does not reliably produce a typed database error the way a string-to-integer comparison does.

Concept tested: Error-based SQL injection attack identification

Source: https://owasp.org/www-community/attacks/SQL_Injection

Topics

#SQL injection#error-based SQLi#web application#payload

Community Discussion

No community discussion yet for this question.

Full PT0-001 Practice