By NHI Mgmt Group Editorial TeamPublished 2025-06-25Domain: Best PracticesSource: StrongDM

TL;DR: Listing all PostgreSQL databases is presented as an operational task, but the real issue is whether access to inventory, metadata, and administrative controls is governed tightly enough to avoid unintended exposure, according to StrongDM. For IAM teams, the lesson is that database visibility, privilege scope, and auditability belong in the same governance conversation as access paths.


At a glance

What this is: This is a PostgreSQL how-to guide showing six ways to list databases, with an important security caveat that database visibility and privilege settings shape what users can see and change.

Why it matters: It matters because database enumeration is not just a DBA convenience issue; it is an identity and access control question that affects least privilege, auditability, and safe operational access across human, NHI, and privileged workflows.

By the numbers:

👉 Read StrongDM's guide to listing PostgreSQL databases across psql, pgAdmin, and more


Context

In PostgreSQL, listing databases is a simple administrative action, but the security meaning changes as soon as visibility depends on role membership, client authentication, and server configuration. The primary governance question is not whether someone can run \l or query pg_database, but whether the right identity has the right level of visibility at the right time.

That distinction matters for IAM and privileged access teams because database inventory is often an access boundary, not just a convenience feature. The article also touches the familiar problem of operational friction versus secure control, especially when administrators are tempted to loosen pg_hba.conf or broaden permissions to make troubleshooting easier.


Key questions

Q: How should security teams govern database listing access in PostgreSQL?

A: Treat database listing as a privileged visibility task, not a default convenience. Give only the identities that truly need inventory access a dedicated read-only role, separate it from administrative permissions, and review the underlying authentication rules that determine who can connect in the first place. The goal is to keep observation narrow and auditable.

Q: Why does PostgreSQL database enumeration matter to least privilege?

A: Because database listing reveals environment structure, and structure is often the first step toward misuse. If broad roles can enumerate every database by default, least privilege is only partial. Security teams should limit metadata visibility to the minimum role set required for operations and avoid using shared admin accounts for routine checks.

Q: What do teams get wrong when they loosen pg_hba.conf for convenience?

A: They often treat it as a connectivity fix instead of an identity control. Changing host-based authentication can expand who can reach PostgreSQL, from where, and with which method. Teams should only relax these rules with a clear access purpose, a limited scope, and a plan to review the change afterward.

Q: What is the difference between GUI database browsing and direct psql access from a governance perspective?

A: The difference is mostly in the interface, not in the access problem. Both depend on the authenticated identity and the permissions granted to that identity. Teams should govern who can enumerate databases, who can administer them, and who can only view them, regardless of whether the person uses psql, pgAdmin, or another client.


Technical breakdown

Database listing through psql, SQL, and GUI tools

PostgreSQL exposes database inventory through multiple interfaces, each with a different control surface. The psql \l meta-command reads server metadata, SQL against pg_database can filter template databases, and GUI tools such as pgAdmin or DBeaver surface the same information through a graphical layer. None of these methods changes the underlying authorization model. They only determine how the authenticated identity asks for the data and how much metadata the server returns. The important distinction is between observation and privilege: listing databases may be permitted even when creation, alteration, or administrative access is not.

Practical implication: separate read-only inventory access from administrative permissions and review which identities can enumerate database metadata.

Why pg_hba.conf and authentication settings change visibility

The article’s error handling section points to pg_hba.conf, authentication methods such as md5 or scram-sha-256, and listen_addresses as factors that influence access. These are not just connectivity settings. In PostgreSQL, host-based authentication determines which identities can connect from which networks under which methods, and that directly shapes whether database listing is possible at all. A permissive setting can turn a minor troubleshooting step into broader visibility than intended, while a restrictive setting can block legitimate operations if poorly designed.

Practical implication: treat authentication and host access rules as identity controls and review them before relaxing them for operational convenience.

RBAC and least privilege in database administration

The article frames role-based access control as the mechanism that keeps users limited to what they need. In practice, RBAC becomes the guardrail between routine administration and overbroad database visibility. When database listing is separated from broader privileged functions, teams can support operators, developers, and automation without exposing unnecessary metadata or control paths. That is the same governance principle used across human admin accounts, service accounts, and scripted access flows: make the visible surface narrow, auditable, and purpose-bound.

Practical implication: define explicit roles for database inventory, connection management, and admin actions instead of sharing broad privileged accounts.


Read our 52 NHI Breaches Analysis report for a comprehensive view of breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Database inventory is an access-control decision, not a convenience feature. PostgreSQL database listing only looks operational on the surface. In governance terms, it exposes who can observe the structure of an environment and who can move from observation to action. That distinction matters because visibility often expands during troubleshooting and never gets tightened again. The practitioner conclusion is simple: treat database enumeration as part of privileged access design, not an afterthought.

Database visibility and NHI visibility are the same governance problem in different wrappers. The control question is whether an identity can see enough to act safely without seeing enough to misuse. That applies equally to a DBA, a script, or a service account running checks against PostgreSQL. The implication is that identity scope, not interface choice, should define the boundary of access.

Standing administrative access creates avoidable exposure in routine database operations. When users keep broad PostgreSQL visibility all the time, the environment assumes every query is safe simply because it is familiar. That assumption fails in mixed operational settings where read access, troubleshooting, and administrative changes overlap. The practitioner conclusion is to minimise persistent privilege and make database inventory access narrowly purpose-bound.

Zero trust in database environments depends on continuous identity checks, not trust in the client tool. A secure psql session is not secure because it is a terminal, and a GUI is not risky because it is graphical. The real question is whether the authenticated identity, source network, and granted role together justify the access requested. The practitioner conclusion is to govern the identity chain first and the tooling second.

Operational shortcuts in database administration often become lifecycle debt. Teams that loosen authentication, share admin roles, or grant broad visibility to speed up support create privilege that later survives beyond its original purpose. That pattern affects human admins and non-human automation alike. The practitioner conclusion is to connect database access reviews to the same lifecycle discipline used for other privileged identities.

From our research:

What this signals

Database inventory belongs in the same control plane as privileged identity governance. If teams cannot see which identities can enumerate environments, they cannot reliably enforce least privilege or prove that access scope matches operational need. The practical signal is to fold PostgreSQL visibility paths into the same review cycle used for other privileged roles, including service accounts and shared admin identities.

Standing visibility is a form of privilege creep. A database browser, CLI user, or automation account that can always see every database creates the same governance debt as any other persistent entitlement. Teams should look for access paths that remain enabled long after the original operational need has passed, then retire those paths into a documented lifecycle process.


For practitioners

  • Separate inventory access from administrative access Create a distinct role for listing PostgreSQL databases and keep it read-only. Do not reuse admin credentials for routine visibility tasks, even when the task feels harmless.
  • Review host-based authentication rules before widening access Check pg_hba.conf, listen_addresses, and authentication methods before loosening controls to solve a connection issue. Make sure any change is limited to the smallest network and identity scope that still supports the task.
  • Log and review every database inventory action Capture database enumeration activity alongside other privileged actions so you can see which identities are routinely discovering environments. Use those logs to identify unnecessary visibility and stale access.
  • Align database access with least privilege roles Assign connection, read, and admin duties to different roles so operators do not inherit broader access just because they need one command. This is especially important where scripts and shared accounts are involved.

Key takeaways

  • PostgreSQL database listing is an identity governance issue because visibility itself is a privilege.
  • Access configuration, especially host-based authentication and RBAC, determines whether database enumeration stays narrow or becomes overexposed.
  • Teams should separate inventory roles from admin roles and review all persistent database visibility as part of lifecycle governance.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-03Database visibility and privilege scope mirror NHI credential overexposure patterns.
NIST CSF 2.0PR.AC-4Role-based access and authorization boundaries are central to safe database enumeration.
NIST Zero Trust (SP 800-207)PR.AC-5Network and identity conditions determine which PostgreSQL identities can enumerate databases.

Use zero trust principles to verify identity, source, and role before allowing database metadata access.


Key terms

  • Database Enumeration: The act of discovering which databases exist inside a PostgreSQL environment. In governance terms, enumeration is a visibility privilege, not a harmless query, because it reveals environment structure that can inform both legitimate administration and misuse.
  • Host-based Authentication: A PostgreSQL control that decides which clients may connect, from where, and with which authentication method. It is an identity boundary as much as a network rule, because it shapes who can reach the server and what actions that identity can attempt.
  • Role-based Access Control: A permission model that assigns database access through roles instead of individual one-off grants. In PostgreSQL administration, RBAC helps separate read-only inventory, operational support, and full administration so routine tasks do not inherit unnecessary privilege.
  • Standing Privilege: Persistent access that remains available whether or not it is currently needed. In database environments, standing privilege becomes risk when identities can always enumerate, view, or administer resources instead of receiving access only for a defined task window.

Deepen your knowledge

Database visibility, least privilege, and privileged access in PostgreSQL are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building a governance programme from a similar starting point, it is worth exploring.

This post draws on content published by StrongDM: How to List All Databases in PostgreSQL (psql and More). Read the original.

NHIMG Editorial Note
Published by the NHIMG editorial team on 2025-06-25.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org