pocin
04/13/2022, 9:09 AMNeedle
04/13/2022, 9:09 AM/title
command!
We have solved your problem?
Click the button below to archive it.pocin
04/13/2022, 9:09 AMcreate table public.protecc as (select 1 val);
create view public.protecc_view as (select * from public.protecc);
alter table public.protecc enable row level security;
and the following code
import {createClient} from '@supabase/supabase-js'
const SUPABASE_URL = `ADD HERE`
const ANON_KEY = `ADD HERE`
async function main(){
{
const { data, error } = await client.from('protecc').select('*')
console.dir(data, error)
}
{
const {data, error} = await client.from('protecc_view').delete().match({val: 1})
console.dir(data, error)
}
}
main().catch(console.log)
any (even anon user (no access token)) can delete from the table (via the view). This means that any public view is by default vulnerable to data corruption/unauthorized access.
This at least warrants a big warning in the docs imho, if not an automated check in the UI for views who are owned by user bypassing RLS.
I understand this is because view owner is the supabase_admin (who created the view) and it can bypass RLS and I have read
https://github.com/supabase/supabase/discussions/1501
https://github.com/supabase/supabase/discussions/2148pocin
04/13/2022, 9:11 AMalter view public.protecc_view owner to anon
the anon
role has ALL grants on all tables by default. This is safe because all tables should have RLS. Correct?silentworks
04/13/2022, 11:39 AMNeedle
04/13/2022, 11:39 AMpocin
04/13/2022, 12:43 PMNeedle
04/13/2022, 12:43 PM