Skip to content
SQL injection Write-up Intermediate

Web Security Series #9 — Exploiting Second-Order SQL Injection

A SQL injection payload stored during user registration was later executed when the application reused that stored value in a login query, causing the login to succeed without valid credentials and revealing hidden Bio information. The attacker could bypass authentication and access data not normally displayed.

Laibakashif Follow

Published on medium.com

SQL Injection is widely known as one of the most dangerous vulnerabilities in web applications. Most testers focus on first-order SQL injection, where malicious input is executed immediately after submission.

Laibakashif, 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

Likely the application stored user input without validation and later built a login SQL query by concatenating that stored value, so the injected SQL logic executed at login time.

Impact

An attacker could bypass authentication and reveal hidden Bio information from the database.

What the attacker needed

Access to the vulnerable lab environment; ability to register an account

The fix

The application should use prepared statements (parameterized queries) for all database interactions and never trust stored data as safe.

How it was found

  1. Create a normal test account and log in to observe that the Bio field is not displayed.
  2. During sign-up, enter a username containing SQL logic and a password, and note that the account is created without immediate execution.
  3. Log in using the stored malicious username and password.
  4. Observe that the SQL payload executes and the hidden Bio information is revealed.

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.

SQL injection is when user input is inserted into a database command (a query) without being treated as plain text, so the input can change what the command does. Here the malicious input was saved during sign-up and only caused harm later at login, which is why it is called second-order. The result was that the login check was bypassed and hidden profile information appeared.

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 Laibakashif

View all

7 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.