Skip to content
SQL injection Write-up Intermediate

$11,500 for a Payload That Waited: Second-Order SQL Injection in

A username containing a SQL metacharacter was stored safely at registration, but a separate reporting feature later concatenated that stored value into a SQL query without parameterisation. An attacker could trigger the reporting logic indirectly and achieve full SQL injection against the database.

T4nv1 Follow

Published on medium.com

First-order SQL injection shows up immediately — you send a payload, the vulnerable query runs right then, and you see the effect in the same response. Second-order injection is slower and easier to miss entirely, because the payload gets stored safely, through a perfectly well-parameterized query, and only becomes…

T4nv1, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The reporting query concatenated a stored username value directly into SQL instead of using parameterised queries, even though the original registration insert was safe.

Impact

Full SQL injection capability against the application's database, reachable indirectly through any stored value that eventually flows into the vulnerable reporting query, without needing direct injection against any single immediately-exploitable endpoint.

What the attacker needed

A free account; ability to set a username; access to a scheduled digest feature

The fix

The reporting query was parameterised and other admin-facing features reading stored user data were audited, finding one additional instance.

How it was found

  1. Register a test account with a username containing a SQL metacharacter that is inert in a parameterised insert.
  2. Confirm registration succeeds and stores the literal string without executing it.
  3. Trigger the report-generation logic through a scheduled digest feature reachable without admin privileges.
  4. Observe a roughly five-second delay matching the conditional sleep when the condition is true, and normal speed when false.
  5. Repeat true and false variants several times to rule out network jitter.
  6. Use a boolean-based variant to extract a single known database version fact as confirmation.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When you type something into a website, it is often saved in a database. If the website later reads that saved text and builds a new database command by gluing the text directly into it, a malicious value can turn into a command. Here the first save was safe, but a later report feature glued the saved username into a database query, so the stored attack ran later.

What is SQL injection?

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

More by T4nv1

View all

113 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

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