aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-11-11 09:00:00 -0600
committerNathan Bossart <nathan@postgresql.org>2024-11-11 09:00:00 -0600
commit952ff31e2a89e8ca79ecb12d61fddbeac3d89176 (patch)
tree5bc7bb20a64566bf5ee61ff64c7ee0caf794ca33 /src/backend/executor
parente428cd058f0bebb5782b0c263565b0ad088e9650 (diff)
downloadpostgresql-952ff31e2a89e8ca79ecb12d61fddbeac3d89176.tar.gz
postgresql-952ff31e2a89e8ca79ecb12d61fddbeac3d89176.zip
Ensure cached plans are correctly marked as dependent on role.
If a CTE, subquery, sublink, security invoker view, or coercion projection references a table with row-level security policies, 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. Reported-by: Wolfgang Walther Reviewed-by: Noah Misch Security: CVE-2024-10976 Backpatch-through: 12
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/functions.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 982155e740c..b1939611522 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -1991,6 +1991,12 @@ tlist_coercion_finished:
rtr->rtindex = 1;
newquery->jointree = makeFromExpr(list_make1(rtr), NULL);
+ /*
+ * Make sure the new query is marked as having row security if the
+ * original one does.
+ */
+ newquery->hasRowSecurity = parse->hasRowSecurity;
+
/* Replace original query in the correct element of the query list */
lfirst(parse_cell) = newquery;
}