]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Use ereport(ERROR), not Assert(), for publisher tuples missing columns.
authorNoah Misch <noah@leadboat.com>
Sun, 17 May 2026 01:01:35 +0000 (18:01 -0700)
committerNoah Misch <noah@leadboat.com>
Sun, 17 May 2026 01:01:39 +0000 (18:01 -0700)
commit59759e1a5b499294d73d409e0bc3343aafd2973f
tree087ce76b931371087193b99e8a029f05da02ebcb
parent2adf78dbe9a2e4a32ceb5383e240c06ef6728776
Use ereport(ERROR), not Assert(), for publisher tuples missing columns.

Three locations use Assert() to guard against a mismatch between the
number of columns advertised in the RELATION message and the number
actually received in the subsequent INSERT/UPDATE tuple message. Since
these values originate from the publisher, the check must survive into
production builds.

A malicious or buggy publisher can send a RELATION claiming N columns
and an INSERT claiming M < N columns. The subscriber's apply worker
indexes into colvalues[]/colstatus[] using column indices from the
RELATION message's attribute map, causing a heap out-of-bounds read when
the tuple's column array is smaller than expected. We've looked, without
success, for a scenario in which the publisher holds sufficient control
over these out-of-bounds bytes to exploit this or even to reach a
SIGSEGV. Despite not finding one, the code has been fragile. Back-patch
to v14 (all supported versions).

Reported-by: Varik Matevosyan <varikmatevosyan@gmail.com>
Author: Varik Matevosyan <varikmatevosyan@gmail.com>
Discussion: https://postgr.es/m/CA+bBoog3cCogktzfLb9bppUByu-10B3CFp8u=iKXG_OvtAguCw@mail.gmail.com
Backpatch-through: 14
src/backend/replication/logical/worker.c