Rolelock
Can your users raise their own role?
npx rolelock@0.1.1 ./my-app$ npx rolelock@0.1.1 demo/clinic-booking
rolelock 0.1.1 · FINDINGS: 2 findings to review; none block yet 1. Any signed-in user can raise their own role [medium, possible] supabase/migrations/20250110090000_profiles.sql:19 Fix prompt for your coding agent: … 2. Anyone with your public key can act on any user's data through refund-order [medium, possible] supabase/functions/refund-order/index.ts:17 Fix prompt for your coding agent: … 2 places that could have a hole (review list)Read on this computer; nothing was sent anywhere.Rolelock reads the supabase/ folder of your app on your computer and looks for two holes. It never runs your code, and it sends nothing anywhere. Every finding comes with a fix prompt for your coding agent.
What it finds
Check B
A signed-in user can raise their own role
Or their admin flag, plan, credits or approval. A column like
The pattern, an example and the fixroleorplansits in a table users may update on their own row, and a policy or function trusts it. Rolelock follows six ways a user can write that column: a direct update or insert, sign‑up data copied by a trigger, an owner‑rights function, an owner‑rights view, deleting the row and inserting it again, and an edge function that writes a request value into it.Check C
An edge function trusts an id from the request
The function uses the secret key, which skips every database rule, and acts on an id taken from the request without tying it to the caller. Anyone who can call the function can then read or change other users' rows. Rolelock checks each request value that reaches the database for a tie to the caller.
The pattern, an example and the fix
Verdicts and exit codes
CLEAR
exit 0
no findings, every file was read, and nothing privileged to check
NOTHING FOUND
exit 0
no findings, every file was read; the places that could have a hole are listed for review
FINDINGS
exit 0
findings to review; none block
BLOCKED
exit 1
a likely finding at or above
--fail-on(default high)NOT CHECKED
exit 2
part of the project couldn't be read, so nothing is cleared
usage error
exit 3
unknown flag or bad value
Rolelock is a finder, not a certifier. Neither quiet verdict says your app has no hole. CLEAR means nothing privileged to check: no edge function uses the secret key, and no privileged column is written by SQL or protected only by a guard. NOTHING FOUND means Rolelock found no hole in the places that could have one, and lists them for you to review.
BLOCKED wins over NOT CHECKED: a known blocking hole is reported even when part of the read failed. NOT CHECKED wins over FINDINGS, NOTHING FOUND and CLEAR. A CLEAR never rests on a guard: a privileged column that only a pin, revoke or missing write policy protects is a place to review, so the verdict is NOTHING FOUND. NOTHING FOUND and FINDINGS list the guards, revokes and pins they depend on, and ask you to confirm those migrations are applied (supabase migration list).
The review list
NOTHING FOUND comes with a review list: every place that could have a hole (a privileged‑column write, a call or trigger that leads to one, a privileged column users may reach that only a guard protects, a call on the secret‑key client, the key handed on), with its file, line and what Rolelock found there: for example, the guard that cleared it, or a value it read but couldn't prove, with a hint such as passing the caller's id. We found no hole there; we can't prove there is none. Go through each place, and confirm the guards it names are applied.
When it says NOT CHECKED
Rolelock says NOT CHECKED, instead of guessing, when part of the project couldn't be read:
- a
DOblock orEXECUTEwhose effect it can't read (a loop that grants, creates policies or drops guards); - a migration statement or file it can't parse, or a database function body it can't read (including other languages);
- invisible bidirectional text, or a name that mixes Latin with look‑alike letters;
- an edge function that touches the secret key but goes past a reading limit (an import outside
supabase/, a remote helper, a budget or depth cut); - migrations whose order can't be known, or a table the files never create;
- a file over the size caps, a symlink, or no
supabase/folder at all; - a check that isn't built yet.
A place Rolelock read but couldn't prove (a value it can't follow at a privileged write or a secret‑key call) goes on the NOTHING FOUND review list, not on NOT CHECKED.
No check blocks yet. Every finding starts as "possible" until that kind of finding has been measured on examples we held back, so today a scan with findings ends FINDINGS, not BLOCKED. Read each finding before you act on it.
Run it
Run it from outside your project, pointing at the folder that holds supabase/:
npx rolelock@0.1.1 ./my-appOn Windows, the same in PowerShell:
npx rolelock@0.1.1 C:\path\to\my-appAlways type the exact version, rolelock@0.1.1. Never run a bare npx rolelock. Run it from outside the project, because a copy installed inside the folder it scans could have been changed by that project.
It runs on Mac, Windows and Linux, with Node 22.18 or a later 22.x, or Node 24.11 or later. No account, no sign‑up, no Docker.
--json: the full result, with the fix prompts and what was read.--sarif: SARIF 2.1.0 for GitHub code scanning.--fail-on low|medium|high|critical: the severity that blocks (default high).--no-default-grants: don't assume Supabase's old default table grants. This never makes a result CLEAR.
What it never does
- It never runs your code.
- It never connects to your database or your live app.
- It sends nothing anywhere: no telemetry, no network calls. Findings go where you send them.
- It reads files on your computer: the
supabase/folder (migrations, database functions, edge functions and config), the deploy files next to it (such aspackage.json,Makefile,deno.jsonand.github/workflows/) for deploy flags, and.launch-blockers-ignore.
What no file scan can see
Read this before you trust a CLEAR or a NOTHING FOUND. Rolelock can't see:
- changes made in the Supabase dashboard, which schemas are exposed, or whether sign‑up is on;
- your client code, or code outside
supabase/; - whether your migrations are applied (check with
supabase migration list); - your project's real table grants: it assumes Supabase's old default grants unless a migration revokes them (see
--no-default-grants); - cross‑user reads: Check A isn't in this version;
- other platforms: it reads Supabase projects only.
For tables left open on your live app, run Greenlit on your own app.
Known limits
Rolelock reads code a generated app plausibly writes. It does not hunt deliberate evasion:
- a secret key built at run time where no text test can see it: from character codes, base64 or a remote config, and sent to a URL built the same way;
- a service key kept under an innocent name;
- a decision on a column name held in a constant (
p[col]), or on a row turned into a string and searched; - NULL let through under a negation in a guard (
not exists (... and col = 'v'),case ... else true,is not false); - a network call reached through a name built at run time or
eval.
The full list of residual risks is in docs/SECURITY-REVIEW.md.
Fix prompts
Every finding comes with a prompt written for your coding agent. Prompts always ask for a new migration, never an edit to one that may already be applied. They never suggest switching Row Level Security off, putting the secret key in client code, or loosening a policy.
Checked a finding yourself and it's fine? Add its id and your reason to .launch-blockers-ignore, the file Launch Blockers already uses. Wildcards are refused, and an id stops matching when the code changes shape, so a new hole in the same place isn't hidden. Only a person should add these lines, never an agent.
rolelock:b:0123456789abcdef the guard trigger in 20260110_lock_role.sql blocks thisIn your agent and your CI
GitHub Action
Runs on your own runner and downloads no npm packages. It sets up Node 24 only if the runner's Node is too old. Pin it to a full commit hash, never a tag.
permissions:
contents: read
security-events: write # only for the SARIF upload
jobs:
rolelock:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@<full commit hash>
- uses: priberry-data/rolelock/cli@<full commit hash> # pin a commit, never a tagOn a public repo the log shows counts and finding ids only, because anyone signed in to GitHub can read it. NOT CHECKED fails the job unless you set fail-on-not-checked: false. On pull requests only the base branch's ignore file counts. Never run it on pull_request_target; it refuses to.
MCP server
rolelock mcp speaks stdio and opens no network port. It has one read‑only tool, rolelock_scan, which takes only a folder path and refuses folders outside the folder it was started in or the workspace roots your editor declares.
{ "mcpServers": { "rolelock": { "command": "npx", "args": ["-y", "rolelock@0.1.1", "mcp"] } } }Agent skill
The skill tells a coding agent how to run Rolelock, explain each verdict and apply the fix prompts: a new migration every time, no deploy or db push without your OK, and never an ignore line written by the agent. Copy cli/skill/rolelock into your agent's skills folder.
Open source
Rolelock is free and open source under the Apache‑2.0 license. The code, the rules and the tests are at github.com/priberry-data/rolelock. To report a security problem, see our security page.
Want Rolelock and every other Priberry check run on every change and every deploy?