Vulnerability class

How to prove SQL injection, and verify the parameterised fix

Updated

SQL injection is proven when a parameter changes the query's behaviour rather than its value — a boolean that flips the result set, a quote that breaks the statement, or a delay you control. ORMs do not remove it: raw fragments, sort parameters and search are where it lives.

Where this class of bug actually lives in an app on an ORM

  • Raw fragments. where(\"status = '#{s}'\"), sequelize.literal, text(), raw(). The ORM hands these through untouched.
  • Sorting and filtering. ORDER BY ${sortColumn} cannot be parameterised, so it is interpolated — and it is injectable.
  • Search and reporting. Admin reports, exports and full-text search often run on a raw connection where conventions do not apply.
  • Second-order. A value stored safely and later concatenated into a query in a report or a batch job.

What to try first

  1. Send a single quote and compare the error with the baseline. Then send two and compare again.
  2. Use a boolean pair on every filter: x' AND '1'='1 versus x' AND '1'='2. Different result sets means injection.
  3. Time-based on blind endpoints: a sleep payload and a measured difference of about the delay.
  4. Try the sort, order and direction parameters, which are interpolated in most frameworks.

A reproduction you can keep

Timing is the least ambiguous proof on a blind endpoint. Same request, one payload difference:

Time-based proof, then the boolean pair
# baseline
time curl -sS 'https://staging.example.com/api/search?q=widget' -H 'Authorization: Bearer ***'

# delay payload (Postgres; use SLEEP(5) on MySQL, WAITFOR on MSSQL)
time curl -sS --get 'https://staging.example.com/api/search' \
  --data-urlencode "q=widget'||(SELECT 1 FROM pg_sleep(5))||'" \
  -H 'Authorization: Bearer ***'

# boolean pair — the result sets must differ
curl -sS 'https://staging.example.com/api/search?q=widget%27%20AND%20%271%27%3D%271'
curl -sS 'https://staging.example.com/api/search?q=widget%27%20AND%20%271%27%3D%272'

# vulnerable: ~5s on the delay, different bodies on the pair
# fixed: both baseline speed, identical bodies

What "fixed" has to look like

Every value must travel as a bound parameter, and anything that cannot be — an identifier such as a column or direction — must be validated against an allowlist. Verify by re-running the delay payload (baseline speed) and the boolean pair (identical results), including on the sort parameter.

Where people get this wrong

  • Escaping quotes is not parameterisation. Numeric context, LIKE and IN lists all bypass escaping.
  • The sort parameter is the most commonly missed injection point because it cannot be bound and gets interpolated by default.
  • A fixed endpoint does not mean a fixed codebase: the same fragment is usually copied in three places.

What Offense does here

Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

Can an ORM still be vulnerable to SQL injection?

Yes. Every ORM exposes a raw-SQL escape hatch, and ordering and identifiers are commonly interpolated because they cannot be parameters.

What is the most reliable proof of blind SQL injection?

A time-based payload with a measured delay, repeated twice, compared against a baseline of the same request. Boolean pairs corroborate it.

Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.