Skip to content
SQL injection Write-up Intermediate

SQL Injection in Password Reset: Full Database, One Email

A password reset link contained a ukey parameter that was concatenated directly into a SQL query without sanitisation. An attacker who modified that parameter could read every table in the database, including user records and password hashes.

infosecwriteups.com

Published on infosecwriteups.com

Every table. Every user record.

LordofHeaven, on infosecwriteups.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 forgot-password script built its SQL query by joining the ukey value from the URL directly into the query string instead of using a prepared statement.

Impact

An unauthenticated attacker could read the entire database, including user records, admin credentials, email addresses, session tokens and password hashes; file read and command execution were blocked because the database user lacked those privileges.

What the attacker needed

A valid account on the site; access to the reset email inbox; ability to modify the reset link

The fix

The script should use a prepared statement with bound parameters instead of concatenating the ukey value into the query; the text says the issue was still present sixteen months after reporting.

How it was found

  1. Submit a non-domain email to the forgot-password form and observe the PHP and SQL error.
  2. Register with a valid domain email and trigger the reset flow to receive the link.
  3. Copy the ukey value from the reset link into a request in Burp Repeater.
  4. Append a single quote to the ukey value and observe the same SQL error.
  5. Run SQLMap against the endpoint to enumerate databases and dump tables.

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 forget your password, a website emails you a link with a long code in it. This site put that code straight into a database command without checking it, so changing the code let the author run their own database commands. That meant they could read every user's details, including scrambled passwords.

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.