Summary
Metasploit's msfdb initialization can configure PostgreSQL with trust authentication and expose its Unix socket in /tmp with permissions that allow local users to access it. A user on the same host may then authenticate as the passwordless postgres superuser and execute operating system commands as the msfdb owner.
Affected context
The issue concerns the PostgreSQL cluster created by Metasploit's msfdb init component. It may be present when the cluster uses trust authentication and its Unix domain socket in /tmp is accessible to other local users. The described impact depends on a local user being able to reach that socket.
Exploit preconditions
- Attack surface: The local PostgreSQL Unix domain socket created during msfdb initialization
- Required access: A local account on the same host that can access the socket
- Trigger point: Authentication to the PostgreSQL cluster and use of its database functionality
- Why exploitation is possible: Trust authentication does not require a password, and overly broad socket access can let local users connect as the
postgressuperuser
Why this happens
The initialization process combines passwordless trust authentication with insufficient access restrictions on a local database socket. This fails to enforce authorization at the database boundary: users who can reach the socket can be treated as trusted superusers. This maps to CWE-284: Improper Access Control, because access to a privileged resource is not adequately limited to authorized users.
Potential impact
- A local user may authenticate to PostgreSQL as the
postgressuperuser without a password. - An attacker could execute operating system commands with the privileges of the msfdb owner.
- The database and data accessible to that account could be compromised or altered.
- The host could be further compromised, depending on the privileges and reach of the msfdb owner.
General mitigation guidance
Defensive patterns focus on requiring authenticated database access and limiting who can reach local database sockets.
- Prefer password-based or otherwise explicitly authenticated access over trust authentication.
- Restrict socket directories and files to the intended service account and authorized users.
- Avoid placing privileged service sockets in broadly accessible locations.
- Run database services and related processes with only the privileges they require.
- Review initialization defaults so secure authentication and restrictive permissions are applied automatically.
How teams detect issues like this
- Review database initialization code and configuration for trust authentication or passwordless privileged roles.
- Check socket directory and socket permissions for access by unintended local users.
- Use static analysis and code review to flag permissive authentication defaults and insecure temporary-directory usage.
- Enforce policy checks that require authenticated database access and restricted permissions for service sockets.
- Monitor database connections and privileged activity for unexpected local accounts or processes.

