DBLINK_CONNECT_U(3)
π
DBLINK_CONNECT_U(3) β like dblink_connect but make it insecure π«Ά
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
~/.pgpassfile 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 grantEXECUTEpermission fordblink_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
- opensuse-leap 16.0: postgresql14-docs 14.24-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