Skip to content

Security Advisor: Security Definer View false positive #98

@markledwich2

Description

@markledwich2

To make RLS perform acceptably, I often make views with security definer and then filter the data with filters that use auth.uid() or auth.jwt() , or joins to other views that do. This performs drastically better than raw queries against RLS tables for us ( I am assuming because it will filter with optimizations as part of the whole query rather than a row-by-row if it is RLS).

For example, the following query is detected as a security error

create view profile_my with (security_barrier = true, security_invoker=off) as (
  select p.* from profile p
  where p.user_id = (select auth.uid()) and not p.deleted
);

Supabase treats errors as very serious in its communication via the weekly email, and there is no way to ignore them individually. So it makes these false positives frustrating to see permanently against the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions