Robots — Stored XSS + RFI to RCE, Double-MD5 Cracking, Sudo Curl and Apache2 Chains to Root | TryHackMe
A stored cross-site scripting flaw in the username field of a registration form let an attacker run JavaScript in an administrator's browser, and a phpinfo() page that echoed the Cookie header allowed the admin session cookie to be stolen despite HttpOnly. The authenticated admin page then passed a user-supplied URL into PHP's include(), giving remote file inclusion and code execution as www-data, after which database credentials, a double-MD5 password, and two sudo misconfigurations led to root.
Published on meetcyber.net
Robots is a Docker-based TryHackMe machine themed around Asimov’s Three Laws of Robotics. The path to root starts with a stored XSS vulnerability in a user registration form, used to hijack an administrator’s session cookie by abusing a phpinfo() information disclosure page.
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 stored usernames without output encoding, exposed a phpinfo() page that reflected request headers, and passed an unvalidated user-supplied URL directly into PHP's include() with allow_url_include enabled.
Impact
An attacker could run JavaScript in the admin's session, steal the admin cookie, and then execute code as www-data inside the container, with the text also showing a path onward to root through database credentials and sudo misconfigurations.
What the attacker needed
Ability to register an account; admin bot visits pages with usernames; attacker-hosted listener reachable by target; allow_url_include enabled on server
How it was found
- Register an account with a script element as the username to confirm the field is stored and rendered unescaped in the admin view.
- Register a username whose script fetches server_info.php and posts the response body to an attacker listener.
- Run a listener, wait for the bot to visit, and extract the admin PHPSESSID from the saved phpinfo output.
- Use the stolen session against admin.php and submit a local file path in the url parameter to confirm file inclusion.
- Retrieve config.php through the php://filter base64 wrapper to obtain database credentials.
- Serve a PHP reverse shell and submit its remote URL in the url parameter to get a shell as www-data.
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 web form saved whatever a user typed as their username and later showed it to an administrator without cleaning it, so an attacker could put JavaScript there and have it run in the admin's browser. A separate diagnostic page printed the browser's cookie header back out, which let that script send the admin's session cookie to the attacker even though the cookie was marked HttpOnly (a flag that stops scripts reading it directly). With the admin session, a page that fetched any URL the user gave it could be pointed at the attacker's own file, which the server then ran as code.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.