1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

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
This commit is contained in:
Nathan Bossart
2024-11-11 09:00:00 -06:00
parent b7e3a52a87
commit cd7ab57532
5 changed files with 226 additions and 6 deletions

View File

@ -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;
}