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
commit562289460e118fcad44ec916dcdab21e4763c38c (patch)
tree3baee85d1ac570a5e3d86ab3b4aed417c78379c5 /src/backend/executor
parent8fe3e697a1a83a722b107c7cb9c31084e1f4d077 (diff)
downloadpostgresql-562289460e118fcad44ec916dcdab21e4763c38c.tar.gz
postgresql-562289460e118fcad44ec916dcdab21e4763c38c.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 81b0c029e7a..d5b3e48ba67 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -1985,6 +1985,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;
}