To check for SQL injection, test only an application you own or have written permission to test, map every input that reaches a database, then send safe probes such as a single quote, true and false conditions, and a time-delay payload. Confirm a real flaw with a second method or sqlmap, record the evidence, and fix it with parameterized queries.
Key takeaways
- Only test systems you own or have written permission to test, and use a staging copy, never production data.
- A single quote, true/false conditions and a time delay reveal most SQL injection flaws without extracting data.
- Parameterized queries, not input filtering, are the fix that actually stops SQL injection.
SQL injection lets an attacker turn a normal input box into a database command. A search field, a login form or a URL parameter becomes a way to read, change or delete data. The good news is that checking for it follows a repeatable method, and the fix is well understood.
What is SQL injection?
SQL injection happens when an application builds a database query by pasting user input directly into SQL text. The database then cannot tell where the developer's code ends and the attacker's input begins, so it runs both.
A classic example is a login query such as SELECT * FROM users WHERE username = '[input]' AND password = '[input]'. If the username is admin' OR '1'='1, the query changes its logic and may return the admin row without a valid password. OWASP lists injection as A03 in its Top 10, and its testing guide, WSTG-INPV-05, describes the same pattern in detail.
Injection is not limited to login forms. Search boxes, product filters, sort orders, page numbers, profile fields, cookies and HTTP headers can all reach a query. Any parameter that influences what the database returns is a candidate.
What should you do before you test?
Before sending a single payload, confirm you have permission, a safe target and a way to undo damage. Testing without authorization is not a grey area, and testing production can corrupt real data.
- Get written permission. For your own app, note the scope in your ticket. For a client or bounty program, keep the written authorization and stay inside its scope.
- Use staging, not production. Clone the app and a scrubbed database copy. Never run destructive payloads against live customer data.
- Take a backup and a snapshot. You need a fast rollback if a payload changes data or locks a table.
- Record a baseline. Save normal responses, timings and row counts for each input, so you can spot what a payload changed.
- Agree on the stop rule. If a test extracts data, changes records or takes the app down, stop, preserve the evidence and tell the owner.
How do you find every input that could be vulnerable?
Start by mapping the application before you test anything. List every place user input can reach a database, then test each one separately, because one safe field does not prove the next one is safe.
Browse the app through a proxy such as ZAP or Burp Suite and capture every request. Note form fields, URL parameters, JSON body fields, cookies, headers and hidden fields. Login, search, registration, profile updates, filters, sort options and report exports are the usual suspects.
For each input, ask three questions: does this feature read from a database, does my value change the result, and is the value used in a query, a sort or a filter? If the answer to all three is yes, add it to your test list. Also check second-order paths, where input is stored first and used in a query later, such as a username shown in an admin report.
How do you test for error-based SQL injection?
Error-based testing is the fastest first check. Send a single quote character, ', in an input and compare the response with the baseline. A database error, a 500 page or a visibly different result is a strong clue.
Try the quote in each input one at a time. Then try a double quote, a backslash and a closing parenthesis, because different databases and code paths react differently. Note the exact error text, but do not rely on it alone: many apps hide errors and are still vulnerable.
Next, try a payload that changes the query logic, such as ' OR '1'='1 in a text field, or 5 OR 1=1 in a numeric field. If the page suddenly returns more rows, logs you in or shows records you should not see, you have a likely injection. Record the request, the response and the time, then stop and confirm it with the blind tests below.
How do you check for blind SQL injection?
Blind injection gives you no error and no data, so you infer the flaw from behavior. The two standard methods are boolean-based and time-based testing, and both use pairs of payloads that should behave differently only if injection is present.
For boolean-based testing, send a true condition and a false condition through the same parameter. For a URL such as ?id=5, try ?id=5 AND 1=1 and then ?id=5 AND 1=2. If the first returns the normal page and the second returns a different page, an empty result or an error, the parameter is likely injectable. For a text field, use admin' AND '1'='1 and admin' AND '1'='2 in the same way.
For time-based testing, use a payload that makes the database wait, such as 5 AND SLEEP(5) in MySQL or 5; WAITFOR DELAY '00:00:05' in SQL Server. If the response takes about five seconds longer than the baseline, and a harmless payload does not, that delay is evidence of injection. Repeat the test, because slow networks also cause delays, and a single slow response proves nothing.
Union-based testing is a third method, used when data is returned to the page. Try UNION SELECT NULL, NULL with the right number of columns, increasing the count until the error changes. This is more advanced, and on a real engagement it is usually where a tool such as sqlmap takes over.
Which tools check for SQL injection?
Manual probes find the easy cases. Tools find the rest, repeat the work reliably and produce evidence you can hand to a developer. Use at least two categories: a proxy for manual work and an automated scanner or exploitation tool for confirmation.
| Tool | What it does | Cost | Best for |
|---|---|---|---|
| sqlmap | Automates detection and exploitation across many database types | Free, open source | Confirming a suspected flaw and showing impact |
| ZAP | Intercepting proxy plus active DAST scanning | Free, open source | Mapping an app and running repeatable scans in CI |
| Burp Suite | Proxy, Repeater and Intruder for manual payload work | Community free; Professional paid | Careful manual testing and custom payloads |
| Nuclei | Template-based scanning for known injection patterns | Free, open source | Fast checks across many endpoints |
| Commercial DAST | Managed scanning with verified exploit confirmation | Quote only | Large apps and continuous testing |
Sqlmap is the standard confirmation tool. A basic authorized run looks like sqlmap -u "https://staging.example.com/product?id=5" --batch --dbs, but read its documentation first and never point it at production. ZAP, formerly OWASP ZAP, is the free starting point for teams that want a scanner in their pipeline, while Burp Suite Community Edition covers manual proxy work at no cost. The Invicti guide to SQL injection testing tools compares these categories in more depth.
Whichever tool you use, treat its output as a lead, not a verdict. Confirm every high-severity finding by hand, check that the request is in scope, and note the exact payload and response in your report.
How do you confirm a finding and report it?
A finding is confirmed when you can reproduce it, explain the mechanism and show the impact without guessing. A single error message is not enough, and a scanner alert on its own is not enough either.
- Reproduce it twice. Run the same payload again and a second, different payload that should give the same result.
- Show true versus false. For blind flaws, record the true-condition response and the false-condition response side by side.
- Keep the evidence minimal. Prove the database is reachable; do not dump tables, passwords or customer data to make the point.
- Note the exact location. Record the URL, parameter, HTTP method, payload and response code, plus a screenshot or log excerpt.
- Rate the severity honestly. A login bypass or data read is critical. A minor error leak with no data access is lower, but still worth fixing.
Your report should give a developer everything needed to reproduce the flaw in staging, the parameterized fix, and a retest step. If you found the flaw in a third-party product, report it through the vendor's security contact or bug bounty program, and do not publish details before a fix is available.
How do you fix SQL injection?
The fix is parameterized queries, also called prepared statements. The SQL text and the data travel separately, so the database treats user input as a value, never as code. This works in every major language and framework, and it is the fix OWASP recommends first.
In practice, that means replacing string concatenation with placeholders and bound parameters, and using an ORM or query builder that parameterizes by default. Validate and limit input as well, but do not rely on blocklists or escaping alone: both can be bypassed, and escaping is easy to get wrong for one database dialect.
Other layers help but do not replace the fix. Give the database account only the permissions it needs, so a successful injection cannot drop tables or read unrelated data. Hide detailed database errors from users, log them server-side instead, and keep a firewall as a second layer. For a wider hardening checklist, see our small business cybersecurity checklist.
What mistakes do people make when checking?
The most common mistake is testing only the obvious fields. Login and search get tested, while sort orders, filters, cookies and API parameters are missed, and those are often the vulnerable ones. Test every parameter, including ones that look numeric.
Other frequent mistakes are trusting a clean scanner report without manual checks, testing production, and treating a firewall as a fix. A scanner can miss second-order injection, where stored input is used later, and a firewall rule can be bypassed. Also watch for false positives: a slow page, a generic error or a validation message can look like injection when it is not.
Finally, do not stop at detection. A finding with no fix, no owner and no retest date will still be there next quarter. File the fix, schedule the retest, and add the test to your release checklist so the same flaw does not come back.
Pair the technical fix with the wider controls in our small business cybersecurity checklist, so testing, patching and backups all get owned by someone.
The bottom line
Checking for SQL injection is a method, not a guess: get permission, map every input, probe with a quote, true/false pairs and a time delay, then confirm with a second method before you report it.
Fix it with parameterized queries, least-privilege database accounts and a retest after the change. You can check the public-facing side of your own site in seconds with our free security headers checker, then work through the database checks above in staging.
Frequently asked questions
What is the simplest way to check for SQL injection?
Send a single quote character in an input and watch the response. A database error, a blank page or a changed result suggests the input reaches a SQL query unprotected. That is only a clue, not proof, so confirm it with a true/false test or a scanner before reporting it.
Is it legal to test a website for SQL injection?
Only with permission. Testing a site you do not own, even with a harmless payload, can be unauthorized access under laws such as the US Computer Fraud and Abuse Act. Test your own application, a staging copy, or a system where you have written authorization, such as a bug bounty scope.
Can SQL injection be checked without any tools?
Yes, for the basic cases. Manual probes in a browser or with curl cover error-based and boolean-based blind injection. Tools such as sqlmap, ZAP and Burp Suite help with time-based blind injection, large parameter lists and repeatable evidence, but they are not required for a first check.
What does sqlmap do that manual testing cannot?
Sqlmap automates detection across many injection types, fingerprints the database, and can extract data or prove impact when authorized. Manual testing is slow and error-prone on blind injection, where the difference between true and false may be a single row or a few seconds of delay.
How do I know a finding is a real vulnerability and not a false positive?
Reproduce it twice with different payloads, show that a true condition and a false condition give different responses, and check that the behavior disappears when the input is parameterized. A scanner finding with no reproducible manual evidence should be treated as unconfirmed.
What is the difference between error-based and blind SQL injection?
Error-based injection shows database errors in the response, which makes it easy to spot. Blind injection shows no errors and no data, so the tester infers the flaw from changes in page content, status codes or response time. Blind flaws are just as dangerous and need more careful testing.
Does a web application firewall stop SQL injection?
A firewall can block known payloads, but it is not a fix. Attackers bypass filters with encoding, comments and alternative syntax, and a firewall does nothing for flaws in internal APIs or direct database access. Fix the code with parameterized queries and keep the firewall as an extra layer.
How often should I check for SQL injection?
Check on every release that changes queries, inputs or database code, and run automated DAST scans in your pipeline. Also retest after framework upgrades, new API endpoints and any change to login, search, filtering or reporting features, since those are the usual injection points.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the OWASP Web Security Testing Guide (WSTG-INPV-05) and current sqlmap, ZAP and Burp Suite documentation.
How we write and fact-check →