SQL Injection: Second Order SQL Injection
Second Order SQL Injection is a subtype of SQL injection where the malicious SQL payload is primarily stored in the application's database and later executed by a different functionality of the same application. Unlike first-order SQLi, the injection doesn't happen right away. It is triggered in a separate step, often in a different part of the application.
User submits input that is stored (e.g., during registration or profile update).
Username: attacker'-- Email: attacker@example.comThat input is saved without validation but doesn't trigger a SQL injection.
INSERT INTO users (username, email) VALUES ('attacker\'--', 'attacker@example.com');Later, the application retrieves and uses the stored data in a SQL query.
query = "SELECT * FROM logs WHERE username = '" + user_from_db + "'"If this query is built unsafely, the injection is triggered.
Comments
No comments yet.