A SQL injection attack consists of insertion or “injection” of a SQL query via the input data from the client to the application. A successful SQL injection exploit can read sensitive data from the database, modify database data (Insert/Update/Delete), execute administration operations on the database (such as shutdown the DBMS), recover the content of a given file present on the DBMS file system and in some cases issue commands to the operating system. SQL injection attacks are a type of injection attack, in which SQL commands are injected into data-plane input in order to effect the execution of predefined SQL commands. OWASP
Always use a prepared statement or parameterized statement and avoid building SQL queries by concatenating user-supplied input. If it’s not possible to use prepared statements, escape all user-supplied input using tested libraries. When possible try to limit user inputs using whitelists.
- OWASP: SQL Injection
- OWASP: ESAPI project
- Wikipedia: Prepared statement
- OWASP 2017-A1
- OWASP 2021-A3