SQL DatabaseLesson 63Free preview
SQL Injection
This lesson is part of SQL · All levels
Summary
SQL injection is an attack when an attacker inserts a piece of SQL through a user input so that the query intent changes and can leak or even delete data. A classic example is the input 'OR' 1'=1 which makes the condition always true. Prevention includes using parameterized queries or prepared statements, applying the principle of minimum rights, and validating inputs.
Key points
- SQL injection occurs when user input is incorporated raw into a string query.
- The effect can be bypass logins, read, change, or delete data.
- The main prevention: prepared statement with binding parameters.
- The principle of least privilege: give the application account the minimum access.
- Validation input is an additional layer, not a substitute for a parameterized query.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.