DBLINK_CONNECT_U(3)

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

okay so bestie, welcome to the dblink_connect_u page πŸ’… this is the PostgreSQL 17.11 documentation, and yes we are getting into the spicy corner of the dblink family. pull up a chair πŸŽ€


✨ NAME ✨

dblink_connect_u β€” opens a persistent connection to a remote database, insecurely 😭 (yes, that's the actual word. it's giving "we know, we know")


✨ SYNOPSIS ✨

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

✨ DESCRIPTION ✨

So dblink_connect_u() is literally identical to dblink_connect() β€” same energy, same vibes β€” except that it will allow non-superusers to connect using any authentication method. like, any. all of them. no filtering πŸ’€

Now here's the part where we need to talk πŸ™ˆ

If the remote server selects 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. so the remote side thinks it's talking to your server's OS user. that's not a cute look πŸ‘‘

Also β€” and this is the sneaky bit β€” even if the remote server does demand a password, it is possible for the password to be supplied from the server environment, such as a ~/.pgpass file belonging to the server's user. 😭 so the credential is just... sitting there, ready to be used.

This opens not only a risk of impersonation, but the possibility of exposing a password to an untrustworthy remote server. both at once. a combo deal nobody ordered πŸ“

🚨 Because of all that, dblink_connect_u() is initially installed with all privileges revoked from PUBLIC, making it un-callable except by superusers. it ships locked down, fr fr. this is not a drill, this is the default πŸ”₯

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, read that twice. think about it. then think about it again 🧚

It is also recommended that any ~/.pgpass file belonging to the server's user not contain any records specifying a wildcard host name. so no * host entries in there, bestie. none. periodt πŸ’…

For further details see dblink_connect(). πŸ‘ˆ that's your homework


🌸 SEE ALSO 🌸

dblink_connect() β€” the safe-ish sibling, per the "For further details see dblink_connect()" note above 🫢


that's the whole page, no cap ✨ this was PostgreSQL 17.11 documentation, dated 2026, page DBLINK_CONNECT_U(3) β€” stay safe out there and don't hand out EXECUTE like it's candy, ily πŸ’œπŸ¦‹

πŸ“¦ where this page comes from