pgsql: Check EXECUTE privilege on type-to-json cast functions.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check EXECUTE privilege on type-to-json cast functions.
Date: 2026-11-09 14:21:53
Message-ID: E1xQQFt-000000003SA-2hv4@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check EXECUTE privilege on type-to-json cast functions.

When converting a value to json or jsonb, to_json() and its many
friends execute the cast function without first checking for
EXECUTE privileges. To fix, check privileges and invoke the
object access hook before calling the cast function. This
covers to_json(), to_jsonb(), row_to_json(), array_to_json(), the
json[b]_build_*() and *_agg() functions, the SQL/JSON constructors
(v16 and later), and COPY TO with FORMAT json (v19 and later).

Reported-by: Filip Janus <fjanus(at)redhat(dot)com>
Reported-by: Anthropic OSS program
Author: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Co-authored-by: Anthropic OSS program
Reviewed-by: Andrew Dunstan <andrew(at)dunslane(dot)net>
Security: CVE-2026-116303
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/af852c3a30a871930c1d029216b9dcbd6ad52ac8
Author: Nathan Bossart <nathan(at)postgresql(dot)org>

Modified Files
--------------
src/backend/utils/adt/json.c | 9 +++++++++
src/backend/utils/adt/jsonb.c | 9 +++++++++
src/test/regress/expected/privileges.out | 21 +++++++++++++++++++++
src/test/regress/sql/privileges.sql | 15 +++++++++++++++
4 files changed, 54 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-11-09 14:21:54 pgsql: Fix use-after-free in pg_show_all_settings().
Previous Message Noah Misch 2026-11-09 14:21:52 pgsql: Avoid use-after-free hazards in re-entrant use of pltcl.