What is a finding actually telling you?
A good finding has four parts. Read all four before you prompt anything.
- What: the behaviour, in one sentence. "User B can read user A's invoices."
- Where: the page, the API address or the table. "GET /rest/v1/invoices, table public.invoices."
- Proof: the request that was sent and the response that came back. This is the part your AI tool needs most, because it shows the real behaviour instead of a description of it.
- Severity: how bad it is if someone uses it. Some reports use the CVSS scale, where Low is 0.1 to 3.9, Medium 4.0 to 6.9, High 7.0 to 8.9 and Critical 9.0 to 10.0 (FIRST, CVSS v4.0). CVSS describes the severity of a flaw relative to others; your own context can move it up or down.
A finding with no proof is a lead, not a fact. Ask whoever wrote the report for the request and response before you spend a prompt on it.
Which findings should you fix first?
Our order, regardless of the labels in the report:
- Data anyone can read or change. Tables without row level security, one user reaching another's records, public storage buckets, a secret key in the browser's scripts. For a leaked key, rotate it in the provider's dashboard first, then fix the code (what to do about an exposed key).
- Sign-in and accounts. Password reset flaws, admin pages an ordinary user can open, a role field a user can set (can a user make themselves admin?).
- Things that cost you money. AI or paid endpoints anyone can call without signing in (stopping AI bill abuse).
- Injection and cross-site scripting.
- Settings. Security headers, cookie flags, CORS, verbose error pages.
Header findings can fill a page of a report, which makes them feel urgent. They are the least urgent item on this list. Fix them, but not before a table anyone can read.
How should you write the prompt?
One finding per prompt. A prompt with 11 findings gets 11 shallow changes and one vague "done", and when something breaks you cannot tell which change did it.
Each prompt should carry five things:
- The finding's what and where, copied from the report.
- The proof: paste the request and response.
- The expected behaviour: "User B gets an empty list or a 403 for user A's invoices. User A still sees their own."
- The constraint: "Fix it in the database policy or the server route. Do not filter in the browser, do not disable checks, do not change tests to pass."
- The check: "Add a test that signs in as two accounts and fails if B can read A's invoice."
Ask for a plan before any edit. Each tool has a mode for it:
- Claude Code: plan mode, where it "reads files and proposes a plan but makes no edits until you approve". Press Shift+Tab until the status bar shows plan mode, or start with
claude --permission-mode plan(Claude Code docs). - Cursor: Plan Mode, which "creates detailed implementation plans before writing any code". Press Shift+Tab in the chat input or pick it from the mode menu (Cursor docs).
- Lovable: Chat mode "never changes your project's code or data" (Lovable docs), and Plan mode writes a plan you approve before it builds (Lovable docs).
Read the plan for one thing above all: where the fix lives. If the plan touches only a React component for a data-access finding, say no and point it at the policy or the route. Our fix prompt library has ready prompts in this shape, for example owner-only rows and checking the owner on every record.
What does a fake fix look like?
Here is the fix from the opening scene:
// The page loaded every invoice
const { data } = await supabase.from("invoices").select("*")
// The "fix": hide other people's rows after they arrive
const mine = data?.filter((row) => row.user_id === session.user.id)
Every row still reaches the browser, and anyone with your publishable key can call the same API without your page at all. The fix belongs in the database:
alter table public.invoices enable row level security;
-- Remove the policy that let every signed-in user read everything
drop policy if exists "Authenticated users can read invoices" on public.invoices;
create policy "Owners read their own invoices"
on public.invoices for select
to authenticated
using ( (select auth.uid()) = user_id );
The drop policy line matters. In Postgres, "all permissive policies which are applicable to a given query will be combined together using the Boolean OR operator" (PostgreSQL docs). Add a strict policy next to an old permissive one and the old one still wins. Supabase recommends the (select auth.uid()) form for performance (Supabase docs); the RLS troubleshooting guide covers other ways a policy fails quietly.
Other symptom fixes to reject:
- Catching the error and returning an empty list, so the finding's request "fails" politely while the data path stays open.
- Turning off row level security or a check "temporarily" to make a feature work.
- Removing the admin link from the menu while the admin API still answers.
- Editing the test until it passes.
That last one is documented. In March 2025 OpenAI published examples of a reasoning model on coding tasks whose own notes said "We can circumvent verify to always return true", and another that skipped tests outright (OpenAI). The tool is doing what it was rewarded for: making the failure go away. Your prompt has to make the real fix the only acceptable one.
How do you prove the fix worked?
Do not ask the tool. Claude Code's own documentation says "Claude stops when the work looks done" and that "All tests pass" on its own "tells you very little"; ask for the command it ran and the output (Claude Code best practices).
First, keep a regression test. Run it against a staging project with two test accounts that each own data:
import { createClient } from "@supabase/supabase-js"
import { expect, test } from "vitest"
const env = process.env
async function signIn(email: string, password: string) {
const client = createClient(env.SUPABASE_URL!, env.SUPABASE_PUBLISHABLE_KEY!)
const { error } = await client.auth.signInWithPassword({ email, password })
if (error) throw error
return client
}
test("account B cannot read account A's invoice", async () => {
const a = await signIn(env.A_EMAIL!, env.A_PASSWORD!)
const b = await signIn(env.B_EMAIL!, env.B_PASSWORD!)
const { data: own } = await a.from("invoices").select("id").limit(1)
expect(own).toHaveLength(1) // A still sees their own
const { data } = await b.from("invoices").select("id").eq("id", own![0].id)
expect(data).toEqual([]) // hidden rows come back empty, not as an error
})
The empty result is expected: rows a policy hides "are silently suppressed; no error is reported" (PostgreSQL docs). If you prefer SQL, supabase test db runs pgTAP tests (Supabase docs).
Second, repeat the proof from the report on the running app. Sign in as the second test account, send the exact request from the finding, and read the response. The access control test walks through it with two accounts, including changes and deletes.
Third, ask whoever found it to recheck that finding. A scanner, a pentester or a platform scan can each confirm the request now fails from their side.
How do you avoid breaking the app, and undo a fix?
Commit before each finding and after it, one finding per commit, with the finding's title in the message. Tool undo features help, with limits:
- Cursor's checkpoints are local snapshots of agent edits; its docs say to "use Git for permanent version control" (Cursor docs).
- Lovable's revert restores "your project's code only" and "does not restore or roll back your database data"; migrations already run stay run (Lovable docs).
That second point bites with security fixes, because policies live in the database. Before a policy change, save the current policies (the SQL is in the RLS testing guide) so you can put them back by hand.
After each fix, click through the normal flows as both accounts. A tight policy often breaks something legitimate, such as a shared item or a team view. That is a design question for the plan, not a reason to loosen the policy.
Your next step: take the single most serious finding in your report, switch your tool to its plan mode, and paste in the proof with the five parts above.