Skip to content

Tighten permissive RLS policies (USING/WITH CHECK true) #174

Closed

Description

@thinkclay

Summary

Several tables have RLS policies that use USING (true) or WITH CHECK (true) for INSERT/UPDATE/DELETE/ALL. Such policies allow any authenticated (or unauthenticated) user to perform those operations, effectively bypassing row-level security for those commands.

Affected objects

  • core.addresses — policies addresses_insert, addresses_update
  • core.inquiry_audit_log — policy inquiry_audit_insert_only
  • core.review_category_ratings — policy review_category_ratings_write
  • core.review_soft_skill_votes — policy review_soft_skill_votes_write
  • core.sites — policies sites_insert, sites_update
  • engagement.activity_events — policy activity_events_insert_authenticated
  • engagement.profile_views — policy profile_views_insert_authenticated
  • forsured.audit_log — policy Allow authenticated users to insert audit logs
  • public.privacy_requests — policy Users can create privacy requests

Remediation

  1. For each policy, replace true with a condition that restricts rows (e.g. auth.uid() = user_id, org membership, or role check).
  2. Ensure WITH CHECK and USING both reflect the intended access.
  3. See Permissive RLS Policy.

References

Activity

  1. thinkclay commented on Mar 10, 2026

    @thinkclay
    ContributorAuthor

    Done.

    • Added migration 406_tighten_permissive_rls_policies.sql:
      • core.addresses: INSERT requires org membership; UPDATE only if address is linked to a project the user can edit (via project_addresses + projects).
      • core.sites: Same pattern (org membership for INSERT; project_sites + project edit for UPDATE).
      • core.inquiry_audit_log: INSERT WITH CHECK (actor_id = auth.uid()).
      • core.review_category_ratings / core.review_soft_skill_votes: ALL restricted to review author (EXISTS review where author_user_id = auth.uid()).
      • engagement.activity_events: INSERT WITH CHECK (user_id = auth.uid()).
      • engagement.profile_views: INSERT WITH CHECK (viewer_user_id = auth.uid() OR viewer_user_id IS NULL).
      • public.privacy_requests: INSERT WITH CHECK (user_id = auth.uid() OR requester_email = current user email).
    • forsured.audit_log skipped (schema dropped in 400).
    • Applied locally; closing as completed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions