The weakness
SQL injection happens when user input is treated as part of a database query instead of plain text.
Interactive Web Security Lab
Learn how SQL injection works by searching a simulated Pokémon database, testing malicious input, and seeing how the application response changes when a query is vulnerable.
Concept
SQL injection happens when user input is treated as part of a database query instead of plain text.
The attacker tries to change the query logic to return data they should not be able to access.
Security teams look for suspicious query patterns and turn them into structured alerts.
Database Context
Pokémon
---------------------------------------------------------
pokedex_number | name | type_1 | type_2 | base_stat_total
Normal searches should return Pokémon records. SQL injection-style input will simulate what could happen if the application built unsafe SQL queries.
Hands-On Lab
GET
/search?q=<user_input>
Try a normal query first, such as Pikachu, Water, or Dragon. Then test a SQL injection payload and compare the application response.
Submit a query to see the simulated SQL output.
No event generated yet.
Payload Testing
Pikachu
Returns rows where the Pokémon name matches the search term.
Water
Returns Pokémon where type_1 or type_2 matches Water.
' OR '1'='1
Simulates a tautology attack where the WHERE clause becomes true.
' UNION SELECT username, password_hash FROM admin_users--
Simulates pulling data from a table the user should not access.
Pikachu'; DROP TABLE pokemon;
Simulates a stacked query attempt.
Security Telemetry
{
"timestamp": "2026-05-01T22:45:12Z",
"source_ip": "client_side_demo",
"username": "guest",
"event_type": "sql_injection_attempt",
"route": "/search",
"http_method": "GET",
"payload": "' OR '1'='1",
"result_count": 1028,
"severity": "high",
"mitre_attack": "T1190",
"status": "exploited",
"detection_reason": "SQL tautology pattern"
}
Select a field in the JSON log to learn what it means and why it matters in a security context.
Defensive Takeaway
User input should be passed as data, not directly inserted into SQL strings.
Applications should reject unexpected patterns and enforce safe input formats.
Logs should capture suspicious payloads, affected routes, source details, and detection reasoning.