GuidesUpdated

How to review an AI-generated access-control PR

Use a permission matrix and cross-user tests to review an agent-written authentication or authorization change before you merge it.

On this page

A login screen can work while a signed-in user still reads someone else's data. When an agent changes authentication, roles, database policies or a private API, review exactly what it grants. With an example invoice PR, this guide builds a test matrix, traces the server and database, and ends in a merge decision.

Canopy pull request review beside an agent's findings and code diff
Canopy pull request review beside an agent's findings and code diff

Write the permission rule before reading the diff

Say a PR lets team members open invoices. The rule might be: an active member of the invoice's team can view it; only a billing admin can edit it; outsiders and signed-out visitors can do neither. Have the product owner confirm it before you judge the code. Authentication says who the caller is; authorization says whether they may do this action on this object. OWASP recommends denying by default.

Example review matrix. Replace these rules with your product's policy before testing.
CallerInvoiceExpected readExpected edit
Signed-out visitorAny private invoiceDenyDeny
Team memberOwn team's invoiceAllowDeny
Different memberAnother team's invoiceDenyDeny
Billing adminOwn team's invoiceAllowAllow
Removed memberFormer team's invoiceDenyDeny

Follow the request past the visible button

Find every changed route, server action, query, migration and policy that reads or edits invoices. A hidden link or disabled button isn't server-side authorization. Check the server identifies the caller and checks the requested invoice rather than trusting a client-supplied team ID or role. Then send the request with another team's invoice ID. OWASP calls this object-level authorization. Check list, detail, export, attachment, update and delete paths; one guarded page can leave another route open.

  • Test unauthorized requests at the API or database, not just the UI.
  • If the policy is ambiguous, stop and ask the owner.

Inspect database and credential changes

On Supabase, review both grants and row-level security policies for the table. Grants decide which operations a role can attempt; RLS decides which rows they reach. Confirm RLS is on, policies match the matrix, and tests use distinct users and teams. A secret key bypasses RLS and must stay server-side; in browser code it blocks the merge. For other backends, check their equivalent enforcement. Review dependency changes separately.

  • Check migration order and existing grants, not just the new policy.
  • Check whether a privileged client serves ordinary user requests.

Ask a second agent for evidence, then reproduce it

Give a reviewer agent read-only scope, the matrix and the latest commit. Ask it to list every entry point, cite a file and line per finding, and separate proven bypasses from hypotheses. A person then runs the cross-user case with disposable accounts. If the agent can't run the app, its output is a review plan, not proof. Keep both agents on the same commit.

  • Record the request, expected denial, actual response and account role.
  • Confirm allowed requests still work; always-deny hides broken features.
  • After a fix, rerun the failed case and check the newest diff and CI.

Decide what is ready to merge

Approval needs a confirmed rule, reviewed server and data paths, allowed and denied test results, and the latest diff. For payment authority, tenant-wide access, production credentials or similar, get a qualified security reviewer. A green CI badge doesn't mean cross-user tests ran. Record what's still uncertain and who accepts it.

Copyable resources

Read-only access-control reviewer prompt

Use test accounts and fixtures. Don't give the reviewer production secrets or permission to approve or merge.

Review PR [link] at head commit [SHA] against this approved rule: [who may read/edit which object]. Don't edit files, comment, approve or merge. Map every changed UI, API, server action, query, migration and database policy that affects this rule. For each possible bypass, give file/line, caller and object, request path, expected result and evidence. Separate confirmed findings from cases that need a human test. Check signed-out, own-team, other-team, admin and removed-member cases. List the tests and CI results you inspected, and flag credential or dependency changes. End with the cases still unverified.

Frequently asked questions

Is a working login screen enough to approve an authentication PR?

No. A signed-in user may still reach an object or action they shouldn't. Confirm the permission rule and test it at the server and data layer.

What is the fastest useful negative test?

With a disposable account from another team, request the changed object's ID directly through the affected API or query and confirm it's denied. Then confirm the allowed account still succeeds.

Can an AI reviewer sign off on access control?

No. It can propose paths and findings. A person verifies the rule, reproduction and final diff, and owns the approval.

Does Supabase RLS remove the need to inspect backend code?

No. Check grants and policies, and whether a privileged server client or another route bypasses user-scoped access.

More questions and answers →

Sources and further reading