Hacking Headless: From Web to Root with Blind XSS and Sudo Shenan
The web application had a blind XSS vulnerability in the User-Agent header and an admin cookie without the HttpOnly flag, allowing an attacker to steal the cookie and access the dashboard. The dashboard's date parameter was vulnerable to command injection, leading to a reverse shell, and a sudo-enabled script used a relative path that allowed privilege escalation to root.
Published on medium.com
Learn how I exploited blind XSS and a sudo misconfiguration to root Hack The Box’s Headless with Burp Suite and custom scripts.
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 failed to sanitise the User-Agent header before reflecting it, and the admin cookie was set without the HttpOnly flag, enabling session hijacking.
Impact
An attacker could steal the admin cookie and access the dashboard, then exploit command injection to gain a shell as user dvir, and finally escalate to root via a sudo misconfiguration.
What the attacker needed
Access to /support form; admin views the request; attacker-controlled server
How it was found
- Browse to the /support page and submit a test script in the message field to check for XSS.
- Intercept the /support form request in Burp Suite and modify the User-Agent header to contain a script.
- Forward the request and observe an alert box, confirming XSS in the header.
- Craft a blind XSS payload in the User-Agent header that sends document.cookie to an attacker-controlled server.
- Start a Python HTTP server to capture incoming requests.
- Send the request and capture the is_admin cookie from the server logs.
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.
A blind XSS is a cross-site scripting flaw where the malicious script runs in someone else's browser, not your own, so you need a way to capture the result. Here, the attacker put a script in the User-Agent header of a support form, and when an admin viewed the request, the script sent the admin's cookie to the attacker. The cookie lacked a protection flag called HttpOnly, which normally stops scripts from reading it, so the attacker could use it to log in as admin.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.