ITPEC FE Subject A April 2026 Question 34
An SQL injection attack caused the SQL statement below to be executed. Which of the following does the SQL statement do? Here, the accounts table contains user account information in each row.
Explanation
It selects every record in accounts and then deletes the accounts table — the injected text makes the condition always true and appends a second statement.
Read the injected statement in two parts:
- •
username='1' or '1'='1'—'1'='1'is always true, andormakes the wholeWHEREclause true for every row, so theSELECTreturns all records - •
; DROP TABLE accounts;— the semicolon ends the first statement, andDROP TABLEremoves the table, definition and data, from the database
Answer (c)
Why not others:
- •(a) — nothing creates a user; that would need an
INSERTorCREATE USERstatement - •(b) — a pop-up box is what cross-site scripting produces by injecting JavaScript into a web page; SQL runs on the database and displays nothing
- •(d) — the
WHEREclause matches every row, not one, andDROP TABLEremoves the whole table rather than some rows, which would needDELETE
Key rule: A classic SQL injection pairs an always-true condition that defeats the filter with a statement separator that appends a new command; placeholders (prepared statements) block both by keeping input out of the SQL text.
Security · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.