Information Security Basics
In a web application, entering a string such as ' OR '1'='1 in the password field of the login screen lets someone log in without knowing the password. What is this attack called?
- ASQL injection
- BCross-site scripting
- CDirectory traversal
Show answer and explanation
Answer: A. SQL injection
SQL injection exploits a web application that builds database commands (SQL statements) by simply concatenating user input as strings. For example, when ' OR '1'='1 is inserted where the condition "the password equals 'input'" is built, the quotation mark closes the string and the always-true condition "or '1' equals '1'" gets added. As a result the condition holds without the password, and the login succeeds. The same method can also be used to steal, alter or delete data. The fundamental countermeasure is a mechanism that never interprets input as part of the command: prepared statements with placeholders.
- A. Correct. An attack in which input changes the meaning of an SQL statement is SQL injection.
- B. Cross-site scripting embeds malicious scripts in web pages so that they run in visitors' browsers.
- C. Directory traversal puts sequences such as ../ into a file name parameter to read files that are not meant to be public.