Skip to content
SQL injection Write-up Beginner

The Login That Didn’t Need a Password

The login form built its SQL query by pasting the username directly into the string, so a username containing a quote and a comment marker could comment out the password check. An attacker could log in as the administrator without knowing the password.

medium.com

Published on medium.com

Lab one was a shop filter — I made hidden products appear. This one is sharper.

morgan_hack, 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 application built its SQL query by concatenating user input directly into the string instead of using parameterised queries.

Impact

An attacker could log in as the administrator without a password, gaining full access to the admin account.

What the attacker needed

Access to the login form; ability to intercept and modify requests

The fix

The login should use parameterised queries (prepared statements) so user input is treated as data, not part of the SQL command.

How it was found

  1. Capture the real login request with a proxy, noting the CSRF token, username and password fields.
  2. Change only the username value to include a quote and a comment marker, leaving the CSRF token and password unchanged.
  3. Forward the request and observe a 302 redirect to the administrator's account page with a new session cookie.
  4. Use the new session cookie (or complete the login in the browser) to access the administrator account.

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 login form usually asks the database a question like 'is there a user with this name and this password?'. Here the app glued whatever you typed straight into that question. By typing a special character that ends the name and starts a comment, the password part of the question was ignored, so the database said yes to the admin account.

What is SQL injection?

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

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.