postgresql/src/backend
Dean Rasheed cb2ae5741f 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:24:27 +01:00
..
access Fix indentation in twophase.c 2023-07-18 14:04:48 +09:00
backup In basebackup.c, perform end-of-file test after checksum validation. 2023-03-06 10:20:17 -05:00
bootstrap Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
catalog WAL-log the creation of the init fork of unlogged indexes. 2023-07-06 17:29:12 +03:00
commands Fix updates of indisvalid for partitioned indexes 2023-07-14 10:13:15 +09:00
executor Fix RLS policy usage in MERGE. 2023-08-07 09:24:27 +01:00
foreign Rename SetSingleFuncCall() to InitMaterializedSRF() 2022-10-18 10:22:40 +09:00
jit Fix leak of LLVM "fatal-on-oom" section counter. 2023-07-05 13:13:30 +03:00
lib Fix lock assertions in dshash.c. 2022-07-11 16:01:22 +12:00
libpq Raise fixed token-length limit in hba.c. 2023-07-27 12:07:48 -04:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:32 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:35 +02:00
optimizer Disallow replacing joins with scans in problematic cases. 2023-07-28 15:45:02 +09:00
parser Fix publication syntax error message 2023-05-10 18:26:10 +02:00
partitioning Fix incorrect partition pruning logic for boolean partitioned tables 2023-04-14 16:21:07 +12:00
po Translation updates 2023-05-08 14:29:57 +02:00
port Ensure that the argument of shmdt(2) is declared "void *". 2022-02-15 17:17:28 -05:00
postmaster Handle DROP DATABASE getting interrupted 2023-07-13 13:04:45 -07:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:17 -07:00
replication Fix ReorderBufferCheckMemoryLimit() comment. 2023-08-02 15:01:08 +09:00
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:24:27 +01:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Remove unnecessary code in dependency_is_compatible_expression(). 2023-03-14 11:10:45 -04:00
storage Revert the commits related to allowing page lock to conflict among parallel group members. 2023-07-06 08:28:27 +05:30
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Check for interrupts and stack overflow in TParserGet(). 2023-06-24 17:18:08 -04:00
utils Fix overly strict Assert in jsonpath code 2023-08-02 01:40:56 +12:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Move basebackup code to new directory src/backend/backup 2022-08-10 14:03:09 -04:00
nls.mk Translation updates 2022-11-07 14:04:05 +01:00