leahycc/claude-skills/api-security
Claude Code and agent skill by leahycc/claude-skills
- community
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-securitySKILL.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
- Quick Reference
- Decision Matrix: "Where Do I Add Security?"
- The #1 Mistake: Server Actions Are Public Endpoints
- Decision Matrix: "Is This Secure?"
- OWASP API Security Top 10 (2023): Full Mapping
- OWASP Web Top 10 (2025): Cross-Reference
- AI tools: where they map
- Code Review Checklist
- Audit Report Format
Architecture
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
| Resource | OWASP API | OWASP Web | What It Covers | |
|---|---|---|---|---|
| Access Control | API1, API5 | A01 | BOLA/IDOR, function-level auth, ownership checks | |
| Authentication | API2 | A07, A04 | Session management, JWT, Clerk/Auth0, proxy.ts, password reset, MFA and passkeys | |
| Input Validation | API3, API8 | A05 | Zod schemas, SQL, NoSQL and command injection, XSS, Server Action validation | |
| Rate Limiting | API4 | A06 | Per-endpoint limits, per-account login throttling, cost attacks, Upstash patterns | |
| Security Headers | API8 | A02 | CSP, HSTS, CORS, CSRF (Fetch Metadata, allowedOrigins), Permissions-Policy | |
| Data Exposure | API3, API6 | A06, A10 | DAL pattern, DTOs, error sanitization, race-safe business limits | |
| Supply Chain | API9, API10 | A03, A08 | Dependencies, env vars and startup schema, CI/CD, third-party APIs | |
| SSRF & Logging | API7 | A01, A09 | URL validation, DNS pinning, fetch safety, secure logging, audit trails | |
| File Uploads | API4 | A06 | Size caps, magic bytes, random names, scan hook, separate origin | |
| AI Tools | API1, API5 | A01 | Tool calls, session identity, signed approval, MCP |
Decision Matrix: "Where Do I Add Security?"
| Layer | What to Check | Why | |
|---|---|---|---|
proxy.ts | Logged-out redirect, CSP nonce, rate limits | A cookie check here is not the authorization check | |
Route Handler (route.ts) | Auth + authz, input validation, CORS, CSRF, body size | Public HTTP endpoint. Treat as untrusted | |
Server Action ('use server') | Auth + authz, input validation, return filtering | Also a public HTTP endpoint — not protected by the UI | |
Data Access Layer (data/*.ts) | Ownership checks, field filtering, parameterized queries | Last line — defense in depth | |
next.config.ts | Security headers, redirects, allowed image domains | Static security baseline | |
Tool execute (lib/ai) | Session user, one action, signed approval for writes | The 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.
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?"
| Question | If No → | Resource | |
|---|---|---|---|
| Does every Server Action re-verify auth? | Add getCurrentUser() check | Access Control | |
| Does every Route Handler validate input with Zod? | Add schema validation | Input Validation | |
| Are database queries parameterized? | Use tagged templates or ORM | Input Validation | |
| Does the response return only needed fields? | Add DTO layer | Data Exposure | |
| Are rate limits in place for auth endpoints? | Add Upstash/Arcjet | Rate Limiting | |
| Are security headers configured? | Add to next.config.ts | Security Headers | |
| Does the DAL reject a missing or revoked session? | Check in getCurrentUser(), not only in proxy.ts | Authentication | |
| Are env vars only accessed in the DAL? | Move to server-only module | Supply Chain | |
Does fetch() in server code validate URLs? | Add URL allowlist | SSRF & Logging | |
| Are errors sanitized before returning to client? | Return generic messages | Data Exposure | |
Does tool execute take the user from the session? | Remove userId from the tool schema | AI Tools | |
| Do write tools require an approval the client cannot forge? | Sign it, show the real arguments, spend it once for that user | AI Tools | |
| Is each MCP server pinned, with its own credential? | Name the tools. Do not forward the session | AI Tools | |
| Are uploads checked by bytes and size, then served from another origin? | Magic-byte allowlist, caps, nosniff, attachment | File Uploads | |
| Are login failures counted per account as well as per IP? | Add a per-account limiter that slows, not locks | Rate Limiting | |
| Are reset tokens random, hashed, single use, and short-lived? | Use generateResetToken and consumeResetToken | Authentication | |
| Do state-changing Route Handlers reject cross-site requests? | Check Sec-Fetch-Site, then Origin | Security Headers | |
| Does the app refuse to start with a missing secret? | Zod-parse process.env from instrumentation.ts | Supply Chain |
OWASP API Security Top 10 (2023): Full Mapping
| # | Category | Resource | |
|---|---|---|---|
| API1 | Broken Object Level Authorization (BOLA) | access-control | |
| API2 | Broken Authentication | authentication | |
| API3 | Broken Object Property Level Authorization | input-validation, data-exposure | |
| API4 | Unrestricted Resource Consumption | rate-limiting, file-uploads | |
| API5 | Broken Function Level Authorization | access-control | |
| API6 | Unrestricted Access to Sensitive Business Flows | data-exposure | |
| API7 | Server Side Request Forgery | ssrf-and-logging | |
| API8 | Security Misconfiguration | security-headers, input-validation | |
| API9 | Improper Inventory Management | supply-chain | |
| API10 | Unsafe Consumption of APIs | supply-chain |
OWASP Web Top 10 (2025): Cross-Reference
| # | Category | Mapped To | |
|---|---|---|---|
| A01 | Broken Access Control (includes SSRF) | access-control, ssrf-and-logging | |
| A02 | Security Misconfiguration | security-headers | |
| A03 | Software Supply Chain Failures | supply-chain | |
| A04 | Cryptographic Failures | authentication | |
| A05 | Injection | input-validation | |
| A06 | Insecure Design | rate-limiting, data-exposure, file-uploads | |
| A07 | Authentication Failures | authentication | |
| A08 | Software or Data Integrity Failures | supply-chain | |
| A09 | Security Logging and Alerting Failures | ssrf-and-logging | |
| A10 | Mishandling of Exceptional Conditions | data-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.
| Risk | Resource | |
|---|---|---|
| LLM01 Prompt Injection, LLM03 Excessive Agency, LLM10 Improper Output Handling | ai-tools | |
| LLM06 Unbounded Consumption | rate-limiting | |
| ASI01 Goal Hijack, ASI02 Tool Misuse, ASI03 Identity and Privilege Abuse, ASI05 Unexpected Code Execution, ASI09 Human-Agent Trust Exploitation | ai-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
- SKILL.md in the repositoryCheckingskills/api-security/SKILL.md
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
[](https://verified-skill.com/skills/leahycc/claude-skills/api-security)