Exam GPEN All QuestionsBrowse all questions from this exam
Question 42

While performing a code audit, you discover a SQL injection vulnerability assuming the following vulnerable query, what user input could be injected to make the query true and return data? select * from widgets where name = '[user-input]';

    Correct Answer: C

    To exploit a SQL injection vulnerability in the provided query, the user input needs to alter the logic of the SQL statement to always evaluate to true. The input 'or 1=1-- does this effectively. It terminates the string input with a single quote, then adds a logical OR condition that is always true (1=1), and finally comments out the rest of the query using --. This makes the entire where clause trivially true and can result in returning all data from the widgets table.

Discussion
79c58bbOption: C

C. 'or 1=1-- This input effectively makes the query always true, bypassing the intended check and potentially exposing all data from the widgets table.