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

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Shlok Kyal' <shlok(dot)kyal(dot)oss(at)gmail(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 02:46:56
Message-ID: OS9PR01MB12149CD09F8A706A8DCC3F478F5CA2@OS9PR01MB12149.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

> 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

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2026-07-29 03:05:41 RE: sequencesync worker race with REFRESH SEQUENCES
Previous Message Hayato Kuroda (Fujitsu) 2026-07-29 02:35:36 RE: CREATE SUBSCRIPTION ... SERVER vs. pg_dump, etc.