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

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(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>
Subject: Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server
Date: 2026-07-28 13:03:08
Message-ID: CANhcyEU9VsaLwo908ws_1MxNB79f+cr-JVfig=Zoaf4+KQe+GQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While testing another patch, I found a bug related to subscriptions
created using a foreign server.

Suppose a subscription is created using a foreign server, and the
subscription owner does not have permission to access that server. If
the owner executes ALTER SUBSCRIPTION ... REFRESH PUBLICATION, ADD
PUBLICATION, DROP PUBLICATION, or SET PUBLICATION, the command
can still connect to the publisher and fetch the updated relation
list.

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.

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 am posting the patch in this thread since the related changes were made here.

Thanks,
Shlok Kyal

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tender Wang 2026-07-28 13:03:51 Re: remove_useless_joins vs. bug #19560
Previous Message Rafia Sabih 2026-07-28 13:01:27 Re: [PATCH] Add tests for src/backend/nodes/extensible.c