Skip to content
SQL injection Write-up Beginner

Exploring Web Vulnerabilities with ThreatByte: From Exploitation

The ThreatByte application had SQL injection in the file search and reflected XSS in the search input. An attacker could extract user credentials, crack MD5 hashes, log in as admin, and steal session cookies to take over accounts.

anotherik Follow

Published on medium.com

ThreatByte is a deliberately vulnerable web application designed to demonstrate some Web Application and API Security risks. It provides a simple platform that aims to represent a simple online file-sharing platform.

anotherik, 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 built SQL queries by inserting user input directly into the query string and marked user input as safe in HTML templates, disabling escaping.

Impact

An attacker could extract all user credentials, crack weak MD5 hashes, log in as admin, and steal session cookies to take over accounts; no defence is mentioned as blocking these attacks.

What the attacker needed

A low-privileged user account; victim clicks a crafted link

The fix

The application should use parameterized queries for SQL and remove the safe filter to allow automatic HTML escaping for XSS.

How it was found

  1. Send a single quote to the search field and observe an error revealing SQLite.
  2. Inject a UNION SELECT payload to list all files in the database.
  3. Use UNION SELECT to extract table names from sqlite_master.
  4. Retrieve the SQL definition of the users table to find columns.
  5. Extract usernames and MD5 password hashes using a UNION SELECT with concatenation.
  6. Crack the MD5 hash with hashcat and log in as admin.

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 lets an attacker type database commands into a search box, so the app runs them and shows private data. Reflected XSS lets an attacker put a script in a link; when a victim clicks it, the script runs in their browser and can steal their login cookie.

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.