Skip to content
SQL injection Write-up Intermediate

Web Security Series #7 — Exploiting Blind SQL Injection via Ses

A session cookie value was inserted into a database query without proper handling, so a crafted cookie could change the query's logic. By asking the database true/false questions through the cookie, an attacker could extract the database version and other users' passwords one character at a time.

Laibakashif Follow

Published on medium.com

SQL Injection is one of the most critical vulnerabilities in web applications. However, not all SQL Injection flaws are directly visible.

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

Impact

An attacker who can set or guess a session cookie value could extract database contents such as the version and other users' passwords; the text demonstrates this only in a local lab.

What the attacker needed

Local vulnerable lab; Burp Suite; sqlmap; valid login credentials

The fix

The application should use prepared statements or parameterised queries and treat cookies as untrusted input.

How it was found

  1. Log in with valid credentials and note the baseline Content-Length of the response.
  2. Change the password to an invalid value and observe that the Content-Length changes.
  3. Try SQL injection in the login fields and see that it is filtered or not injectable.
  4. Run sqlmap against the saved request and see it reports the parameters as not injectable.
  5. Send a GET request with the session cookie, then alter the cookie and watch the Content-Length and welcome message change.
  6. Append a boolean condition to the cookie and use substring checks, then Burp Intruder, to extract the version and a password character by character.

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.

A website often stores a session cookie in your browser to remember who you are. Here the site put that cookie's value straight into a database command, so a modified cookie could make the database answer yes/no questions. By watching whether the page looked normal or not, the author could slowly guess secret values like passwords, one letter at a time.

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.