pgsql: Protect against miscalculation of tuple sizes via int32 overflow

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Protect against miscalculation of tuple sizes via int32 overflow
Date: 2026-11-09 14:21:55
Message-ID: E1xQQFv-000000003Wn-2pMj@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Protect against miscalculation of tuple sizes via int32 overflow

In-memory tuple sizes were being calculated in 64-bit-sized variables
and later assigned to 32-bit variables, potentially leading to integer
wraparound, which could then be used to overwrite server memory with
attacker-controlled contents. Repair by using overflow-aware addition
and, for additions done in loops, checking that the result complies with
the 1GB palloc limit at each step.

Reported-by: Hillai Ben Sasson <hillai(dot)bensasson(at)wiz(dot)io>
Reported-by: Jayden Sarveshkumar <jayden(at)verialabs(dot)com>
Reported-by: Mehmet Ince <mehmet(at)mehmetince(dot)net>
Author: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reviewed-by: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Security: CVE-2026-120139
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/01cdd163c86ffe6f4426973e8ecdc6389312731c
Author: Álvaro Herrera <alvherre(at)kurilemu(dot)de>

Modified Files
--------------
src/backend/access/common/heaptuple.c | 59 +++++++++++++++++++++++++++++----
src/backend/access/heap/heaptoast.c | 20 ++++++-----
src/backend/executor/execTuples.c | 5 +++
src/backend/utils/adt/array_userfuncs.c | 3 +-
src/backend/utils/adt/multirangetypes.c | 7 ++++
src/include/access/htup_details.h | 4 +++
src/include/access/tupmacs.h | 30 +++++++++++++++++
7 files changed, 112 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-11-09 14:21:56 pgsql: Add tests for row type changes causing issues
Previous Message Noah Misch 2026-11-09 14:21:54 pgsql: Check for Consts in domain DEFAULTs