PostgreSQL Trust Authentication Detection
PostgreSQL's pg_hba.conf file controls which hosts can connect to which databases with which authentication method. When the method is set to trust for a host entry, any connection from that host is accepted without a password regardless of which user is claimed. Trust authentication is commonly used for local connections and sometimes misconfigured to cover broader network ranges. Confirming it is active from your source IP gives immediate database access with no credentials required.
Test for Trust Authentication
Attempt a connection as postgres with no password. A successful connection with no prompt confirms trust authentication is in effect for your source IP:
current_user -------------- postgres (1 row)
No password prompt and a successful query result confirms trust authentication. Test additional common usernames — trust may apply to specific users or databases rather than all connections:
Read pg_hba.conf if Accessible
With superuser access the pg_hba.conf file can be read directly through PostgreSQL to understand the full scope of trust entries:
pg_read_file is restricted to superuser accounts and reads files relative to the PostgreSQL data directory. If it returns content, look for lines containing trust in the method column. A trust entry covering a broad CIDR range or 0.0.0.0/0 is a critical misconfiguration affecting any host in that range.
Query the pg_hba_file_rules View
PostgreSQL 10 and later expose pg_hba.conf entries through the pg_hba_file_rules view which is readable by superusers:
type | database | user_name | address | netmask | auth_method -------+----------+-----------+-------------+-----------------+------------- host | all | all | 0.0.0.0 | 0.0.0.0 | trust local | all | all | | | trust
A trust entry with address = 0.0.0.0 and netmask = 0.0.0.0 means trust authentication applies to all hosts. An entry scoped to a subnet still affects every host on that subnet. Any trust entry covering more than localhost is a finding worth documenting — it enables unauthenticated access from any IP within the covered range.
Check Privilege Level of the Trust Account
Once trust authentication is confirmed, immediately check what privileges the accessible account holds:
rolname | rolsuper | rolcreaterole | rolcreatedb | rolcanlogin ----------+----------+---------------+-------------+------------- postgres | t | t | t | t
rolsuper = t confirms superuser access without a password. This enables COPY FROM PROGRAM for OS command execution, pg_read_file for arbitrary file reads, and extension loading. All exploitation techniques are immediately available.
References
-
PostgreSQL — pg_hba.conf documentationwww.postgresql.org/docs/current/auth-pg-hba-conf.html (opens in new tab)
Trust authentication method behavior and host entry format reference
-
PostgreSQL — pg_hba_file_rules viewwww.postgresql.org/docs/current/view-pg-hba-file-rules.html (opens in new tab)
Programmatic access to pg_hba.conf entries via the catalog view
Was this helpful?
Your feedback helps improve this page.