DBLINK_CONNECT_U(3)
π DBLINK_CONNECT_U(3) π
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 fromPUBLIC, 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
- opensuse-leap 16.0: postgresql17-docs 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms