~ / writeups / treaportal

TreaPortal

Hack The Box · Easy · Web

Easy Web Challenge

Challenge Overview

Field Value
Name TreaPortal
Category Web
Difficulty Easy
Target http://<target_ip>:<port>
Concept HTTP Parameter Pollution + SQL injection to bypass a "self-only" profile-lookup restriction

Flag

Type Value
Challenge flag [REDACTED]

Reconnaissance / Analysis

Exploitation

The lookup endpoint /api/user/ reads a username query parameter. Sending the parameter twice makes the access-control check and the database query disagree about which value to use (HTTP Parameter Pollution). The first username carries the SQLi payload; the second is empty — the authorization check passes while the query is injected.

Step 1 — Craft the request (HPP + SQLi)

Intercept the self-lookup request in Burp Suite and change the request line to:

GET /api/user/?username=%27%20or%20flag%21%3D%27&username= HTTP/1.1

URL-decoded, the first parameter is:

username=' or flag!='

' or flag!=' breaks out of the string literal and ORs a condition on the flag column, so the query returns every row whose flag field is non-empty — i.e. the record(s) containing the flag.

Result

The flag is returned in the response body, visible in the browser's Network tab (DevTools inspect tool).

FLAG FOUND

Techniques Demonstrated

  1. Source analysis (init.ts) revealing a prod-only flag field
  2. Broken object-level access control (self-only lookup)
  3. HTTP Parameter Pollution (duplicate username parameter)
  4. SQL injection (' or flag!=')

Tools Used

Browser (view-source + DevTools Network), Burp Suite

← all writeups