SQL Injection: The Decisions That Matter
A vulnerability where user input is inserted into a database query in a way that lets an attacker change the query, reading or modifying data they should not access.
On this page
Why does it matter?
SQL injection can expose an entire database, and it is entirely preventable with parameterized queries.
What are the numbers?
- Primary defense parameterized queries or prepared statements
- ORMs use parameters by default, but raw queries can reintroduce risk
- Least privilege database accounts should have only the permissions they need
- OWASP Top 10 injection is a listed risk category
What should I do?
- Use parameterized queries everywhere
- Review raw SQL in code reviews
- Validate input types and formats
- Restrict database account permissions
- Scan applications for injection flaws
What should I avoid?
Avoid:
- Building queries with string concatenation
- Escaping by hand instead of using parameters
- Database accounts with admin rights for the web app
- Detailed database errors shown to users
When should I get help?
Short answer Bring in help when legacy code builds SQL from strings, or when a scan reports injection risks.
Where this comes from
- OWASP — SQL Injection Prevention Cheat Sheet
- PHP Manual — Prepared statements and stored procedures
The figures and practices above come from the sources listed.
Working on something like this?
We take on Web Design & Development work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.