Building apps
What is row-level security (RLS)?
Row-level security (RLS) is a database feature that enforces access rules on individual rows, so a query returns only the records the requesting user is permitted to see, regardless of what the application asked for.
New to Bolt? Sign up free.
Technical definition
Row-level security applies access policies at the row level inside the database. A policy is a condition evaluated against the current user's identity for every read or write, and the database silently excludes rows that fail it.
Because enforcement lives in the database rather than in application code, RLS holds no matter how the query arrives. A request that omits a filter, a bug in the application, or a crafted request from a user all produce the same result: only permitted rows.
In plain terms
Row-level security means the database itself refuses to hand over records that do not belong to the person asking.
Without it, security depends on your application remembering to ask correctly every single time. With it, forgetting is harmless.
Why it matters
This is the concept that decides whether an AI-built app leaks its customers' data, and it deserves the emphasis.
The failure mode is specific. Your app shows each customer their own orders, because the code asks for orders belonging to the logged-in user. That works until one request somewhere omits the filter, or until a user changes an ID in a request and asks directly. With no rule in the database, the data comes back.
With row-level security, the same request returns nothing. The rule is evaluated on every query, so a mistake in application code fails closed rather than open.
The reason this matters more with AI building: the AI writes queries across dozens of files, and it takes one place where the filter was omitted. Enforcing at the data layer removes the need for perfection everywhere else.
The test to run before you launch: log in as an ordinary user, try to fetch a record belonging to someone else, and confirm you get nothing.
