diff options
author | Nathan Bossart <nathan@postgresql.org> | 2024-11-11 09:00:00 -0600 |
---|---|---|
committer | Nathan Bossart <nathan@postgresql.org> | 2024-11-11 09:00:00 -0600 |
commit | edcda9bb4c4500b75bb4a16c7c59834398ca2906 (patch) | |
tree | ea5126092918e6ba3f6935d8a8111a56c82038ac /src/backend/executor/functions.c | |
parent | 3ebcfa54db3309651d8f1d3be6451a8449f6c6ec (diff) | |
download | postgresql-edcda9bb4c4500b75bb4a16c7c59834398ca2906.tar.gz postgresql-edcda9bb4c4500b75bb4a16c7c59834398ca2906.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/functions.c')
-rw-r--r-- | src/backend/executor/functions.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 692854e2b3e..39880663307 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -1972,6 +1972,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; } |