1
Leakproof enum equality and like/ilike, so RLS queries can use their indexes
Source: supabase/supabase#54373 · opened by @martijn00
Under RLS, Postgres only uses a filter as an index condition (or evaluates it before the policies) when its operator function is LEAKPROOF. Two common filters aren't, and on Supabase the project can't change that, because ALTER FUNCTION ... LEAKPROOF needs a superuser: • Enum equality. enum_eq (and enum_ne, enum_lt, ...) has no proleakproof in src/include/catalog/pg_proc.dat, while texteq does. On an RLS table, where status = 'open' with an index on (organization_id, status) reads every row of the organization and filters after the policies. • like and ilike. textlike and texticlike aren't leakproof, so a pg_trgm index never serves ?name=ilike.*foo* from PostgREST, or a search in a security invoker function, for a user subject to RLS. The same mechanism is behind supabase/storage#1678 (lower(name) in storage.search). Workarounds today • Store status values as text with a check constraint instead of an enum, which loses the type. • M…
No pledges yet. Be the first to back this.
Comments
Similar requests
Better protection against failing to protect tables with RLS
1 vote · 0 comments
Extension to the current "Copy as Markdown" function
1 vote · 0 comments
Redesign of the Queries tab
4 votes · 0 comments
Add Feature to Test + Debug Row Level Security Policies
47 votes · 0 comments
Support Case-Insensitive Array Element Matching in PostgREST API
3 votes · 0 comments
No comments yet.