DBLINK_CONNECT_U(3)

πŸ“¦ version 14.24, in opensuse-leap 16.0

okay bestie, so this one lives in the PostgreSQL 14.24 Documentation and honestly the name alone is giving chaos: DBLINK_CONNECT_U. Buckle up πŸ’–


✨ NAME ✨

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

no bc that's literally what it does, the insecurely is doing a LOT of heavy lifting there.


✨ SYNOPSIS ✨

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

two signatures, pick your fighter πŸŽ€


✨ DESCRIPTION ✨

okay so dblink_connect_u() is identical to dblink_connect(), with exactly one (1) difference and it's a spicy one: it'll let non-superusers connect using any authentication method. yep. any. 🌈

and like, that's where it gets scary οΏ½οΏ½ so hear me out:

  • if the remote server picks an authentication method that doesn't involve a password, then impersonation and subsequent escalation of privileges can literally occur 😭 because the session will appear to have originated from the user as which the local PostgreSQL server runs. main character energy but in the worst way πŸ’€
  • and even if the remote server does demand a password, the password can totes be supplied from the server environment β€” like a ~/.pgpass file belonging to the server's user πŸ“ and that opens up not just the risk of impersonation, but also the possibility of exposing a password to an untrustworthy remote server. not the vibe. not even a little. πŸ™ˆ

so because of all that, dblink_connect_u() is initially installed with all privileges revoked from PUBLIC, which makes it un-callable except by superusers. locked down, as it should be πŸ‘‘πŸ”’

in some situations it may be appropriate to grant EXECUTE permission for dblink_connect_u() to specific users who are considered trustworthy β€” but bestie, this should be done with care. fr fr. 🫢

it's also recommended that any ~/.pgpass file belonging to the server's user not contain any records specifying a wildcard host name. just don't πŸ’…

for further details see dblink_connect(). iykyk ✨


and that's the whole page, no cap 🧚 straight from PostgreSQL 14.24, dated 2026 β€” periodt. πŸ’œ

πŸ“¦ where this page comes from