MySQL DatabaseLesson 63Free preview
MySQL Injection
This lesson is part of MySQL · All levels
Summary
SQL injection is an attack where an attacker inserts a malicious SQL snippet through an application input, such as a login column, to manipulate a server query. A classic example is to add 'OR' = 1' so that the WHERE condition is always true and all the data leaks. The most effective way to prevent this is to use a prepared statement with a binding parameter, rather than compiling a query with string merging.
Key points
- SQL injection utilizes user input that is directly integrated into string queries
- Symptoms: open login with strange input or personal data coming in
- Prepared statement with binding parameters is the main prevention
- Apply the principle of least privilege to the database accounts used by the application
- Do not display database error details to end users
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.