Knowledge Base · general

SQL Injection

generaltechnique notetechniquesql-injection

Attacker-controlled input reaches a SQL query, allowing authentication bypass and data extraction.

How it works

  • Auth bypass: ' OR '1'='1' -- -.
  • UNION-based extraction: match the column count, then pull other tables/columns.
  • Blind boolean/time-based extraction when output is not reflected.

Detection & defence

  • Use prepared statements / parameterised queries everywhere.
  • Apply least privilege to the database user and validate input types.