aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-05-08 10:12:44 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-05-08 10:12:44 -0400
commitca73753b090c33bc69ce299b4d7fff891a77b8ad (patch)
tree802e903b453a2022d73a88b8c3753532c5e615af /src/backend
parent681d9e4621aac0a9c71364b6f54f00f6d8c4337f (diff)
downloadpostgresql-ca73753b090c33bc69ce299b4d7fff891a77b8ad.tar.gz
postgresql-ca73753b090c33bc69ce299b4d7fff891a77b8ad.zip
Handle RLS dependencies in inlined set-returning functions properly.
If an SRF in the FROM clause references a table having row-level security policies, and we inline that SRF into the calling query, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to later executions in the same session returning or hiding rows that should have been hidden or returned instead. Our thanks to Wolfgang Walther for reporting this problem. Stephen Frost and Tom Lane Security: CVE-2023-2455
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/optimizer/util/clauses.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index a9c7bc342ec..11269fee3ed 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -5205,6 +5205,13 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
*/
record_plan_function_dependency(root, func_oid);
+ /*
+ * We must also notice if the inserted query adds a dependency on the
+ * calling role due to RLS quals.
+ */
+ if (querytree->hasRowSecurity)
+ root->glob->dependsOnRole = true;
+
return querytree;
/* Here if func is not inlinable: release temp memory and return NULL */