AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

0006 Multiple Permissive Policies: Fix Comparator And OR/AND Logic In Documentation Examples

The Supabase documentation example for lint 0006_multiple_permissive_policies contains incorrect comparator descriptions and uses OR instead of AND in the consolidated policy, which would lead users to implement overly permissive row-level security. This issue proposes corrections including using <= consistently and changing OR to AND, plus adding a restrictive policies alternative.

mediumConfidence 95%PostgreSQL RLSEdge Functions@supabase/supabase-jsStorage

Origin Analysis

Documentation example for combining permissive RLS policies incorrectly used OR in the consolidated policy, maintaining the permissive OR semantics instead of the intended AND semantics. It also mismatched the textual description of Policy B ("at or above") with the actual comparator <=, and contained typos ("departemnt").
1. Follow the Supabase docs for lint 0006_multiple_permissive_policies. 2. Create the employee_data table with department and grade_level columns. 3. Create the two permissive policies as shown in the original documentation (department_access and grade_level_access). 4. Notice that a user can see rows from other departments if their grade_level is <= the user's grade level, or see higher-grade employees in their own department, because the policies are permissive and combined with OR. 5. Apply the suggested consolidated policy from the original docs using OR. The same broad access remains, demonstrating the bug in the documentation.

Fixing Code Block

-- Drop existing permissive policies drop policy if exists department_access on employee_data; drop policy if exists grade_level_access on employee_data; -- Option 1: Single consolidated policy with correct AND semantics create policy consolidated_access on employee_data for select using ( department = current_user_department() and grade_level <= current_user_grade_level() ); -- Option 2: Multiple restrictive policies (alternative for maintainability) -- Note: Ensure no other permissive policies exist, or understand that permissive policies will still be OR'ed -- drop policy if exists department_access on employee_data; -- drop policy if exists grade_level_access on employee_data; -- create policy department_access on employee_data -- as restrictive -- for select -- using (department = current_user_department()); -- create policy grade_level_access on employee_data -- as restrictive -- for select -- using (grade_level <= current_user_grade_level());
The corrected documentation uses <= consistently to reflect 'at or below' semantics, and changes the consolidated policy from OR to AND so that both conditions must be true, matching the intended access. Additionally, an alternative using RESTRICTIVE policies is provided to maintain multiple policies while enforcing AND semantics.

Edge Case Audit

Applying these policy changes can lock out users if current_user_department() or current_user_grade_level() are not stable or if policies are not carefully audited. Dropping existing policies without a backup can temporarily remove all access. Restrictive policies can interact with other permissive policies on the same table; if any permissive policy exists, rows may still be visible through that permissive path even if restrictive policies fail. Test in a transaction and rollback if unexpected results occur. Rollback suggestion: Save original policy definitions before dropping and recreate them if necessary.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state