Authentication Bypass SQL Injection Payloads

Authentication bypass abuses a login query that concatenates the username and password into SQL. A tautology makes the WHERE clause always true, a comment truncates the password check, and a UNION can forge a row with a known hash. Use these only against login forms you are authorized to test.

How to confirm: You are logged in without valid credentials — the tautology returns the first user, or the comment skips the password comparison entirely.

UNION with MD5 hash

Authentication bypass

'admin' AND 1=0 UNION ALL SELECT 'admin', '161ebd7d45089b3446ee4e0d86dbcf92'-- 

UNION login as admin with hash 161ebd7d45089b3446ee4e0d86dbcf92 (password column).

PayloadsAllTheThings reference

Defense

  • Use parameterized queries for the credential lookup and never build the login SQL by string concatenation.
  • Store passwords with a slow salted hash and compare in application code, not inside the SQL WHERE clause.
  • Enforce row-count checks and MFA so a single-row tautology is not enough to authenticate.