Zennoxa Shield
Application Security Glossary

SQL Injection

SQL injection is a vulnerability where an attacker inserts malicious SQL fragments into an application's database query, letting them read, modify, or delete data they shouldn't be able to access. It occurs when untrusted input is concatenated directly into a query instead of being parameterized.

SQL injection (SQLi) happens when an application builds database queries by concatenating user-supplied input directly into the SQL string. Because the input is treated as query logic rather than data, an attacker can alter the query's meaning — for example, ending an input with ' OR '1'='1 to bypass a login check or '; DROP TABLE users; -- to destroy data.

Under the hood, the database has no way to distinguish the developer's intended query structure from attacker-injected syntax when they arrive as one blended string. The fix is parameterized queries (prepared statements), where the query structure is sent separately from the values, so user input can never be interpreted as SQL. ORMs and stored procedures help when used correctly, but string-built queries reintroduce the risk.

SQLi is one of the oldest and most damaging web vulnerabilities, tracked as CWE-89 and a long-standing member of the OWASP Top 10 injection category. A single injectable endpoint can expose an entire database, including credentials and personal data, which is why static analysis tools flag any query built from tainted, unparameterized input.

Frequently asked questions

What is SQL injection?
SQL injection is a vulnerability where an attacker inserts malicious SQL into an application's database query by supplying crafted input, allowing them to read, alter, or delete data. It arises when untrusted input is concatenated into a query instead of being passed as a bound parameter.
How do you prevent SQL injection?
Use parameterized queries (prepared statements) so user input is always treated as data, never as SQL syntax. Validate and constrain input, apply least-privilege database accounts, and avoid building queries by string concatenation even inside ORMs and stored procedures.
SQL injection vs cross-site scripting?
Both are injection flaws from untrusted input, but SQL injection targets the database by injecting query syntax, while cross-site scripting injects script that runs in a victim's browser. SQLi mainly threatens server-side data; XSS mainly threatens client-side sessions and users.

Related terms

SQL Injection — Zennoxa Glossary — Zennoxa Shield