CyberGlossary

Attacks & Threats

SQL Injection

Also known as: SQLi

Definition

An attack that inserts attacker-controlled SQL fragments into queries built from untrusted input, allowing data theft, modification, or full database compromise.

SQL injection (SQLi) occurs when an application concatenates user input into SQL statements without proper separation between code and data. By submitting payloads such as ' OR 1=1-- or UNION SELECT, an attacker can bypass authentication, read arbitrary tables, modify or delete records, and on misconfigured databases execute system commands. Variants include error-based, union-based, boolean and time-based blind, and out-of-band SQLi. The vulnerability has been a perennial OWASP Top 10 entry. The definitive defence is parameterized queries (prepared statements) with bind variables, layered with input validation, least-privilege database accounts, ORM hardening, and a Web Application Firewall as compensating control.

Examples

  • A login form where username='admin'--' lets an attacker log in without a password.
  • A search endpoint that exposes the password_hash column via a crafted UNION SELECT.

Related terms