HackTheBox - Gavel
Why It Matters
This technique shows that even prepared statements can be bypassed when column names are user‑controlled, highlighting critical security gaps for developers and pen‑testers.
Key Takeaways
- •SQL injection via column name in prepared statements demonstrated
- •Timing attacks reveal valid usernames during login enumeration
- •Git repository exposure allowed full source code retrieval
- •Open-source tools Sneak and OpenGrep identified multiple vulnerabilities
- •Custom injection crafted query to extract MySQL version and password hashes
Summary
The video walks through the Hack The Box “Gavel” machine, focusing on a rare SQL injection that abuses a prepared statement by injecting the column name.
After enumerating the host with nmap, the presenter discovers an exposed .git directory, clones the repository, and runs static analysis tools Sneak and OpenGrep, which flag a SQL injection in inventory.php and several low‑severity issues.
The injection works because PHP’s PDO does not bind column identifiers, allowing the attacker to replace the column with a question mark, comment out the rest of the query, and inject a sub‑select that reveals the MySQL version and password hashes from the users table.
The demonstration underscores the danger of exposing source code, the value of timing attacks for username enumeration, and the necessity of sanitizing all query components, even when using prepared statements.
Comments
Want to join the conversation?
Loading comments...