Can users access other users' information?
Last checked 31 Aug 2026
Short answer
Only if your row-level security policies are missing or too permissive — with correct RLS, a query for 'my orders' can only ever return rows owned by the logged-in user, regardless of what the front end sends.
Why this is a database problem, not a UI problem
Hiding another user's data in the interface (e.g. only showing "your" orders in a list) does nothing if the underlying query could still return anyone's rows when called directly. The fix has to sit in row-level security policies at the database level, not in what the app chooses to display.
The pattern that works
A correct RLS policy on a table like orders restricts every read and write to rows where user_id = auth.uid(), regardless of what the client requests. That way, even if someone inspects network requests and tries to change an ID in the request, the database itself refuses to return another user's row.
How to test it yourself
- Create two real test accounts.
- Log in as user A, note an internal ID (e.g. an order ID) from the browser's network tab.
- Log in as user B and try to fetch that same ID directly (e.g. by editing a URL or replaying a request).
- If user B can see or edit user A's data, the RLS policy is missing or wrong.
A prompt that helps
Review the RLS policy on the orders table and confirm it restricts all reads and writes to rows owned by the authenticated user, not just to what the app's queries currently ask for.
What usually goes wrong
Developers filter by user ID in the front-end query (select().eq('user_id', currentUser.id)) and assume that's enough — but that filter is just a convenience, not security, since a modified request could omit it. The RLS policy, not the client-side filter, is what actually enforces the restriction. See /questions/how-do-i-check-supabase-rls to verify yours, and /questions/how-do-i-protect-admin-pages for the equivalent problem with role-gated pages.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I protect API keys?Never put API keys in front-end code — store them as secrets used only inside server functions (Edge Functions), where the browser never sees them.
- AnswerAre Lovable websites secure?Lovable includes built-in security scanning and API-key protection, but real security also depends on you setting up row-level security and role checks correctly — it isn't automatic just because you used Lovable.
- AnswerWhere should secrets be stored?In your project's server-side secrets store, used only inside Edge Functions — never in front-end code, client-side environment variables, or committed to your Git repository.
- AnswerHow do I run a security audit on Lovable?Open your project's Security view in Lovable to see automated scan results, then ask Lovable in chat to review RLS policies, role storage, and any exposed secrets in detail.