postgresql/src/backend
Dean Rasheed c2e08b04c9 Fix RLS policy usage in MERGE.
If MERGE executes an UPDATE action on a table with row-level security,
the code incorrectly applied the WITH CHECK clauses from the target
table's INSERT policies to new rows, instead of the clauses from the
table's UPDATE policies. In addition, it failed to check new rows
against the target table's SELECT policies, if SELECT permissions were
required (likely to always be the case).

In addition, if MERGE executes a DO NOTHING action for matched rows,
the code incorrectly applied the USING clauses from the target table's
DELETE policies to existing target tuples. These policies were applied
as checks that would throw an error, if they did not pass.

Fix this, so that a MERGE UPDATE action applies the same RLS policies
as a plain UPDATE query with a WHERE clause, and a DO NOTHING action
does not apply any RLS checks (other than adding clauses from SELECT
policies to the join).

Back-patch to v15, where MERGE was introduced.

Dean Rasheed, reviewed by Stephen Frost.

Security: CVE-2023-39418
2023-08-07 09:28:47 +01:00
..
access Document more assumptions of LWLock variable changes with WAL inserts 2023-07-26 12:06:04 +09:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Message wording improvements 2023-07-10 10:47:24 +02:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog Rename OverrideSearchPath to SearchPathMatcher. 2023-07-31 17:04:47 -07:00
commands Remove PushOverrideSearchPath() and PopOverrideSearchPath(). 2023-07-31 17:04:47 -07:00
executor Fix RLS policy usage in MERGE. 2023-08-07 09:28:47 +01:00
foreign Expand some more uses of "deleg" to "delegation" or "delegated". 2023-05-21 10:55:18 -04:00
jit Remove duplicated assignment of LLVMJitHandle->lljit 2023-07-13 16:44:17 +09:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq Eliminate fixed token-length limit in hba.c. 2023-07-27 11:56:35 -04:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Add more SQL/JSON constructor functions 2023-07-26 17:08:33 +09:00
optimizer Fix misleading comment in paraminfo_get_equal_hashops 2023-08-07 18:16:46 +12:00
parser Show savepoint names as constants in pg_stat_statements 2023-07-27 09:42:33 +09:00
partitioning Add missing ObjectIdGetDatum() in syscache lookup calls for Oids 2023-07-20 15:18:25 +09:00
po Translation updates 2023-06-26 12:02:02 +02:00
port Add GUC parameter "huge_pages_status" 2023-07-06 14:42:36 +09:00
postmaster Refactor to split Apply and Tablesync Workers code. 2023-08-03 08:59:50 +05:30
regex All supported systems have locale_t. 2023-07-09 11:55:18 +12:00
replication Simplify some of the logical replication worker-type checks. 2023-08-04 08:15:07 +05:30
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:28:47 +01:00
snowball Fix the install rule for snowball_create.sql. 2023-05-23 11:15:57 -04:00
statistics Take pg_attribute out of VacAttrStats 2023-07-03 07:18:57 +02:00
storage Support custom wait events for wait event type "Extension" 2023-07-31 17:09:24 +09:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Take pg_attribute out of VacAttrStats 2023-07-03 07:18:57 +02:00
utils Fix performance regression in pg_strtointNN_safe functions 2023-08-02 12:05:41 +12:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Generate automatically code and documentation related to wait events 2023-07-05 10:53:11 +09:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00