Skip to content
SQL injection Write-up Beginner

SQL Injection in PHP Reservation System — Breaking Access Contr

The manage_user.php page builds an SQL query by directly inserting the user-supplied id parameter, so an authenticated attacker can inject SQL and read arbitrary data such as usernames and password hashes from the database.

Cyber Tamarin Follow

Published on cybertamarin.medium.com

During further analysis of a PHP-based Resort Reservation System available on SourceCodester, I identified a critical SQL Injection vulnerability in the manageuser.php component.

Cyber Tamarin, on cybertamarin.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

User input from the id parameter is concatenated directly into an SQL query without prepared statements or validation.

Impact

An authenticated attacker could extract usernames, password hashes, personal data and reservation records, and may identify administrative accounts to escalate privileges.

What the attacker needed

An authenticated account

The fix

The code should use a prepared statement with the id bound as an integer and validate that the input is numeric.

How it was found

  1. Log in to the application as an authenticated user.
  2. Open the manage_user page with a crafted id value that injects a UNION SELECT.
  3. Read the returned usernames and password hashes from the edit form.

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.

The page takes a number from the web address and pastes it straight into a database command. By putting extra database instructions in that number, an attacker can make the database return other information, like user names and scrambled passwords. This is called SQL injection.

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 Cyber Tamarin

View all

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