Skip to content

Bug class · Intermediate

SQL injection

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

median public bounty
$1,750

Covers CWE 89, 564.

How it works

Full lesson

The pattern behind every report in this class.

SQL injection is a flaw where user input reaches a database query without being properly separated from the query's structure. The evidence shows it recurring across URL parameters, path segments, search boxes, login fields, headers, JSON bodies and GraphQL arguments, on targets ranging from government sites to WordPress plugins and enterprise appliances. Programs care because a confirmed injection can expose or alter the whole database, and in several reports it was chained to command execution or file writes.

The root cause is almost always the same: input is concatenated into a statement instead of being bound as a parameter, or a library, ORM or connector fails to escape it. The evidence includes raw concatenation, bad escaping in database libraries, unsafe alias and connector handling, and ORM methods that accept raw fragments. It also shows that defences such as WAFs and input filters are often incomplete, so a blocked payload does not mean the endpoint is safe.

Where it turns up most often in this evidence: ordinary request parameters on new targets, numeric identifiers in URL paths, search boxes and search APIs, login and password reset fields, sort and order parameters, WordPress plugin handlers, legacy CGI scripts, and known vulnerable appliances. The typical fix is parameterised queries everywhere, including dynamic fragments such as ORDER BY and aliases, plus patching known CVEs.

A query is built by joining fixed SQL text with user input. If the input contains characters that change the query's meaning, the database executes a different statement than the developer intended. The evidence shows this happening when parameters, path values, JSON keys, headers and GraphQL arguments are inserted directly into queries.

Things to try

All 475

Each line worked in a disclosed report. Test only what a program's scope allows.

WAF bypass and filter evasion 187

  • Work around input length filters to still dump the database.
  • Remove client-side length limits on identifier fields and inject into them.
  • When requests are encrypted client-side, reverse the encryption in the client and automate injection testing against the decrypted request.
  • Test parameters on Google BigQuery for injection and WAF bypass.

Other 44

  • Test basic request parameters for SQL injection as a starting point on any new target.
  • Test several parameters by hand in a repeater tab rather than relying only on a scanner.
  • Test parameters on DoD sites for injection, including blind and time-based variants.
  • Test parameters on Eternal and Zomato for injection.

CMS and third-party software CVEs 29

  • Test parameters on Concrete5 search endpoints for time-based injection.
  • Test parameters on file transfer services for known CVE injection.
  • Test parameters on Moodle installations for blind injection and broken access control.
  • Test parameters on MOVEit Transfer for known CVE injection.

JSON body and API parameters 19

  • Test an email check API for unauthenticated Oracle injection.
  • Send POST requests to an unauthenticated items endpoint and test its parameters for injection.
  • Test JSON body parameters for boolean-based injection by comparing true and false responses.
  • Test acctid parameters on comment and import endpoints for time-based injection.

Blind and time-based confirmation 16

  • Use blind and timing-based techniques against a search box whose terms are split on whitespace before reaching the query.
  • Test search pages ending in .aspx for blind SQL injection through their query parameters.
  • Test an identifier string parameter in a bibliography search CGI for blind injection.
  • Test a training course search API for blind injection.

Bypasses and variations

All 309
  • Try unusual encodings and syntax variations against a leading WAF before exploiting the injection.
  • Use a tamper script to encode payloads past a WAF.
  • Use double encoding to get past a WAF.
  • Use case variation and comments to get past a WAF.
  • Use alternative syntax when commas are filtered.
  • Use UNION with a WAF bypass to extract data.

Typical fixes

All 30
  • Use parameterised queries and prepared statements for all database access, including bound parameters for every piece of user input.
  • Fix parameter escaping in database libraries, including the WordPress DB class prepare method.
  • Parameterise or sanitise URL path values before they reach SQL queries.
  • Quote and validate aliases before they reach generated SQL.
  • Escape user input before building Solr queries.
  • Patch MOVEit Transfer against CVE-2023-36934.

Tips for beginners

All 13
  • Start with simple request parameters on a new target, including search boxes, lookup forms and numeric identifiers in the URL path. The evidence shows these are common entry points and are often overlooked in favour of login pages.
  • Test login username fields, password reset username fields and forgotten password forms. The evidence records injections in these fields, including time-based confirmation in a login request.
  • Do not ignore sort and order parameters. The evidence shows ORDER BY clauses and ORM ordering methods accepting raw fragments, and conditional delays placed in sort parameters to confirm injection.
  • When error output is suppressed, use time-based tests and repeat them with shorter delays to rule out network jitter. The evidence describes confirming delays that scale with the supplied value before automating extraction.
  • Compare true and false conditions in search fields and JSON bodies, watching status codes and response lengths. The evidence shows this working where scanners failed and where the search term was split before reaching the query.
  • Test headers and less obvious inputs such as the User-Agent, Referer, cookies and custom headers. The evidence records injections in these locations, confirmed with time delays.

Start here: a reading path

Open the path

Clear reports in order, easiest first.

Guides and techniques

View all

The best explainers, cheat sheets and technique posts on SQL injection, from around the web.

Newest reports

All 1,659

Most recently disclosed.

New SQL injection reports by email

Follow SQL injection and get each week's new disclosures in one short email.

Free. New reports for what you follow, weekly by default. One-click unsubscribe. Privacy