Authorization check may be missing
Investigates authenticated handlers that may not authorize access to the requested resource.
| Detail | Value |
|---|---|
| Check ID | MISSING_AUTHORIZATION_CHECK |
| Severity | High |
| How it runs | Agent review |
Anchor to Vulnerable exampleVulnerable example
app/routes/app.reports.$id.delete.tsx
import type { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
import prisma from "../db.server";
export const action = async ({ request, params }: ActionFunctionArgs) => {
// Authentication answers "who is calling". It doesn't answer
// "may this caller delete this record".
await authenticate.admin(request);
await prisma.report.delete({ where: { id: params.id } });
return { deleted: true };
};
Anchor to How to fixHow to fix
Authorize the actor and resource after authentication.
app/routes/app.reports.$id.delete.tsx
import type { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
import prisma from "../db.server";
export const action = async ({ request, params }: ActionFunctionArgs) => {
const { session } = await authenticate.admin(request);
// Authorize the actor against the resource, then act on the
// record you just authorized rather than on the raw id.
const report = await prisma.report.findFirst({
where: { id: params.id, shop: session.shop },
});
if (!report) throw new Response("Not found", { status: 404 });
await prisma.report.delete({ where: { id: report.id } });
return { deleted: true };
};
shopify app security check, the command that runs this check- All app security checks
Was this page helpful?