postgresql/src/backend
Tom Lane bbf5bcf587 Require superuser to install a non-built-in selectivity estimator.
Selectivity estimators come in two flavors: those that make specific
assumptions about the data types they are working with, and those
that don't.  Most of the built-in estimators are of the latter kind
and are meant to be safely attachable to any operator.  If the
operator does not behave as the estimator expects, you might get a
poor estimate, but it won't crash.

However, estimators that do make datatype assumptions can malfunction
if they are attached to the wrong operator, since then the data they
get from pg_statistic may not be of the type they expect.  This can
rise to the level of a security problem, even permitting arbitrary
code execution by a user who has the ability to create SQL objects.

To close this hole, establish a rule that built-in estimators are
required to protect themselves against being called on the wrong type
of data.  It does not seem practical however to expect estimators in
extensions to reach a similar level of security, at least not in the
near term.  Therefore, also establish a rule that superuser privilege
is required to attach a non-built-in estimator to an operator.
We expect that this restriction will have little negative impact on
extensions, since estimators generally have to be written in C and
thus superuser privilege is required to create them in the first
place.

This commit changes the privilege checks in CREATE/ALTER OPERATOR
to enforce the rule about superuser privilege, and fixes a couple
of built-in estimators that were making datatype assumptions without
sufficiently checking that they're valid.

Reported-by: Daniel Firer as part of zeroday.cloud
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-2004
Backpatch-through: 14
2026-02-09 10:07:31 -05:00
..
access Guard against unexpected dimensions of oidvector/int2vector. 2026-02-09 09:57:44 -05:00
archive Fix memory leaks in error reporting with LOG level 2024-05-14 10:41:32 +02:00
backup Fix incorrect errno in OpenWalSummaryFile() 2026-02-03 11:25:16 +09:00
bootstrap Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
catalog Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:42:47 +13:00
commands Require superuser to install a non-built-in selectivity estimator. 2026-02-09 10:07:31 -05:00
executor Fix bogus ctid requirement for dummy-root partitioned targets 2026-01-23 10:23:22 +09:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:30 -07:00
jit jit: Add missing inline pass for LLVM >= 17. 2026-01-22 16:10:28 +13:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Fix build breakage on Solaris-alikes with late-model GCC. 2025-07-23 15:44:29 -04:00
main Avoid possible crash within libsanitizer. 2025-11-05 11:09:30 -05:00
nodes Fix internal error from CollateExpr in SQL/JSON DEFAULT expressions 2025-10-09 01:07:36 -04:00
optimizer Fix possible issue of a WindowFunc being in the wrong WindowClause 2026-01-26 23:47:07 +13:00
parser Fix possible incorrect column reference in ERROR message 2026-01-09 11:03:24 +13:00
partitioning Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands 2024-08-24 19:18:24 +03:00
po Translation updates 2026-02-08 15:10:56 +01:00
port Don't treat EINVAL from semget() as a hard failure. 2025-08-13 11:59:47 -04:00
postmaster Fix snapshot handling bug in recent BRIN fix 2025-11-04 20:31:43 +01:00
regex Avoid assertion due to disconnected NFA sub-graphs in regex parsing. 2024-11-15 18:23:38 -05:00
replication Prevent invalidation of newly synced replication slots. 2026-01-27 05:49:23 +00:00
rewrite Avoid rewriting data-modifying CTEs more than once. 2025-11-29 12:32:12 +00:00
snowball Avoid null pointer dereference crash after OOM in Snowball stemmers. 2025-02-18 21:23:59 -05:00
statistics Fix security checks in selectivity estimation functions. 2025-08-11 09:09:12 +01:00
storage Add file_extend_method=posix_fallocate,write_zeros. 2026-02-06 17:41:42 +13:00
tcop Check for CREATE privilege on the schema in CREATE STATISTICS. 2025-11-10 09:00:00 -06:00
tsearch Require superuser to install a non-built-in selectivity estimator. 2026-02-09 10:07:31 -05:00
utils Require superuser to install a non-built-in selectivity estimator. 2026-02-09 10:07:31 -05:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:03:02 +09:00
meson.build meson: Fix import library name in Windows 2024-06-20 09:08:36 +02:00
nls.mk Add missing gettext triggers 2024-05-14 12:57:22 +02:00