Skip to content
PostgreSQL
Service

PostgreSQL

PostgreSQL attack reference covering version and role enumeration, weak cred discovery, RCE via COPY TO PROGRAM and UDFs, privesc, lateral movement, persistence, and data exfiltration

:5432 6 guides 3 phases
1 min read Created: Dec 28, 2025 Updated: Jul 14, 2026

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

1

Vulnerability Discovery

Guides for finding PostgreSQL auth flaws, weak creds, and misconfigs

4

Exploitation

RCE via COPY TO PROGRAM, UDF, file read, and privesc methods

1

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.

May 6, 2026 • 7 min read