Security definer views should be allowed in certain conditions
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先在 PostgreSQL 中复现 SQL 草图,并检查 linter 当前如何标记 security definer views。将提议的 security_barrier 和 SELECT-only grant conditions 与现有行为进行比较;完成的标准是 qualifying views 会被允许,或降级为可忽略的警告,同时不允许不安全的变更操作。
由索引模型根据 Issue 内容生成。
描述
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
"security definer" views are flagged as an error.
There are cases where RLS is not the right tool for the job, such as where the per-row checks are very expensive, or where certain columns should not be shown to the user. Postgres has two features I can think of that are helpful here:
- A view with security_invoker=true that calls a security definer function
- A view wth secuity_invoker=false, secuirty_barrier=true
This is touched on in #98, but the discussion focussed on dismissing the error.
I believe the correct behaviour is to allow security definer views if the following conditions are met:
- security_barrier=true – this prevents predicate injection
- grant is limited to select operation only – this prevents mutating the base table if the view is a simple view
Given the intention is to take away footguns from the user base, a warning that could be dismissed also seems fine.
Sketch
To verify the behaviour:
create schema app;
create table app.test (
id uuid primary key default gen_random_uuid(),
slug text unique
);
-- optionally
-- alter table app.test enable row level security;
create view app.test_v as select * from app.test;
create role app_user;
grant app_user to postgres;
revoke all privileges on app.test from app_user;
revoke all privileges on app.test_v from app_user;
-- if RLS is enabled
-- grant select on app.test
grant select on app.test_v to app_user;
grant usage on schema app to app_user;
-- security vulnerability (simple views only)
-- grant insert, update, delete on app.text_v to app.user;
set role app_user;
select * from app.test; -- ERROR: permission denied for table test
select * from app.test_v; -- rows
insert into app.test_v (slug) values ('hello'); -- ERROR: permission denied for view test_v
reset role;
- 主要语言
- PLpgSQL
- 星标
- 284
- 派生
- 110
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
supabase/splinter 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 69/100
supabase/splinter#206 · 1 个 reaction ·
维护者通常 1 天内回复
-
0002_auth_users_exposed false positive: pg_depend join lacks a refclassid filter (cross-catalog OID collision)可能已有人在做 @tushardev-365 于 97 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 40/100
supabase/splinter#210 · 1 个 reaction ·
维护者通常 1 天内回复
-
0030_autovacuum_disabled misses tables where autovacuum_enabled is set to off, 0 or no可能已有人在做 @RaphaelFakhri 于 10 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 1 天内回复
-
Proposal: lint for RLS policies whose role lacks the table privilege (policy_without_privilege)可能已有人在做 @larik15 于 29 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 1/100
维护者通常 1 天内回复
查看 supabase/splinter 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
langchain-ai/langchain-redis#222 ·
维护者通常 2 天内回复
-
`BLMPOP` with COUNT 0 or numkeys 0 hangs可能已有人在做 @ggyuchive 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
needs triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
good first issue help wanted new check
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Area - Azure Provisioning Area - Local to Cloud Bug
难度 2/5 1-3 小时 新手友好度 62/100
microsoft/vscode-mssql#23205 ·
维护者通常 1 天内回复