GPEN · Question #102
You work as a Network Penetration tester in the Secure Inc. Your company takes the projects to test the security of various companies. Recently, Secure Inc. has assigned you a project to test the…
The correct answer is B. Deletes the entire members table. The query uses stacked SQL injection to terminate the SELECT statement and execute DROP TABLE, permanently deleting the entire members table.
Question
You work as a Network Penetration tester in the Secure Inc. Your company takes the projects to test the security of various companies. Recently, Secure Inc. has assigned you a project to test the security of a Web site. You go to the Web site login page and you run the following SQL query:
SELECT email, passwd, login_id, full_name FROM members WHERE email = '[email protected]'; DROP TABLE members; --' What task will the above SQL query perform?
Options
- APerforms the XSS attacks.
- BDeletes the entire members table.
- CDeletes the rows of members table where email id is '[email protected]' given.
- DDeletes the database in which members table resides.
How the community answered
(34 responses)- A9% (3)
- B76% (26)
- C12% (4)
- D3% (1)
Why each option
The query uses stacked SQL injection to terminate the SELECT statement and execute DROP TABLE, permanently deleting the entire members table.
XSS (Cross-Site Scripting) is a client-side injection attack that injects malicious scripts into web page output, not a server-side SQL command targeting database tables.
The semicolon injected after the email value terminates the legitimate SELECT statement, and the subsequent DROP TABLE members; command instructs the database engine to permanently delete the entire members table and all its data. The double-hyphen (--) comments out any remaining SQL that follows, preventing syntax errors and allowing the destructive command to execute cleanly. This is a classic stacked query injection attack that requires the database driver to support multiple statements in a single call.
The WHERE clause in the injected SELECT applies only to that statement and does not affect the scope of DROP TABLE, which operates on the entire table regardless of any filter conditions.
DROP TABLE members removes only the named table from the database; removing the entire database would require a DROP DATABASE statement.
Concept tested: SQL injection stacked query with DROP TABLE
Source: https://owasp.org/www-community/attacks/SQL_Injection
Topics
Community Discussion
No community discussion yet for this question.