Skip to content
Web Design & Development

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.

MediaScaleUp Editorial Team 2 min read 11 views
SQL Injection: The Decisions That Matter

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?

  1. Use parameterized queries everywhere
  2. Review raw SQL in code reviews
  3. Validate input types and formats
  4. Restrict database account permissions
  5. Scan applications for injection flaws
What to do and what to avoid with SQL injection, side by side
Good practice against the usual mistakes, from the sources listed below.

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.

All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Web Design & Development