pgsql: Plug RLS related information leak in pg_stats view.

Поиск
Список
Период
Сортировка
От Joe Conway
Тема pgsql: Plug RLS related information leak in pg_stats view.
Дата
Msg-id E1ZKBOE-0005H1-1Q@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Plug RLS related information leak in pg_stats view.

The pg_stats view is supposed to be restricted to only show rows
about tables the user can read. However, it sometimes can leak
information which could not otherwise be seen when row level security
is enabled. Fix that by not showing pg_stats rows to users that would
be subject to RLS on the table the row is related to. This is done
by creating/using the newly introduced SQL visible function,
row_security_active().

Along the way, clean up three call sites of check_enable_rls(). The second
argument of that function should only be specified as other than
InvalidOid when we are checking as a different user than the current one,
as in when querying through a view. These sites were passing GetUserId()
instead of InvalidOid, which can cause the function to return incorrect
results if the current user has the BYPASSRLS privilege and row_security
has been set to OFF.

Additionally fix a bug causing RI Trigger error messages to unintentionally
leak information when RLS is enabled, and other minor cleanup and
improvements. Also add WITH (security_barrier) to the definition of pg_stats.

Bumped CATVERSION due to new SQL functions and pg_stats view definition.

Back-patch to 9.5 where RLS was introduced. Reported by Yaroslav.
Patch by Joe Conway and Dean Rasheed with review and input by
Michael Paquier and Stephen Frost.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/cfa928ff6f944ac101802718f64db942060187b1

Modified Files
--------------
doc/src/sgml/func.sgml                    |   16 +++++++++
src/backend/access/index/genam.c          |    2 +-
src/backend/catalog/system_views.sql      |    6 ++--
src/backend/executor/execMain.c           |    2 +-
src/backend/rewrite/rowsecurity.c         |   16 ++-------
src/backend/utils/adt/ri_triggers.c       |    4 ++-
src/backend/utils/cache/plancache.c       |    7 +---
src/backend/utils/init/miscinit.c         |   14 +++++++-
src/backend/utils/misc/rls.c              |   53 ++++++++++++++++++++++++++++-
src/include/catalog/catversion.h          |    2 +-
src/include/catalog/pg_proc.h             |    6 ++++
src/include/miscadmin.h                   |    1 +
src/include/utils/builtins.h              |    4 +++
src/test/regress/expected/rowsecurity.out |   38 +++++++++++++++++++--
src/test/regress/expected/rules.out       |    2 +-
src/test/regress/sql/rowsecurity.sql      |   17 ++++++++-
16 files changed, 159 insertions(+), 31 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: pgsql: Disable ssl renegotiation by default.
Следующее
От: Joe Conway
Дата:
Сообщение: pgsql: Plug RLS related information leak in pg_stats view.