DrillsAny invoice, one number away
Any invoice, one number away
What happened
Harbor’s invoice page and its PDF download both call loadInvoice, which Claude Code wrote last month. Every request must be signed in, so it looked safe. Invoice ids are numbers that go up by one. Yesterday a customer wrote to support.
Ana Ruiz, Fjord StudioOut of curiosity I changed the number at the end of my invoice link from 1041 to 1042. I got Kestrel Café’s invoice: their address, what they paid, and the last four digits of their card. I stopped there. You might want to look.
The MagisterRun it first and read what comes back. Then change the code if you like: your edits go to the review too.
Run it: runAccessTests calls loadInvoice as Ana (Fjord Studio), Lena (an accountant on two teams) and Omar (removed from Fjord last week), with fake invoices. db works like Prisma: findUnique and findFirst with a where.
// Loads one invoice for the invoice page and its PDF download.
// user comes from the session, with the ids of the teams they belong to right now.
// id comes from the URL.
async function loadInvoice(user, id) {
const invoice = await db.invoice.findUnique({ where: { id } });
if (!invoice) return { status: 404, body: { error: "Invoice not found" } };
return { status: 200, body: invoice };
}
// Harbor's access tests call loadInvoice as different people. Press Run to see what each got.
const results = await runAccessTests(loadInvoice);
console.log(results.summary);
The code runs in your browser against stand-in data. Nothing is sent anywhere.
Your answer
Reviewed by AI against what a good fix needs. About 10 seconds.Sign in to get your answer reviewed
It's free. Anything you've typed here stays in this browser and is waiting when you come back.
Sign in with email