Restrict postgres_fdw/dblink passfile to user mappings

From: Stepan Neretin <slpmcf(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Restrict postgres_fdw/dblink passfile to user mappings
Date: 2026-11-28 19:43:23
Message-ID: CA+Yyo5QXT-8A1ebgbdijGJcZVeo=9O7ioZ_w62xTrNNJj1XAHg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

password is a USER MAPPING option because libpq marks it with
dispchar '*'. passfile is not marked that way, so postgres_fdw and
dblink treat it as a FOREIGN SERVER option instead.

That puts the password file path into srvoptions, which are broadly
readable. Attached makes passfile user mapping only and
superuser only, and rejects a leftover server side passfile at
connect time. Same idea as keeping secrets out of srvoptions,
in the spirit of the servicefile revert, just for placement.

I left passfile in the libpqsrv proxy allowlist on purpose. That
safelist still blesses it (like sslcert), and Sehrope noted passfile
does not have the /dev/zero hang that servicefile did [1].
Docs deferred.

Regards,
Stepan Neretin

[1]
https://postgr.es/m/CAH7T-aq+U6GDPO8mr3Gga3KzxGpAE=BSLb38x+R8fvWjzF-H8w@mail.gmail.com

Attachment Content-Type Size
v1-0001-Make-postgres_fdw-dblink-passfile-a-user-mapping-option.patch text/x-patch 15.1 KB

Browse pgsql-hackers by date

  From Date Subject
Previous Message Stepan Neretin 2026-11-28 19:23:54 Re: [PATCH 0/2] Parallelizing the archiver