SQL Injection
SQL injection allows attackers to interfere with database queries by inserting malicious SQL syntax into application inputs.
These payloads are for authorized testing only — systems you own, authorized bug bounty programs, or controlled lab environments. Unauthorized testing is illegal.
What it is
SQL Injection (SQLi) is a web security vulnerability that allows an attacker to interfere with the queries an application makes to its database. It generally allows an attacker to view data they are not normally able to retrieve — including data belonging to other users — and can lead to unauthorized data modification, authentication bypass, or complete database compromise.
Attack Vectors
- Login forms (username/password fields)
- Search fields and filters
- URL query parameters
- HTTP headers (User-Agent, Referer, X-Forwarded-For)
- Cookie values
- JSON/XML API request bodies
- Any field that queries a database backend
Testing Methodology
- Submit a single quote (') and observe for SQL syntax errors
- Test boolean conditions: ' OR '1'='1 vs ' OR '1'='2
- Use UNION-based injection to extract additional columns
- Test time-based blind injection with SLEEP()/WAITFOR DELAY
- Enumerate database version, tables, and columns
- Use error-based injection to extract data through error messages
Payloads
Reference payloads for authorized testing. Always verify you have permission before use.
Indicators of Vulnerability
- SQL syntax errors in response
- Generic error messages when submitting quotes
- Different response content for TRUE vs FALSE conditions
- Time delay when using SLEEP/WAITFOR
- Database version strings or table names in response
Detection Guidance
Monitor application logs for SQL syntax in request parameters. Use a WAF with SQL injection detection rules. Implement database query logging and anomaly detection. Look for error messages containing SQL keywords in responses.
Mitigation & Remediation
- Use parameterized queries / prepared statements
- Implement input validation and allowlisting
- Use an ORM with built-in protection
- Apply principle of least privilege on database accounts
- Enable detailed error logging server-side but never expose DB errors to clients
- Use a WAF as defense-in-depth
References
Responsible Use
All content in this reference is for authorized security testing only. Use only on systems you own or have explicit written permission to test.
- Systems and applications you own
- Authorized penetration testing engagements
- Bug bounty programs with defined scope
- Educational lab environments (DVWA, WebGoat, HackTheBox)