Cenk Kurtoğlu©26

n8n · Supabase · RLS operations · 6 minute read

n8n + Supabase: what the service_role key bypasses, and how to watch RLS drift

A Supabase credential inside n8n is not one thing. The same connection can run as a role that row level security was designed to ignore, or as an anon JWT whose every request is filtered by your policies. The difference is not a setting in n8n — it is which key you pasted into the credential.

Two roles, two very different answers

service_role is a privileged server-side role. It bypasses RLS by design, which is why it is the right choice for trusted backend jobs that must see every row: sending a nightly report, reconciling accounts, running a migration check. It is also why it must never reach a browser, a client bundle, a public workflow export or a community-shared template. Anyone holding that value reads and writes every table, policy or no policy.

The anon key is the opposite. It identifies an unauthenticated caller, and Supabase evaluates every request against the policies that apply to the anon role. That makes it safe to publish — but only to the extent that those policies are correct. An always-true SELECT policy with RLS switched on still exposes every row; RLS being enabled is not the same as RLS being closed.

The check that settles the argument

You do not need to guess what either key grants. With a read-only role, query pg_policies and the role grants ininformation_schema. Three questions resolve most of the uncertainty:

  1. Is RLS actually enabled and forced? Without FORCE ROW LEVEL SECURITY, the table owner still bypasses policies — and most migration roles are the owner.
  2. Does any permissive SELECT or ALL policy use USING (true), or is it granted to PUBLICrather than a named role?
  3. Do write policies carry an effective WITH CHECK? Without one, an UPDATE can move a row into a state no policy would have allowed at insert time.

Then verify the anon path from outside the database: a plain REST read with the anon key against a table you expect to be closed should return an empty array or a permission error. A populated array is the answer, whatever the policy text claims. Do this on a scratch project first — a live probe against production tells you the same thing but with real data in the response.

Why a one-time check is not enough

n8n workflows are edited by people. A node gets duplicated, a credential gets swapped during a debugging session, a migration adds a hotfix policy at 2 a.m. The catalog changes even when nobody is thinking about security, and the workflow that ran safely last month keeps running. A scheduled comparison against a known baseline turns that from an invisible change into a small diff in your inbox.

The monitor itself should run read-only. It needs only catalog access; if it needs service_role to inspect your schema, something is wrong with the design. It must also fail closed — a broken credential has to stop the job, never write an empty baseline and report that all findings were resolved. A silent reader is not a clean database.

Run it for free

The free RLS Drift Monitor bundles an n8n workflow with ten catalog checks, a fail-closed baseline diff and a standalone SQL file for people who do not want an automation platform in the loop. First run is silent; later runs report only new and resolved findings. It reads no application table data, writes nothing, and works with a read-only role.

Honest limit: this is a catalog diff, not an exploit test. It cannot tell you whether a policy matches what your team meant, and a clean diff is not proof that the database is safe. When you want one concrete question answered with evidence — for instance, whether the anon key still reaches a table it should not — a documents-only spot check is a fixed-scope way to get it. Paid work starts only after payment is secured; the free workflow stays yours with no support commitment.

Related reading: detecting RLS drift with a nightly read-only check, and what an exposed Supabase key actually grants.

Free entry

If you would rather run these checks yourself

Honest limit: a catalog check is not proof of a leak, and an empty log is not proof the key was never used. Zero findings does not mean safe. If you want a human: $29 self-run kit · $95 spot check (five tables, one working day) · $195 full audit — work starts only after payment is secured.

Template bundle

Review all 20 frontend starters in one bundle

20 editable frontend starters with live demos are $79 — one payment, no subscription.

View the Bundle — $79↗