Server Action AuthZ

    1

    Stop IDOR and missing session checks on Next.js Server Actions before they ship.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    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 Post record
    • Caller: Likely a form action or startTransition on 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

    1. Implement the requireUser helper if it does not exist in lib/auth.
    2. Update the client-side caller to handle the structured { ok: true } response.
    3. Verify that authorId is 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Listed21 days ago

    What's inside

    Frequently Asked Questions

    This skill specifically targets the 'Server Action' layer in Next.js, detecting IDOR vulnerabilities and tenant leaks that generic security scanners often miss by tracing how client data interacts with your database queries.

    It is designed for Next.js App Router projects using TypeScript and is compatible with major auth providers like Auth.js, Clerk, and Supabase, as well as Zod for schema validation.

    The skill generates a comprehensive audit report including an inventory of all exported actions, severity-ranked vulnerability findings, and specific code patches to harden your server-side logic.

    No, this skill focuses on the application logic layer; it identifies authorization gaps but does not configure your database's Row Level Security (RLS) or underlying ORM policies.

    Simply provide the skill with access to your Next.js project's source code (specifically the `/app` or `/actions` directories) to begin the automated inventory and audit process.

    New in Frontend & Web Apps