- Home
- Skills
- Frontend & Web Apps
- Server Action AuthZ
Server Action AuthZ
Stop IDOR and missing session checks on Next.js Server Actions before they ship.
$9
Works with the AI Agents you already use
Server Action AuthZ
Example session with this skill installed
secure this Server Action:
export async function updatePost(id, data) {
await db.post.update({ where: { id }, data });
}
- Read your context and instructions
- Compiled the server action authz
I have audited the updatePost action. It currently lacks authentication, input validation, and ownership checks, creating a high-risk IDOR vulnerability.
Server Action AuthZ Audit
Action inventory
- Action:
updatePost - File:
actions/post.ts - Mutation: Update
Postrecord - Caller: Likely a form action or
startTransitionon a post editing page.
AuthZ findings
- Blocker: Missing Authentication. The action does not call a session helper; anyone can invoke this endpoint.
Blocker: IDOR / Missing Ownership. The action updates a post based solely on a client-provided id without verifying if the user owns the post.
Major: Schema Validation. Input data is passed directly to the DB without parsing, allowing for potential mass-assignment of restricted fields.
Hardening patch
"use server";
import { z } from "zod";
import { requireUser } from "@/lib/auth";
import { db } from "@/lib/db";
const UpdatePostInput = z.object({
id: z.string().min(1),
title: z.string().trim().min(1).max(200).optional(),
content: z.string().optional(),
});
export async function updatePost(raw: unknown) {
const user = await requireUser();
const input = UpdatePostInput.parse(raw);
// Validate ownership in the query
const post = await db.post.findFirst({
where: { id: input.id, authorId: user.id },
});
if (!post) {
throw new Error("Post not found or unauthorized");
}
await db.post.update({
where: { id: post.id },
data: {
title: input.title,
content: input.content,
},
});
return { ok: true as const };
}
Residual risks
- Rate Limiting: Multiple rapid updates could be triggered; consider adding a sliding window limit.
- Audit Logs: Mutations are not currently logged for administrative review.
Next steps
- Implement the
requireUserhelper if it does not exist inlib/auth. - Update the client-side caller to handle the structured
{ ok: true }response. - Verify that
authorIdis the correct field name in your Prisma/Database schema.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop IDOR and missing session checks on Next.js Server Actions before they ship. Audits App Router Server Actions for authentication gaps, object-level authorization, tenant isolation, and client-trusted privilege fields. Returns Action inventory, AuthZ findings, Hardening patch, and Residual risks. Includes checklist, patterns, anti-patterns, and a bad-to-good delete example. Complements Zod input contracts; does not replace a full policy engine.
Does not replace ORM policy engines or RLS. Requires existing auth library (Auth.js, Clerk, etc.) to be present for session resolution.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 21 days ago
Permissions
No special permissions declared or detected