Reject system catalogs as logical replication targets. The subscriber relied on the publisher refusing to add a system catalog to a publication, and checked only the relation kind it was about to apply into. However, the relation is named by the publisher, and a publisher that speaks the logical replication protocol doesn't have to be a PostgreSQL server. A malicious one can name a system catalog, and the apply worker will write into it.
The danger is limited to subscriptions owned by a superuser. Changes are applied as the table owner, or as the subscription owner when run_as_owner is set, and a non-superuser can never hold write privileges on a system catalog, so a subscription owned by a non-superuser stops at the privilege check. We can't depend on the publisher for this, so check the target relation on the subscriber too. A relation that the server maintains for its own use, such as a system catalog, must never be written by an apply worker, and neither must a temporary relation. We don't reject unlogged relations the way the publisher does; replicating into one is fine. The check runs when a worker opens the target relation to apply changes, and also when getting the relation list, so that such a relation is never recorded in pg_subscription_rel in the first place. The test attaches a callback of its own to the injection point, which needs a form of injection_points_attach() that v18 and older don't have, so it is applied to v19 and later. Reported-by: qian zhang <[email protected]> Author: Masahiko Sawada <[email protected]> Reviewed-by: Ashutosh Bapat <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Backpatch-through: 14 Security: CVE-2026-120145 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/60c7b4d04d4651c54c0f019ecfa1b45801513900 Author: Masahiko Sawada <[email protected]> Modified Files -------------- src/backend/commands/subscriptioncmds.c | 11 ++++---- src/backend/executor/execReplication.c | 41 ++++++++++++++++++++++++++++-- src/backend/replication/logical/relation.c | 6 ++--- src/backend/replication/logical/worker.c | 12 ++++----- src/include/executor/executor.h | 2 ++ 5 files changed, 55 insertions(+), 17 deletions(-)
