DBLINK_CONNECT_U(3)

ok so this page lives in the PostgreSQL 18.6 Documentation, section 3 (that's the C library functions girlies, iykyk) ✨


🌸 NAME 🌸

dblink_connect_u β€” opens a persistent connection to a remote database, insecurely 😭


πŸŽ€ SYNOPSIS πŸŽ€

dblink_connect_u(text connstr) returns text
dblink_connect_u(text connname, text connstr) returns text

πŸ’– DESCRIPTION πŸ’–

okay so dblink_connect_u() is literally identical to dblink_connect(), with exactly one difference and it's a big one: it will let non-superusers connect using any authentication method. any. at all. no cap 🫢

and like… bestie, that's why it's giving chaos energy, because:

  • If the remote server picks an authentication method that does not involve a password, then impersonation and subsequent escalation of privileges can occur πŸ’€ β€” because the session will appear to have originated from the user as which the local PostgreSQL server runs.
  • And even if the remote server does demand a password, it's possible for the password to be supplied from the server environment, such as a ~/.pgpass file belonging to the server's user. 😳

so yeah, that opens up not only a risk of impersonation, but also the possibility of exposing a password to an untrustworthy remote server. it's giving nightmare fuel fr fr πŸ“

therefore, dblink_connect_u() is initially installed with all privileges revoked from PUBLIC, making it un-callable except by superusers. periodt. πŸ”’

in some situations it may be appropriate to grant EXECUTE permission for dblink_connect_u() to specific users who are considered trustworthy, but this should be done with care. it is also recommended that any ~/.pgpass file belonging to the server's user not contain any records specifying a wildcard host name. πŸ™ˆ

for further details see dblink_connect(). πŸ‘‘


mwah πŸ’‹ that's the whole page, bestie β€” go read dblink_connect() next, she's the well-behaved sibling.

postgres 18.6, dated 2026, source-version-and-date girlies, slay πŸ¦‹βœ¨