leahycc/claude-skills/api-security

Claude Code and agent skill by leahycc/claude-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

OWASP API Security Top 10 (2023) with production Next.js App Router code. Access control, authentication with MFA and password reset, input validation (SQL, NoSQL and command injection), rate limiting and per-account login throttling, security headers and CSRF, data exposure, supply chain and startup env checks, SSRF with DNS pinning, file uploads, and AI tools on those APIs. Use when writing or reviewing Route Handlers, Server Actions, proxy.ts, auth flows, uploads, outbound fetches, or next.config security settings.

Install

npx vskill@latest install leahycc/claude-skills/api-security

SKILL.md

The same SKILL.md was published earlier as leahycc/claude-skills/api-security.

API Security — OWASP API Security Top 10 (2023) for Next.js

Production-grade API security patterns for Next.js App Router. Covers every category in the OWASP API Security Top 10 (2023) with cross-references to the OWASP Web Top 10 (2025). AI tools attached to those APIs are in AI Tools. Verified against the official OWASP specifications.

Scope: for CSRF and XSS this skill covers the server half. That is request origin checks, cookie flags, headers, and the sinks where user data reaches HTML. Client-side DOM code and browser state are out of scope.

Contents

Architecture

Request → proxy.ts (logged-out redirect) → Route Handler / Server Action
↓
Input Validation (Zod)
↓
Data Access Layer (auth + authz + DTO)
↓
Database (parameterized queries)
↓
Filtered Response (DTO, no raw records)

The Data Access Layer (DAL) is the central security architecture recommended by Next.js. All database access, authorization checks, and response filtering happen in one server-only module — never in components or actions directly.

Quick Reference

ResourceOWASP APIOWASP WebWhat It Covers
Access ControlAPI1, API5A01BOLA/IDOR, function-level auth, ownership checks
AuthenticationAPI2A07, A04Session management, JWT, Clerk/Auth0, proxy.ts, password reset, MFA and passkeys
Input ValidationAPI3, API8A05Zod schemas, SQL, NoSQL and command injection, XSS, Server Action validation
Rate LimitingAPI4A06Per-endpoint limits, per-account login throttling, cost attacks, Upstash patterns
Security HeadersAPI8A02CSP, HSTS, CORS, CSRF (Fetch Metadata, allowedOrigins), Permissions-Policy
Data ExposureAPI3, API6A06, A10DAL pattern, DTOs, error sanitization, race-safe business limits
Supply ChainAPI9, API10A03, A08Dependencies, env vars and startup schema, CI/CD, third-party APIs
SSRF & LoggingAPI7A01, A09URL validation, DNS pinning, fetch safety, secure logging, audit trails
File UploadsAPI4A06Size caps, magic bytes, random names, scan hook, separate origin
AI ToolsAPI1, API5A01Tool calls, session identity, signed approval, MCP

Decision Matrix: "Where Do I Add Security?"

LayerWhat to CheckWhy
proxy.tsLogged-out redirect, CSP nonce, rate limitsA cookie check here is not the authorization check
Route Handler (route.ts)Auth + authz, input validation, CORS, CSRF, body sizePublic HTTP endpoint. Treat as untrusted
Server Action ('use server')Auth + authz, input validation, return filteringAlso a public HTTP endpoint — not protected by the UI
Data Access Layer (data/*.ts)Ownership checks, field filtering, parameterized queriesLast line — defense in depth
next.config.tsSecurity headers, redirects, allowed image domainsStatic security baseline
Tool execute (lib/ai)Session user, one action, signed approval for writesThe model chooses the call. The session is the caller

The #1 Mistake: Server Actions Are Public Endpoints

Every exported 'use server' function is reachable via direct POST request. Page-level auth does NOT protect actions on that page.

tsx
// FAIL — no auth check, anyone can call this via POST
'use server'
export async function deleteAccount(userId: string) {
await db.delete(users).where(eq(users.id, userId))
}
// PASS — validates auth AND ownership inside the action
'use server'
import { getCurrentUser } from '@/data/auth'
export async function deleteAccount() {
const user = await getCurrentUser()
if (!user) throw new Error('Unauthorized')
await db.delete(users).where(eq(users.id, user.id))
}

Notice: the PASS version doesn't accept userId as a parameter — it derives it from the session. This prevents IDOR (Insecure Direct Object Reference).

Decision Matrix: "Is This Secure?"

QuestionIf No →Resource
Does every Server Action re-verify auth?Add getCurrentUser() checkAccess Control
Does every Route Handler validate input with Zod?Add schema validationInput Validation
Are database queries parameterized?Use tagged templates or ORMInput Validation
Does the response return only needed fields?Add DTO layerData Exposure
Are rate limits in place for auth endpoints?Add Upstash/ArcjetRate Limiting
Are security headers configured?Add to next.config.tsSecurity Headers
Does the DAL reject a missing or revoked session?Check in getCurrentUser(), not only in proxy.tsAuthentication
Are env vars only accessed in the DAL?Move to server-only moduleSupply Chain
Does fetch() in server code validate URLs?Add URL allowlistSSRF & Logging
Are errors sanitized before returning to client?Return generic messagesData Exposure
Does tool execute take the user from the session?Remove userId from the tool schemaAI Tools
Do write tools require an approval the client cannot forge?Sign it, show the real arguments, spend it once for that userAI Tools
Is each MCP server pinned, with its own credential?Name the tools. Do not forward the sessionAI Tools
Are uploads checked by bytes and size, then served from another origin?Magic-byte allowlist, caps, nosniff, attachmentFile Uploads
Are login failures counted per account as well as per IP?Add a per-account limiter that slows, not locksRate Limiting
Are reset tokens random, hashed, single use, and short-lived?Use generateResetToken and consumeResetTokenAuthentication
Do state-changing Route Handlers reject cross-site requests?Check Sec-Fetch-Site, then OriginSecurity Headers
Does the app refuse to start with a missing secret?Zod-parse process.env from instrumentation.tsSupply Chain

OWASP API Security Top 10 (2023): Full Mapping

#CategoryResource
API1Broken Object Level Authorization (BOLA)access-control
API2Broken Authenticationauthentication
API3Broken Object Property Level Authorizationinput-validation, data-exposure
API4Unrestricted Resource Consumptionrate-limiting, file-uploads
API5Broken Function Level Authorizationaccess-control
API6Unrestricted Access to Sensitive Business Flowsdata-exposure
API7Server Side Request Forgeryssrf-and-logging
API8Security Misconfigurationsecurity-headers, input-validation
API9Improper Inventory Managementsupply-chain
API10Unsafe Consumption of APIssupply-chain

OWASP Web Top 10 (2025): Cross-Reference

#CategoryMapped To
A01Broken Access Control (includes SSRF)access-control, ssrf-and-logging
A02Security Misconfigurationsecurity-headers
A03Software Supply Chain Failuressupply-chain
A04Cryptographic Failuresauthentication
A05Injectioninput-validation
A06Insecure Designrate-limiting, data-exposure, file-uploads
A07Authentication Failuresauthentication
A08Software or Data Integrity Failuressupply-chain
A09Security Logging and Alerting Failuresssrf-and-logging
A10Mishandling of Exceptional Conditionsdata-exposure

AI tools: where they map

The model is a component until it can call a tool. After that, the agentic list applies. This skill covers the tool call on a Next.js route, in AI Tools. Token spend stays in rate-limiting.

RiskResource
LLM01 Prompt Injection, LLM03 Excessive Agency, LLM10 Improper Output Handlingai-tools
LLM06 Unbounded Consumptionrate-limiting
ASI01 Goal Hijack, ASI02 Tool Misuse, ASI03 Identity and Privilege Abuse, ASI05 Unexpected Code Execution, ASI09 Human-Agent Trust Exploitationai-tools
ASI04 Agentic Supply Chain (MCP server, tool definitions)ai-tools, supply-chain

Poisoned training data, embedding stores, cross-session memory, and agents talking to each other are outside this skill.

Code Review Checklist

When reviewing API code in Next.js, verify:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
3
Repository forks
1
7-day trend score
7

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/leahycc/claude-skills/api-security/badge)](https://verified-skill.com/skills/leahycc/claude-skills/api-security)

Something wrong with this skill or its page? Tell us.