pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Teach equalRowTypes() to safely handle dropped columns.
Date: Mon, 09 Nov 2026 14:21:55 +0000
Message-ID: <E1xQQFv-000000003WN-2AGD@gemulon.postgresql.org> (raw)

Teach equalRowTypes() to safely handle dropped columns.

equalRowTypes compared the name, type, typmod, and collation of
corresponding attributes.  That's sufficient when neither attribute has
been dropped, since their physical storage attributes (attlen and
attalign) are derived from their type.  But a dropped attribute has its
atttypid set to InvalidOid while keeping the attlen and attalign of the
type that the column used to have.  Two row types that merely had
dropped attributes in the same positions could therefore be considered
equal, even when the dropped attributes' widths or alignments differed.

That was a problem for typcache.c's record type cache, which relies on
equalRowTypes to decide whether a tuple descriptor matches one that was
already assigned a record typmod.  A tuple built using one tuple
descriptor could be assigned the typmod of a physically incompatible
descriptor, allowing it to be deformed using that descriptor.  That
could be abused to make the server disclose memory contents, and to
achieve arbitrary code execution.

To fix, make equalRowTypes also compare the attlen and attalign of
corresponding dropped attributes.

Oversight in commit 20e58105, which introduced equalRowTypes.
equalTupleDescs already compared attlen and attalign, but equalRowTypes
missed that precedent.

Reported-by: Peter Geoghegan <pg@bowt.ie>
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Security: CVE-2026-120142
Backpatch-through: 17

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c9f334488a29e91c43f6879fd7c563ae94ff640b
Author: Peter Geoghegan <pg@bowt.ie>

Modified Files
--------------
src/backend/access/common/tupdesc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)



view thread (3+ messages)  latest in thread

Message-ID: <E1xQQFv-000000003WN-2AGD@gemulon.postgresql.org>
Permalink:  ../E1xQQFv-000000003WN-2AGD@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQFv-000000003WN-2AGD@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: noah@leadboat.com
  Subject: Re: pgsql: Teach equalRowTypes() to safely handle dropped columns.
  In-Reply-To: <E1xQQFv-000000003WN-2AGD@gemulon.postgresql.org>
  References: <E1xQQFv-000000003WN-2AGD@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox