0
0
SQLquery~20 mins

Why SQL security awareness matters - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SQL Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is SQL injection a serious security risk?

Imagine a website where users enter their username and password. If the website's database queries are not secure, what can happen if someone uses SQL injection?

AThe database will delete itself to prevent attacks.
BThe website will automatically block the attacker without any damage.
CThe attacker can only see public information, no harm done.
DThe attacker can access or modify data they shouldn't be able to see.
Attempts:
2 left
💡 Hint

Think about what happens when user input is treated as code.

query_result
intermediate
2:00remaining
What happens if user input is not sanitized in this query?

Consider this SQL query used in a login system:

SELECT * FROM users WHERE username = '{user_input}' AND password = '{user_input_password}';

If a user inputs ' OR '1'='1' -- as username and anything as password, what will the query return?

AIt returns all users because the condition always becomes true.
BIt returns no users because the syntax is invalid.
CIt returns only the user with username ' OR '1'='1.
DIt causes the database to crash.
Attempts:
2 left
💡 Hint

Look at how the OR condition affects the WHERE clause.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in this SQL command

Find the syntax error in the following SQL statement:

INSERT INTO users (username, password VALUES ('alice', 'pass123');
AMissing closing parenthesis after column names.
BIncorrect keyword 'VALUES' used.
CMissing comma between values.
DQuotes around values are not allowed.
Attempts:
2 left
💡 Hint

Check the parentheses around the column list.

optimization
advanced
2:00remaining
Which index improves security and performance for user login?

You have a users table with columns: id, username, password_hash, email.

To speed up login checks and prevent unauthorized data access, which index is best to create?

ACREATE INDEX idx_password ON users(password_hash);
BCREATE INDEX idx_username ON users(username);
CCREATE INDEX idx_email ON users(email);
DCREATE INDEX idx_id ON users(id);
Attempts:
2 left
💡 Hint

Think about which column is used to find users during login.

🔧 Debug
expert
3:00remaining
Why does this SQL query expose sensitive data?

Given this query:

SELECT username, password FROM users WHERE active = 1;

Why is this a security risk?

AIt lacks a LIMIT clause, causing performance issues.
BIt filters only active users, so no risk exists.
CIt exposes password hashes which should be kept secret.
DIt uses SELECT instead of DELETE, causing data leaks.
Attempts:
2 left
💡 Hint

Consider what data should never be exposed in queries.