Evidence Review: Why SQL Injection Keeps Appearing
SQL injection is one of the oldest web security problems, and also one of the easiest to prevent. So why does it keep showing up? This page looks at what respected public sources say, in plain language, without inventing any figures.
First, what is SQL injection?
SQL injection happens when an app builds a SQL query by gluing user input straight into the query text. If someone types SQL code instead of normal input, the database may run it. Here is the classic mistake, in a tiny made-up example:
# DON'T do this
query = "SELECT * FROM users WHERE name = '" + name + "'"
If name is ' OR '1'='1, the query now matches every user.
What the well-known sources say
OWASP Top 10. OWASP (the Open Worldwide Application Security Project) publishes a list of the most important web application security risks. Injection, which includes SQL injection, has been on that list in every edition. In the 2021 edition it appears as "A03 Injection".
MITRE CWE. CWE is a public catalogue of software weakness types, run by MITRE. SQL injection has its own entry, CWE-89. MITRE also publishes a list of the most dangerous weaknesses each year, based on real reported vulnerabilities, and SQL injection regularly appears near the top.
Vulnerability databases. The US National Vulnerability Database (NVD) lists publicly reported vulnerabilities, each with a CVE identifier. Searching it for "SQL injection" shows new reports appearing all the time, in all kinds of software.
Why it is still common
The evidence points to a few reasons:
- Old code. Many apps were written before safe habits were widespread, and still run today.
- Tutorials that teach the wrong way. Some beginner examples still glue strings together because it looks simpler.
- Small projects with no review. Plugins, scripts and internal tools often never get a second pair of eyes.
- Places where placeholders don't fit. Table or column names chosen by the user cannot be passed as normal parameters, and people sometimes take shortcuts.
What actually prevents it
| Defence | What it means |
|---|---|
| Parameterised queries | The SQL and the values are sent separately, so values can never become code |
| Allow-lists | For things like sort columns, accept only known names |
| Least privilege | The app's database account can only do what it needs |
| Code review | Someone checks every place SQL is built |
Here is the safe version of the earlier example, using a placeholder:
cursor.execute("SELECT * FROM users WHERE name = ?", (name,))
How to read the evidence
These lists count reported problems. They show that SQL injection is common and serious, but they cannot tell you how likely your own app is to be attacked. The practical message is simpler: always use placeholders, and you remove the problem at its source.
Try it yourself, safely, in our hands-on SQL injection tutorial.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.
General commentary only: this page does not report specific news events and does not cite a survey or data source. Treat any trends described as unverified.