The mistake
Treating a server action as private because the page that renders the form is protected, and writing to the database without checking the session inside the action.
Why it is dangerous
Every exported function in a "use server" file (and every inline "use server" function) becomes a public POST endpoint. Next.js calls it with an action id that is in the page's JavaScript, so anyone can invoke it directly with any arguments, whether or not the page is protected. The arguments are client input, not trusted values.
How to fix it
Authenticate (and authorize) inside every action, like an API route:
"use server";
import { auth } from "@/auth"; // or Clerk auth() / getServerSession / supabase.auth.getUser()
export async function deletePost(id: string) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");
await prisma.post.delete({ where: { id, authorId: session.user.id } });
}
What this checker looks for
This page runs route-auth-check, which reads
Next.js, Express, Fastify, Hono, FastAPI, Flask and Django routes. The rules most relevant to this page:
| Rule | What it finds |
|---|---|
RAC003 | Server action has no authentication check |
RAC002 | Record looked up by a request id with no ownership check (IDOR) |
RAC006 | User id or role taken from the request instead of the session |
RAC008 | Whole request body written to the database (mass assignment) |
Every finding has a rule id, a severity, file:line, the offending line (secrets masked),
why it matters and how to fix it. Run route-auth-check rules for the full list.