SQL Injection (SQL Injection)

Security Glossary - Web Security

Definition: SQL injection is a vulnerability where an attacker inserts malicious SQL code into application queries through user input fields. If the application builds SQL queries by concatenating user input without proper parameterization, the attacker can read, modify, or delete database data, bypass authentication, or execute operating system commands.

Why SQL Injection Matters

SQL injection has been one of the most devastating web vulnerabilities for decades. A successful SQL injection can expose an entire database - user credentials, personal data, financial records. Some of the largest data breaches in history were caused by SQL injection.

The vulnerability exists when applications construct SQL queries using string concatenation with user input. For example, "SELECT * FROM users WHERE id = " + userInput allows an attacker to input "1 OR 1=1" to retrieve all records, or "1; DROP TABLE users" to destroy data.

The defense is straightforward: use parameterized queries (prepared statements) for all database interactions. Every modern programming language and database library supports them. ORMs (Object-Relational Mappers) like SQLAlchemy, Sequelize, and Prisma use parameterized queries by default. Manual SQL string construction should never include user input.

Real-World Example

The 2017 Equifax breach exposed personal data of 147 million people. While the initial entry point was an unpatched Apache Struts vulnerability, the attackers used SQL injection techniques to extract data from backend databases over a 76-day period. The breach resulted in over $1.4 billion in costs and a $700 million settlement.

Testing Your Configuration

SQL injection is an application-level vulnerability that requires code review or security scanning to detect. A security audit checks for security headers that provide defense-in-depth, but direct SQL injection testing requires specialized tools like SQLMap or application security scanners.

See how your site handles SQL Injection

Run a Security Audit

Frequently Asked Questions

Is SQL injection still common?
Yes, despite being well understood for decades. It remains in the OWASP Top 10. It most commonly occurs in legacy applications, custom database queries that bypass ORM protections, and applications where developers concatenate user input into queries.
Does using an ORM prevent SQL injection?
ORMs prevent SQL injection for their standard query methods because they use parameterized queries internally. However, most ORMs allow raw SQL queries for complex operations, and those can still be vulnerable if not parameterized. Always use parameterized queries for raw SQL.
Disclaimer: DomainOptic provides automated informational scans only. Results do not constitute professional security advice, compliance certification, or a guarantee of security. Always verify findings independently.