agentsclimarketplace

Api security

Skill LeahyCC/claude-skills/skills/api-security

Production-grade Claude Code skills verified against official specifications. Zero dependencies. Complete domain coverage.

Install
npx -y skills add LeahyCC/claude-skills --skill api-security

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

OWASP API Security Top 10 (2023) with production Next.js App Router code — access control, authentication, input validation, rate limiting, security headers, data exposure, supply chain, SSRF

SKILL.md

8.8 KB, as published. Nobody here has run it

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 (2021). Verified against the official OWASP specifications.

Architecture

Request → proxy.ts (auth gate) → 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, A02Session management, JWT, Clerk/Auth0, proxy.ts
Input ValidationAPI3, API8A03Zod schemas, SQL injection, XSS, Server Action validation
Rate LimitingAPI4A04Per-endpoint limits, cost attacks, Upstash patterns
Security HeadersAPI8A05CSP, HSTS, CORS, Permissions-Policy, next.config
Data ExposureAPI3, API6A04DAL pattern, DTOs, error sanitization, response filtering
Supply ChainAPI9, API10A06, A08Dependencies, env vars, CI/CD, third-party APIs
SSRF & LoggingAPI7A09, A10URL validation, fetch safety, secure logging, audit trails

Decision Matrix: "Where Do I Add Security?"

LayerWhat to CheckWhy
proxy.tsAuth redirect, CSP nonce, rate limit headersFirst line — blocks unauthenticated requests early
Route Handler (route.ts)Auth + authz, input validation, CORS, CSRFPublic 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

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.

// 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
Is proxy.ts checking auth before page access?Add auth middlewareAuthentication
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

OWASP API Security Top 10 (2023) — Full Mapping

#CategorySeverityResource
API1Broken Object Level Authorization (BOLA)Criticalaccess-control
API2Broken AuthenticationCriticalauthentication
API3Broken Object Property Level AuthorizationHighinput-validation, data-exposure
API4Unrestricted Resource ConsumptionHighrate-limiting
API5Broken Function Level AuthorizationCriticalaccess-control
API6Unrestricted Access to Sensitive Business FlowsMediumdata-exposure
API7Server Side Request ForgeryHighssrf-and-logging
API8Security MisconfigurationMediumsecurity-headers, input-validation
API9Improper Inventory ManagementMediumsupply-chain
API10Unsafe Consumption of APIsMediumsupply-chain

OWASP Web Top 10 (2021) — Cross-Reference

#CategoryMapped To
A01Broken Access Controlaccess-control
A02Cryptographic Failuresauthentication
A03Injectioninput-validation
A04Insecure Designrate-limiting, data-exposure
A05Security Misconfigurationsecurity-headers
A06Vulnerable & Outdated Componentssupply-chain
A07Auth Failuresauthentication
A08Software & Data Integrity Failuressupply-chain
A09Logging & Monitoring Failuresssrf-and-logging
A10SSRFssrf-and-logging

Code Review Checklist

When reviewing API code in Next.js, verify:

  • Every 'use server' function checks auth — no exceptions
  • No user-supplied IDs used for ownership — derive from session
  • All inputs validated with Zod before use
  • Database queries use parameterized queries or ORM
  • Responses return DTOs, not raw database records
  • Error messages don't leak stack traces, SQL, or internal paths
  • Security headers set in next.config.ts (CSP, HSTS, X-Frame-Options)
  • Rate limiting on auth endpoints and expensive operations
  • proxy.ts gates auth before page/action access
  • Environment variables accessed only in server-only modules
  • No fetch() to user-controlled URLs without allowlist
  • Dependencies audited — no known vulnerabilities
  • .env*.local in .gitignore

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.