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 <[email protected]> Author: Peter Geoghegan <[email protected]> Reviewed-by: Robert Haas <[email protected]> Reviewed-by: Andrew Dunstan <[email protected]> Security: CVE-2026-120142 Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/c2439a04353ccab618006f21df8698aa9cc31167 Author: Peter Geoghegan <[email protected]> Modified Files -------------- src/backend/access/common/tupdesc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
