Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server
Date: 2026-07-29 11:17:42
Message-ID: CANhcyEUJ05x32wdBVsEPM-KMfexxnVsbMLeTtzUO5ES1mksufg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 29 Jul 2026 at 08:16, Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Dear Shlok,
>
> > While testing another patch, I found a bug related to subscriptions
> > created using a foreign server.
>
> Good catch.
>
> > This happens because AlterSubscription() calls:
> > GetSubscription(subid, false, orig_conninfo_needed, false)
> > with conninfo_aclcheck set to false, so the ACL check on the
> > associated foreign server is skipped.
>
> Agree. There is an ongoing discussion to weaken the validation at DDL phase [1],
> but IIUC it does not match with this issue. REFRESH PUBLICATION command needs to
> refer the conninfo to connect to the publisher, so validation is mandatory.
>
I also noticed that the thread [1] does not address this issue.

> > The attached patch fixes this by enabling conninfo_aclcheck for
> > these ALTER SUBSCRIPTION operations, ensuring that permissions on
> > the foreign server are validated before connecting to the publisher.
> > Thoughts?
>
> I think for ADD/DROP/SET PUBLICATION commands, ACL check is not needed non-refresh
> case. For these cases, backends won't directly connect to the publisher server:
> apply worker will check privileges and raise the ERROR. Can you set
> orig_conninfo_aclchk to true only for REFRESH case?
>
> [1]: https://www.postgresql.org/message-id/e96efe16fb47fcca4ae0cd0157fb6bc662470712.camel%40j-davis.com

Thanks for reviewing the patch. I have updated the patch and attached
the v2 patch.

Thanks,
Shlok Kyal

Attachment Content-Type Size
v2-0001-Check-foreign-server-permissions-for-ALTER-SUBSCR.patch application/octet-stream 5.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-07-29 11:21:34 Re: [PATCH v1] Fix pg_basebackup long-path test on Windows
Previous Message Daniel Gustafsson 2026-07-29 10:50:23 Re: [PATCH] Rename "getdatabaseencoding()" to "pg_database_encoding()", and document