DBLINK_CONNECT_U(3)

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

okay so real talk β€” this page is DBLINK_CONNECT_U(3), straight out of the PostgreSQL 15.19 Documentation, and bestie… the "u" does not stand for "uwu". It stands for unsecured and we're gonna talk about it. 🫢


🌸 NAME 🌸

dblink_connect_u β€” opens a persistent connection to a remote database, insecurely. bestie. INSECURELY. that's literally in the name, i'm not being dramatic. 😭


πŸŽ€ SYNOPSIS πŸŽ€

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

two flavors, pick your fighter: one that just takes a connection string, and one that also lets you name the connection. slay. ✨


πŸ’– DESCRIPTION πŸ’–

okay so here's the tea: dblink_connect_u() is identical to dblink_connect(), with exactly one (1) spicy difference β€” it will allow non-superusers to connect using any authentication method. any. all of them. no gatekeeping. πŸ‘‘

and like… that's also kind of the problem, ngl. let's get into it.

if the remote server picks an authentication method that doesn't involve a password, then impersonation and subsequent escalation of privileges can happen β€” because the session will appear to have originated from the user that the local PostgreSQL server runs as. like, the remote server literally thinks it's you. main character energy, but the villain kind. πŸ’€

and pookie, it gets worse: even if the remote server does demand a password, it's possible for that password to be supplied from the server environment β€” think a ~/.pgpass file belonging to the server's user. which opens not only a risk of impersonation, but also the possibility of exposing a password to an untrustworthy remote server. 🫣 not the vibes. not the vibes at all.

so because of all that, dblink_connect_u() ships initially installed with all privileges revoked from PUBLIC, which makes it un-callable except by superusers. yes queen, locked down by default. that's the vibe check passing. πŸ”₯

⚠️ 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. like, think about it. don't just hand it out in the group chat. πŸ™ˆ

also, one more rec before you go: it's recommended that any ~/.pgpass file belonging to the server's user not contain any records specifying a wildcard host name. no wildcards in there, bestie. periodt. πŸŽ€

for further details see dblink_connect(). it's giving "go read the other page, this one's the chaotic sibling". 🌈


πŸ’« tl;dr β€” same as dblink_connect() but with the safety rails politely removed. iconic, dangerous, and you should read the warnings twice. iykyk.

made with love from the PostgreSQL 15.19 docs, dated 2026 β€” mwah, go be safe out there πŸ’œπŸ¦‹

πŸ“¦ where this page comes from