SQL Injection Tester

Paste SQL or query-building code and flag string concatenation, ${} interpolation, $variables and classic injection signatures. Static check in your browser.

The interactive tool loads here when JavaScript runs.

About this tool

What is SQL Injection Tester?

The SQL Injection Tester is a static reviewer for SQL text and the code that builds it. Paste a query, a code snippet or a line from a query log and it runs eleven pattern checks, from template interpolation such as '${username}' and string concatenation with + or PHP's . operator, to the classic signatures (an OR 1=1 tautology, UNION SELECT after a closing quote, stacked statements) that suggest input has already reached the SQL.

Each finding has a severity, a short description, a sketch of what the pattern looks like and a mitigation. The result also gives a score out of 100 (Critical findings cost 30 points, High 20, Medium 10, Low 5) and recommendations such as adding LIMIT or replacing SELECT *. You can copy or download the report as text.

It is a heuristic, not a scanner. Nothing is sent to a database or a website; the text is checked in your browser. A clean result means none of the known patterns matched, not that the code is safe.

  • Eleven pattern checks with severity, description and mitigation
  • Detects ${} and {x} interpolation, quoted %s, $variables and concatenation
  • Recognises ?, $1, :name, @name and %s as bound parameters
  • Score, pass count and recommendations; copy or download the report
  • Static analysis in the browser; no network requests
Read the guide: Preventing SQL Injection: Spotting Unsafe Queries in Code Review

Updated

How to use SQL Injection Tester

  1. Paste SQL, query-building code or a captured runtime query into SQL Query Input, or click Load Sample.
  2. Click Test for SQL Injection.
  3. Read Security Analysis for the score and pass count, then the Security Vulnerabilities list for each finding and its mitigation.
  4. Rewrite flagged queries with bound parameters and run the check again.
  5. Use the copy or download buttons to attach the report to a ticket or pull request.

Worked examples

The built-in sample

Input

SELECT * FROM users WHERE username = '${username}' AND password = '${password}';

Output

Score 65/100: Interpolated Value (Critical), Literal String Comparison (Low)

The template placeholders build the SQL text from variables, which is the root cause of injection. Before this fix the tester missed ${...} entirely and scored the sample 100.

The parameterised rewrite

Input

SELECT id, name FROM users WHERE username = $1 AND active = true LIMIT 1;

Output

Score 100/100, 11 of 11 checks passed

The $1 placeholder is recognised as a bound parameter, and the recommendation reminds you to keep passing the value separately from the SQL text.

Background and insight

SQL injection happens when data is spliced into the text of a query, so the database parses part of the data as SQL. The fix is the same in every language: send the SQL with placeholders (?, $1, :name or @name) and pass the values separately, so the driver or database never treats them as code. Escaping functions try to achieve the same thing by rewriting the data and fail on edge cases such as character sets, numeric contexts and identifiers.

Bound parameters cover values, not identifiers. A user-chosen sort column or table name cannot be a placeholder, so it must be mapped through an allow-list in code. The tester adds a recommendation when it sees an interpolated ORDER BY.

Pattern matching has blind spots in both directions. MyBatis #{x} binds a parameter while ${x} interpolates; EF Core FromSqlInterpolated turns {x} into a parameter while FromSqlRaw with an interpolated string does not. Python drivers use an unquoted %s as a real placeholder, which the tester treats as safe, but a quoted '%s' usually means string formatting. Read each finding with the surrounding code in mind.

Common use cases

  • Code review

    Paste a data-access function from a pull request and get a second look at how its queries are built.

  • Reviewing legacy code

    Find string-built queries in older PHP, Java or JavaScript before a refactor to prepared statements.

  • Reading query logs

    Check a suspicious logged query for tautologies, UNION SELECT or stacked statements.

  • Teaching secure coding

    Show developers the difference between interpolated and parameterised versions of the same query.

Tips and limitations

  • Paste the code that builds the query, not just the final SQL. Concatenation and interpolation are only visible in the source.
  • Low-severity findings (a literal string comparison, a -- comment) are prompts to check where values come from, not bugs in themselves.
  • Stored procedures only help if they do not build dynamic SQL inside. EXEC with a concatenated string has the same problem.
  • Give the application's database account only the privileges it needs, so a missed injection cannot drop tables or read other schemas.
  • This tool never tests a live site. Only run dynamic security testing against systems you own or are authorised to test.

Sources and further reading

  1. SQL Injection Prevention Cheat Sheet, OWASP. Parameterised queries first, allow-lists for identifiers
  2. Query Parameterization Cheat Sheet, OWASP. Placeholder syntax across languages and drivers
  3. CWE-89: Improper Neutralization of Special Elements used in an SQL Command, MITRE
  4. Mapper XML Files: String Substitution, MyBatis. Why #{} binds a parameter and ${} does not
  5. SQL Queries in EF Core, Microsoft Learn. FromSql, FromSqlInterpolated and the risk of FromSqlRaw

Frequently asked questions

How do I check my code for SQL injection?

Look for any place where request data becomes part of the SQL string: concatenation, template literals, f-strings or format calls. Paste the code into the tester to flag those patterns, then replace each one with a placeholder and pass the value as a bound parameter.

Does this tool attack or scan my website?

No. It only reads the text you paste and matches it against known unsafe patterns in your browser. It sends no requests to a website or database. For dynamic testing, use an authorised scanner against systems you own or have written permission to test.

Are parameterised queries enough to prevent SQL injection?

For values, yes: bound parameters stop data from being parsed as SQL. They cannot bind identifiers such as column or table names, so those need an allow-list. Least-privilege database accounts and input validation are still worth having as extra layers.

Why is %s flagged in one query but not another?

An unquoted %s is the placeholder style used by Python drivers such as psycopg and MySQLdb, where the values are passed separately and bound safely. A quoted '%s' usually means Python string formatting is building the SQL, so the tester flags it as interpolation.

Is escaping user input as good as using prepared statements?

No. Escaping depends on the right function for the database, character set and context, and it does nothing for numeric or identifier positions. Prepared statements keep code and data separate by design, so they are the reliable fix.

Why did my secure query still get a low score warning?

Low findings such as a WHERE clause comparing against a quoted literal or a -- comment are hints, not proof of a bug. A constant literal is fine. Check whether any flagged value can come from a user, and ignore the hint if it cannot.

Is there an in-depth guide to SQL Injection Tester?

Yes. “Preventing SQL Injection: Spotting Unsafe Queries in Code Review” covers the background, how it works, common pitfalls and worked examples. Read the full guide.