vacuumdb: Fully qualify the catalog query's operators.

vacuumdb runs its catalog query with the session's default
search_path so that --table arguments resolve as they would in
psql, but commit edba754f05 added two constructs whose = is not
schema-qualified: the relkind IN list in the LATERAL and the IS
DISTINCT FROM tests on attstattarget and stxstattarget.  This
allows a database owner to shadow the operator with their own and
execute arbitrary code as the user running vacuumdb.  To fix,
rewrite the former as OPERATOR(pg_catalog.=) ANY (array[...]) like
the relkind filter in the WHERE clause, and the latter as an IS
NULL test with OPERATOR(pg_catalog.<>).

Reported-by: Noah Misch <[email protected]>
Reported-by: Anthropic OSS program
Author: Nathan Bossart <[email protected]>
Co-authored-by: Anthropic OSS program
Reviewed-by: Bertrand Drouvot <[email protected]>
Security: CVE-2026-116313
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1ce3bce608dc504ca8849d42abcccc7820b88e48
Author: Nathan Bossart <[email protected]>

Modified Files
--------------
src/bin/scripts/vacuuming.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

Reply via email to