pgsql: Return nulls honestly in aggregate "combine" functions. - Mailing list pgsql-committers

From Noah Misch
Subject pgsql: Return nulls honestly in aggregate "combine" functions.
Date
Msg-id E1wtQFr-00000000yCV-1XCn@gemulon.postgresql.org
Whole thread
Responses pgsql: Fix thinko in error of algorithm type lookup for channel binding
List pgsql-committers
Return nulls honestly in aggregate "combine" functions.

numeric_combine() and several other state-combining functions for
aggregates cheated for the case of both inputs being NULL: they
returned a null pointer without bothering to mark it as a SQL NULL.
This was harmless in the expected usage where the result would be
passed to the same combine function or a related aggregate final
function.  But it's bad news from a security standpoint, because
now that value can be passed to an internal-accepting function
even if said function is strict.  While a previous patch prevented
such queries from being issued, it seems like good defense-in-depth
to expend the few additional lines of code needed to do this properly.
Comparable functions such as array_agg_combine() already do so.

Reported-by: Amy Burnett (OpenAI Codex Security)
Author: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-14680

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/83d0a083f178f22c60814b93d17ecacdcce76eac
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
src/backend/utils/adt/numeric.c   | 32 ++++++++++++++++++++++++++++++++
src/backend/utils/adt/timestamp.c |  8 ++++++++
2 files changed, 40 insertions(+)


pgsql-committers by date:

Previous
From: Noah Misch
Date:
Subject: pgsql: Fix out-of-bound reads with ascii() for invalid multibyte charac
Next
From: Noah Misch
Date:
Subject: pgsql: Check for USAGE privilege on the composite type in ALTER TABLE O