PostgreSQL runs on TCP port 5432 and is a widely used open-source relational database. Nmap identifies it as postgresql. It is common in web application stacks, data warehouses, and cloud environments.
Default installations may allow local trust authentication or have weak passwords on the postgres superuser account. PostgreSQL's COPY command can read and write files on the server. The pg_execute_server_program role and user-defined functions in C or PL/Python provide paths to OS command execution when sufficient privileges are available.
Test credentials with psql, hydra, or crackmapexec. After authentication, check the current user's role and privileges, list databases and tables, and look for sensitive data. Test file read/write capabilities and check for installed extensions that enable command execution.
Enumeration
Enumerate PostgreSQL version, DBs, schemas, roles, and extensions
Vulnerability Discovery
Guides for finding PostgreSQL auth flaws, weak creds, and misconfigs
PostgreSQL Remote Access Misconfiguration
PostgreSQL Superuser and Dangerous Privilege Detection
PostgreSQL Trust Authentication Detection
PostgreSQL Weak and Default Credential Check
Exploitation
RCE via COPY TO PROGRAM, UDF, file read, and privesc methods
PostgreSQL RCE and Exploitation
Exploit PostgreSQL for RCE via COPY TO/FROM PROGRAM, UDF injection, and privilege escalation techniques targeting misconfigured or authenticated database instances.