Code Security Review
Lifecycle skill for REST and GraphQL APIs: covers secure design (controls to implement) and active security testing (payloads to validate those controls). One skill, two complementary modes — invoke whichever fits the current phase of work.
When to Use
Use this skill when:
- Designing or hardening FastAPI / Django / Flask APIs (→
references/python/), Gin / Fiber APIs (→ references/golang/), or Elysia APIs (→ references/DESIGN_CONTROLS.md)
- Reviewing an existing API for security weaknesses against the OWASP Web Top 10 (2025) + API Top 10 (2023)
- Pre-release security assessment before deploying to production (→
references/TESTING_PHASES.md)
- Bug bounty engagements or pentest of an API target
- Implementing or auditing AuthN/AuthZ (JWT, OAuth 2.1, DPoP, API keys, RBAC/ABAC)
- Adding rate limiting, input validation, CORS, or security headers
- Reporting findings — use the standardized template in
references/REPORT_TEMPLATE.md
- Consulting the catalog of 100 web vulnerabilities by category (→
references/WEB_VULNERABILITIES.md)
- Auditing CI/CD + software supply chain (GitHub Actions, lockfile pinning, secrets, SBOM) — A03:2025 (→
references/SUPPLY_CHAIN_CICD.md)
- Reviewing LLM / agentic / MCP features (prompt injection, tool misuse, AI-generated-code patterns) — OWASP LLM 2025 + Agentic 2026 (→
references/AI_SECURITY.md)
This skill is fully standalone — every payload, snippet, and checklist needed lives in this directory.
How This Skill Is Organized
| File / Directory |
Use when |
SKILL.md (this file) |
Foundations, Phase 0 stack + surface detection, OWASP Web 2025 + API 2023 maps, AI/agentic pointer, audit cheat sheet |
references/DESIGN_CONTROLS.md |
Implementing or reviewing controls (proactive) — language-agnostic |
references/TESTING_PHASES.md |
Running 7-phase active testing workflow (reactive) — language-agnostic |
references/REPORT_TEMPLATE.md |
Documenting findings with consistent severity rubric |
references/WEB_VULNERABILITIES.md |
Reference catalog of 100 web vulnerabilities by category (XSS, CSRF, deserialization, mobile/IoT, etc.) |
references/golang/ |
Go stack lifecycle (Gin/Fiber): API.md, MIDDLEWARE.md, VULNERABILITIES.md, PATCHES.md, TESTING_PAYLOADS.md |
references/python/ |
Python stack lifecycle (FastAPI / Django / Flask, CPython 3.13/3.14): API.md, CONFIGURATION.md, VULNERABILITIES.md, PATCHES.md, TESTING_PAYLOADS.md |
references/nextjs/ |
Next.js 16 App Router lifecycle: API.md, CONFIGURATION.md, VULNERABILITIES.md, PATCHES.md, TESTING_PAYLOADS.md |
references/SUPPLY_CHAIN_CICD.md |
A03:2025 deep-dive — dependency pinning, GitHub Actions hardening, secrets, SBOM, incident case studies |
references/AI_SECURITY.md |
LLM Top 10 2025, Agentic Top 10 2026, MCP security, prompt-injection controls, AI-generated-code review |
scripts/ |
Executable probes — automate Phase 0–10 against a live target, or static phases (07/09/10/11) with STATIC_ONLY=1. See scripts/README.md. |
Phase 0 — Stack Detection
Detect the language/framework before loading stack-specific references. Steps 1–4 pick one $STACK (stop at the first match). Step 5 runs always and adds orthogonal surface overlays — AI and CI are independent of the stack.
# Step 1 — Go (Gin / Fiber)
test -f go.mod && grep -E 'gin-gonic/gin|gofiber/fiber/v[23]' go.mod && echo "stack: go"
# Step 2 — Next.js 16+ App Router
test -f package.json && rg '"next":\s*"\^?1[6-9]' package.json && test -d app/ && echo "stack: nextjs-app"
# Step 3 — Python (FastAPI / Django / Flask)
if test -f pyproject.toml || test -f requirements.txt || test -f setup.py; then
rg -q '\bfastapi\b' pyproject.toml requirements*.txt 2>/dev/null && echo "stack: python (framework: fastapi)"
rg -q '\bdjango\b' pyproject.toml requirements*.txt 2>/dev/null && echo "stack: python (framework: django)"
rg -q '\bflask\b' pyproject.toml requirements*.txt 2>/dev/null && echo "stack: python (framework: flask)"
fi
# Step 4 — Elysia / generic
test -f bun.lockb && rg 'elysia' package.json && echo "stack: elysia"
# Step 5 — Surface overlays (always run, additive — not exclusive with the stack above)
rg -lq 'openai|@anthropic-ai/sdk|anthropic|langchain|llamaindex|litellm|ai-sdk|mcp' \
package.json pyproject.toml requirements*.txt go.mod 2>/dev/null && echo "surface: ai-llm"
ls .mcp.json .cursor/mcp.json 2>/dev/null && echo "surface: mcp"
ls .github/workflows/*.y*ml 2>/dev/null && echo "surface: ci-cd"
$STACK |
References to load (in addition to generic) |
Notes |
go |
references/golang/{API,MIDDLEWARE,VULNERABILITIES,PATCHES,TESTING_PAYLOADS}.md |
Gin v1.10.1+, Fiber v2/v3, OWASP API 2023 + Go-specific (race, slowloris, math/rand, pprof, ServeMux conflicts) |
python |
references/python/{API,CONFIGURATION,VULNERABILITIES,PATCHES,TESTING_PAYLOADS}.md |
FastAPI 0.115+, Django 5.x, Flask 3.x, CPython 3.13/3.14 — Pydantic Settings, ASGI middleware, pickle/yaml deserialization, JWT alg confusion, ALLOWED_HOSTS, SECRET_KEY, free-threaded 3.14t races |
nextjs-app |
references/nextjs/{API,CONFIGURATION,VULNERABILITIES,PATCHES,TESTING_PAYLOADS}.md |
Next.js 16.2.x App Router — RSC, Server Actions, Route Handlers, proxy.ts, "use cache", Image Optimizer |
elysia / generic |
references/{DESIGN_CONTROLS,TESTING_PHASES,WEB_VULNERABILITIES,REPORT_TEMPLATE}.md |
Generic references cover the language-agnostic surface |
The generic references (DESIGN_CONTROLS.md, TESTING_PHASES.md, WEB_VULNERABILITIES.md, REPORT_TEMPLATE.md) apply to every stack — load them in addition to the stack-specific bundle. Stack-specific references inherit the OWASP map and severity rubric from the generic ones; do not duplicate.
Step 5 overlays are additive and combine with any $STACK:
| Overlay |
References to load |
Scripts |
ai-llm / mcp |
references/AI_SECURITY.md |
11-ai-llm-probes.sh |
ci-cd |
references/SUPPLY_CHAIN_CICD.md |
09-cicd-workflows.sh, 10-secrets-scan.sh |
Security Foundations (Core Principles)
These principles are language and framework agnostic:
| Principle |
Meaning |
| Defence in Depth |
Multiple independent security layers — one failure should not compromise the system |
| Least Privilege |
Every component and user gets only the minimum access needed |
| Zero Trust |
Never assume a request is safe because it originates inside the network |
| Shift Left |
Embed security checks in development and CI, not only in production monitoring |
| Fail Secure |
On error, deny access rather than allow it |
OWASP Top 10:2025 (Web)
The current Web list (final 2025 edition; replaces 2021). Use these tags for web findings; the API list below is a separate, still-current catalog.
| # |
Category |
Key Risk |
| A01 |
Broken Access Control |
Missing/again-broken authz; SSRF merged in (was A10 in 2021) |
| A02 |
Security Misconfiguration |
Moved up from #5 — debug on, permissive CORS, missing headers, defaults |
| A03 |
Software Supply Chain Failures |
Broadened from "Vulnerable Components" — deps, build, CI, registries |
| A04 |
Cryptographic Failures |
Weak/absent crypto, plaintext secrets, bad TLS |
| A05 |
Injection |
SQL/NoSQL/command/XSS — untrusted input reaching an interpreter |
| A06 |
Insecure Design |
Missing controls by design — no rate limit, no threat model |
| A07 |
Authentication Failures |
Renamed — weak sessions, no brute-force protection, credential stuffing |
| A08 |
Software or Data Integrity Failures |
Unsigned updates, insecure deserialization, untrusted CI artifacts |
| A09 |
Logging & Alerting Failures |
Renamed — no audit trail, no alerting on abuse |
| A10 |
Mishandling of Exceptional Conditions |
New — fail-open error handling, leaked stack traces, logic edge cases |
Changes from 2021
- New: A03 Software Supply Chain Failures broadens the old "Vulnerable & Outdated Components" to the whole dependency→artifact path (see
references/SUPPLY_CHAIN_CICD.md).
- New: A10 Mishandling of Exceptional Conditions — error-handling and fail-open logic become a first-class category.
- SSRF merged into A01 Broken Access Control (was its own A10 in 2021).
- Security Misconfiguration rose to #2. Several categories renamed (Auth Failures, Logging & Alerting Failures).
The OWASP API Top 10 below is a distinct list; its current edition is still 2023 (no 2025 API release).
OWASP API Security Top 10 (2023)
This is the 2023 list — the 2019 list is obsolete.
| # |
Vulnerability |
Key Risk |
| API1 |
Broken Object Level Authorization (BOLA) |
Attacker accesses another user's resources by changing an ID |
| API2 |
Broken Authentication |
Weak tokens, missing expiry, no brute force protection |
| API3 |
Broken Object Property Level Authorization |
Over-fetching (returning private fields) or mass assignment (accepting unexpected fields) |
| API4 |
Unrestricted Resource Consumption |
No rate limiting — DoS, cost amplification, brute force |
| API5 |
Broken Function Level Authorization (BFLA) |
Regular users can call admin functions |
| API6 |
Unrestricted Access to Sensitive Business Flows |
Automated abuse of checkout, account creation, voting |
| API7 |
Server-Side Request Forgery (SSRF) |
New in 2023 — server makes requests to attacker-controlled URLs |
| API8 |
Security Misconfiguration |
Debug mode in prod, permissive CORS, missing headers, default creds |
| API9 |
Improper Inventory Management |
Shadow APIs, deprecated versions, undocumented endpoints |
| API10 |
Unsafe Consumption of APIs |
New in 2023 — trusting third-party API responses without validation |
Changes from 2019
- Removed as separate items: "Excessive Data Exposure" and "Mass Assignment" — merged into API3 (Broken Object Property Level Authorization)
- Renamed: "Lack of Resources and Rate Limiting" → API4 "Unrestricted Resource Consumption"
- Added: API7 SSRF and API10 Unsafe Consumption of APIs
AI / LLM & Agentic Surface
When Phase 0 Step 5 flags ai-llm, mcp, or the code drives LLMs / agents, the web+API catalogs are necessary but not sufficient. Three additional catalogs apply:
- OWASP Top 10 for LLM Applications 2025 (
LLM01:2025 Prompt Injection … LLM10:2025 Unbounded Consumption) — for any LLM-integrated app.
- OWASP Top 10 for Agentic Applications 2026 (
ASI01:2026 Agent Goal Hijack … ASI10:2026 Rogue Agents) — for code that acts via tools, runs multi-step, or talks to other agents.
- OWASP GenAI MCP guides (Secure MCP Server Development; Securely Using Third-Party MCP Servers) — for projects wiring Model Context Protocol servers.
Full tables, controls, AI-generated-code review checklist, and testing payloads in references/AI_SECURITY.md. Static + gated active probes in scripts/11-ai-llm-probes.sh.
OWASP → Phase Map
| OWASP Item |
Design (DESIGN_CONTROLS.md) |
Testing (TESTING_PHASES.md) |
| API1 BOLA |
Authorization patterns |
Phase 2.2 Cross-User Access |
| API2 Broken Auth |
JWT/OAuth 2.1/DPoP |
Phase 1 Authentication Testing |
| API3 BOPLA |
DTOs, mass assignment guards |
Phase 2.3 Over-Fetching, Phase 2.4 Mass Assignment |
| API4 Unrestricted Consumption |
Rate limit algorithms |
Phase 4 Rate Limiting Testing |
| API5 BFLA |
RBAC enforcement |
Phase 2.5 Admin Endpoints |
| API6 Sensitive Flows |
Anti-abuse + MFA |
Phase 4.5 Brute Force |
| API7 SSRF |
URL allowlist |
Phase 3.4 SSRF Payloads |
| API8 Misconfiguration |
Headers, CORS, debug-off |
Phase 5 Info Disclosure, Phase 7 CORS |
| API9 Inventory |
Versioning, doc gating |
Pre-Testing Checklist |
| API10 Unsafe Consumption |
Response validation |
Phase 3 Input Injection (mirrored) |
| A03:2025 Supply Chain |
SUPPLY_CHAIN_CICD.md — pinning, SBOM |
Phase 6/8 (scripts/07, 09) |
| Secrets (CWE-798) |
SUPPLY_CHAIN_CICD.md — secrets hygiene |
Phase 9 (scripts/10) |
| LLM01:2025 / ASI (AI surface) |
AI_SECURITY.md — prompt isolation, tool authz |
Phase 10 (scripts/11) |
Quick Audit Cheat Sheet
Run these checks before deploying any API:
Framework-Specific Production Flags
| Framework |
Production Risk |
Check |
| FastAPI |
/docs, /redoc, /openapi.json exposed |
curl https://target/docs → should return 404 |
| Django |
DEBUG=True, ALLOWED_HOSTS=["*"] |
curl https://target/<nonexistent> → must not render Django traceback; python manage.py check --deploy clean |
| Flask |
app.debug=True, missing Flask-Talisman / CSRFProtect |
Inspect app.config; curl -I https://target/ must include HSTS + CSP |
| Gin |
Debug mode active |
GIN_MODE env var should be release |
| Fiber |
Prefork mode or Helmet missing |
Review middleware stack |
| Elysia |
Bun runtime exposes raw errors |
Verify global error handler is in place |
For detailed implementation patterns per framework, see references/DESIGN_CONTROLS.md. For active probes that exercise these flags, see references/TESTING_PHASES.md.
Workflow Recommendations
Greenfield API
- Read
references/DESIGN_CONTROLS.md end-to-end before writing the first endpoint.
- Pick framework section; copy auth/validation/rate-limit/CORS scaffolds.
- After MVP is functional, run
references/TESTING_PHASES.md Phase 1–7 against staging.
- File findings using
references/REPORT_TEMPLATE.md.
Existing API (audit / pre-release)
- Run
references/TESTING_PHASES.md Phase 1–7 against the target.
- For each finding, cross-reference the corresponding section in
references/DESIGN_CONTROLS.md to identify the missing or misconfigured control.
- Apply fix → re-run the specific phase to validate.
- File using
references/REPORT_TEMPLATE.md.
Bug Bounty / Pentest
- Pre-Testing Checklist in
references/TESTING_PHASES.md — confirm scope and authorization.
- Run all 7 phases; document each finding with
references/REPORT_TEMPLATE.md.
- Severity rubric (CVSS bands) in the same file.
Automated Probes (CI / Pre-Release)
Use scripts/ for hands-off execution:
cd skills/code-security-review/scripts/
export TARGET="https://api.staging.example.com"
export TOKEN_USER_A="..." TOKEN_USER_B="..." USER_A_RESOURCE_ID="42"
export ORIGIN_ALLOWED="https://app.example.com"
export I_HAVE_AUTHORIZATION=1
./run-all.sh # active phases 00–08 + static 09–11
# Static-only — no live target, no authorization needed (deps, CI, secrets, AI):
STATIC_ONLY=1 PROJECT_ROOT=. ./run-all.sh
Each phase from TESTING_PHASES.md has a script counterpart that emits findings as JSON-Lines (out/findings.jsonl) plus an aggregated Markdown report (out/report.md). Active phases (00–08) need an authorized TARGET; static phases (07 supply chain, 09 CI/CD, 10 secrets, 11 AI/LLM) read repository files and run without a target. The active prompt-injection battery in 11 stays gated by LLM_ENDPOINT + I_HAVE_AUTHORIZATION=1. Designed to gate CI on critical/high findings. See scripts/README.md for env vars and CI integration example.
Related Skills
@code-review — broader code-quality review that pairs with this skill for security-specific concerns. For Next.js performance audits, see @code-review references/NEXTJS.md.
For a formal verification standard, deep audits can map findings to OWASP ASVS 5.0 (17 chapters, levels 1–3); use it to set a coverage bar beyond the Top 10.
1---2name: code-security-review3description: Web/API security lifecycle for Go, Next.js, Python, and Bun — design controls, active testing, supply-chain/CI-CD, and LLM/agentic/MCP coverage. Maps to OWASP Web Top 10 2025 + API 2023 + LLM 2025 + Agentic 2026. Triggers: 'security review', 'revisão de segurança', 'auditar segurança', 'pentest', '/code-security-review'.4---56# Code Security Review78Lifecycle skill for REST and GraphQL APIs: covers **secure design** (controls to implement) and **active security testing** (payloads to validate those controls). One skill, two complementary modes — invoke whichever fits the current phase of work.910## When to Use1112Use this skill when:1314- **Designing** or hardening **FastAPI / Django / Flask** APIs (→ `references/python/`), **Gin / Fiber** APIs (→ `references/golang/`), or **Elysia** APIs (→ `references/DESIGN_CONTROLS.md`)15- **Reviewing** an existing API for security weaknesses against the OWASP Web Top 10 (2025) + API Top 10 (2023)16- **Pre-release security assessment** before deploying to production (→ `references/TESTING_PHASES.md`)17- **Bug bounty** engagements or **pentest** of an API target18- Implementing or auditing **AuthN/AuthZ** (JWT, OAuth 2.1, DPoP, API keys, RBAC/ABAC)19- Adding **rate limiting**, **input validation**, **CORS**, or **security headers**20- **Reporting** findings — use the standardized template in `references/REPORT_TEMPLATE.md`21- Consulting the **catalog of 100 web vulnerabilities** by category (→ `references/WEB_VULNERABILITIES.md`)22- Auditing **CI/CD + software supply chain** (GitHub Actions, lockfile pinning, secrets, SBOM) — A03:2025 (→ `references/SUPPLY_CHAIN_CICD.md`)23- Reviewing **LLM / agentic / MCP** features (prompt injection, tool misuse, AI-generated-code patterns) — OWASP LLM 2025 + Agentic 2026 (→ `references/AI_SECURITY.md`)2425This skill is **fully standalone** — every payload, snippet, and checklist needed lives in this directory.2627## How This Skill Is Organized2829| File / Directory | Use when |30| --- | --- |31| `SKILL.md` (this file) | Foundations, Phase 0 stack + surface detection, OWASP Web 2025 + API 2023 maps, AI/agentic pointer, audit cheat sheet |32| `references/DESIGN_CONTROLS.md` | Implementing or reviewing controls (proactive) — language-agnostic |33| `references/TESTING_PHASES.md` | Running 7-phase active testing workflow (reactive) — language-agnostic |34| `references/REPORT_TEMPLATE.md` | Documenting findings with consistent severity rubric |35| `references/WEB_VULNERABILITIES.md` | Reference catalog of 100 web vulnerabilities by category (XSS, CSRF, deserialization, mobile/IoT, etc.) |36| `references/golang/` | Go stack lifecycle (Gin/Fiber): `API.md`, `MIDDLEWARE.md`, `VULNERABILITIES.md`, `PATCHES.md`, `TESTING_PAYLOADS.md` |37| `references/python/` | Python stack lifecycle (FastAPI / Django / Flask, CPython 3.13/3.14): `API.md`, `CONFIGURATION.md`, `VULNERABILITIES.md`, `PATCHES.md`, `TESTING_PAYLOADS.md` |38| `references/nextjs/` | Next.js 16 App Router lifecycle: `API.md`, `CONFIGURATION.md`, `VULNERABILITIES.md`, `PATCHES.md`, `TESTING_PAYLOADS.md` |39| `references/SUPPLY_CHAIN_CICD.md` | A03:2025 deep-dive — dependency pinning, GitHub Actions hardening, secrets, SBOM, incident case studies |40| `references/AI_SECURITY.md` | LLM Top 10 2025, Agentic Top 10 2026, MCP security, prompt-injection controls, AI-generated-code review |41| `scripts/` | Executable probes — automate Phase 0–10 against a live target, or static phases (07/09/10/11) with `STATIC_ONLY=1`. See `scripts/README.md`. |4243## Phase 0 — Stack Detection4445Detect the language/framework before loading stack-specific references. Steps 1–4 pick **one** `$STACK` (stop at the first match). Step 5 runs **always** and adds orthogonal surface overlays — AI and CI are independent of the stack.4647```bash48# Step 1 — Go (Gin / Fiber)49test -f go.mod && grep -E 'gin-gonic/gin|gofiber/fiber/v[23]' go.mod && echo "stack: go"5051# Step 2 — Next.js 16+ App Router52test -f package.json && rg '"next":\s*"\^?1[6-9]' package.json && test -d app/ && echo "stack: nextjs-app"5354# Step 3 — Python (FastAPI / Django / Flask)55if test -f pyproject.toml || test -f requirements.txt || test -f setup.py; then56 rg -q '\bfastapi\b' pyproject.toml requirements*.txt 2>/dev/null && echo "stack: python (framework: fastapi)"57 rg -q '\bdjango\b' pyproject.toml requirements*.txt 2>/dev/null && echo "stack: python (framework: django)"58 rg -q '\bflask\b' pyproject.toml requirements*.txt 2>/dev/null && echo "stack: python (framework: flask)"59fi6061# Step 4 — Elysia / generic62test -f bun.lockb && rg 'elysia' package.json && echo "stack: elysia"6364# Step 5 — Surface overlays (always run, additive — not exclusive with the stack above)65rg -lq 'openai|@anthropic-ai/sdk|anthropic|langchain|llamaindex|litellm|ai-sdk|mcp' \66 package.json pyproject.toml requirements*.txt go.mod 2>/dev/null && echo "surface: ai-llm"67ls .mcp.json .cursor/mcp.json 2>/dev/null && echo "surface: mcp"68ls .github/workflows/*.y*ml 2>/dev/null && echo "surface: ci-cd"69```7071| `$STACK` | References to load (in addition to generic) | Notes |72| --- | --- | --- |73| `go` | `references/golang/{API,MIDDLEWARE,VULNERABILITIES,PATCHES,TESTING_PAYLOADS}.md` | Gin v1.10.1+, Fiber v2/v3, OWASP API 2023 + Go-specific (race, slowloris, `math/rand`, pprof, `ServeMux` conflicts) |74| `python` | `references/python/{API,CONFIGURATION,VULNERABILITIES,PATCHES,TESTING_PAYLOADS}.md` | FastAPI 0.115+, Django 5.x, Flask 3.x, CPython 3.13/3.14 — Pydantic Settings, ASGI middleware, pickle/yaml deserialization, JWT alg confusion, ALLOWED_HOSTS, SECRET_KEY, free-threaded 3.14t races |75| `nextjs-app` | `references/nextjs/{API,CONFIGURATION,VULNERABILITIES,PATCHES,TESTING_PAYLOADS}.md` | Next.js 16.2.x App Router — RSC, Server Actions, Route Handlers, `proxy.ts`, `"use cache"`, Image Optimizer |76| `elysia` / `generic` | `references/{DESIGN_CONTROLS,TESTING_PHASES,WEB_VULNERABILITIES,REPORT_TEMPLATE}.md` | Generic references cover the language-agnostic surface |7778The generic references (`DESIGN_CONTROLS.md`, `TESTING_PHASES.md`, `WEB_VULNERABILITIES.md`, `REPORT_TEMPLATE.md`) apply to **every** stack — load them in addition to the stack-specific bundle. Stack-specific references inherit the OWASP map and severity rubric from the generic ones; do not duplicate.7980Step 5 overlays are additive and combine with any `$STACK`:8182| Overlay | References to load | Scripts |83| --- | --- | --- |84| `ai-llm` / `mcp` | `references/AI_SECURITY.md` | `11-ai-llm-probes.sh` |85| `ci-cd` | `references/SUPPLY_CHAIN_CICD.md` | `09-cicd-workflows.sh`, `10-secrets-scan.sh` |8687## Security Foundations (Core Principles)8889These principles are language and framework agnostic:9091| Principle | Meaning |92| --- | --- |93| **Defence in Depth** | Multiple independent security layers — one failure should not compromise the system |94| **Least Privilege** | Every component and user gets only the minimum access needed |95| **Zero Trust** | Never assume a request is safe because it originates inside the network |96| **Shift Left** | Embed security checks in development and CI, not only in production monitoring |97| **Fail Secure** | On error, deny access rather than allow it |9899## OWASP Top 10:2025 (Web)100101The current Web list (final 2025 edition; replaces 2021). Use these tags for web findings; the API list below is a separate, still-current catalog.102103| # | Category | Key Risk |104| --- | --- | --- |105| **A01** | Broken Access Control | Missing/again-broken authz; **SSRF merged in** (was A10 in 2021) |106| **A02** | Security Misconfiguration | Moved up from #5 — debug on, permissive CORS, missing headers, defaults |107| **A03** | Software Supply Chain Failures | *Broadened* from "Vulnerable Components" — deps, build, CI, registries |108| **A04** | Cryptographic Failures | Weak/absent crypto, plaintext secrets, bad TLS |109| **A05** | Injection | SQL/NoSQL/command/XSS — untrusted input reaching an interpreter |110| **A06** | Insecure Design | Missing controls by design — no rate limit, no threat model |111| **A07** | Authentication Failures | Renamed — weak sessions, no brute-force protection, credential stuffing |112| **A08** | Software or Data Integrity Failures | Unsigned updates, insecure deserialization, untrusted CI artifacts |113| **A09** | Logging & Alerting Failures | Renamed — no audit trail, no alerting on abuse |114| **A10** | Mishandling of Exceptional Conditions | *New* — fail-open error handling, leaked stack traces, logic edge cases |115116### Changes from 2021117118- **New: A03 Software Supply Chain Failures** broadens the old "Vulnerable & Outdated Components" to the whole dependency→artifact path (see `references/SUPPLY_CHAIN_CICD.md`).119- **New: A10 Mishandling of Exceptional Conditions** — error-handling and fail-open logic become a first-class category.120- **SSRF merged into A01** Broken Access Control (was its own A10 in 2021).121- **Security Misconfiguration rose to #2.** Several categories renamed (Auth Failures, Logging & Alerting Failures).122123The OWASP **API** Top 10 below is a distinct list; its current edition is still **2023** (no 2025 API release).124125## OWASP API Security Top 10 (2023)126127This is the **2023 list** — the 2019 list is obsolete.128129| # | Vulnerability | Key Risk |130| --- | --- | --- |131| **API1** | Broken Object Level Authorization (BOLA) | Attacker accesses another user's resources by changing an ID |132| **API2** | Broken Authentication | Weak tokens, missing expiry, no brute force protection |133| **API3** | Broken Object Property Level Authorization | Over-fetching (returning private fields) or mass assignment (accepting unexpected fields) |134| **API4** | Unrestricted Resource Consumption | No rate limiting — DoS, cost amplification, brute force |135| **API5** | Broken Function Level Authorization (BFLA) | Regular users can call admin functions |136| **API6** | Unrestricted Access to Sensitive Business Flows | Automated abuse of checkout, account creation, voting |137| **API7** | Server-Side Request Forgery (SSRF) | *New in 2023* — server makes requests to attacker-controlled URLs |138| **API8** | Security Misconfiguration | Debug mode in prod, permissive CORS, missing headers, default creds |139| **API9** | Improper Inventory Management | Shadow APIs, deprecated versions, undocumented endpoints |140| **API10** | Unsafe Consumption of APIs | *New in 2023* — trusting third-party API responses without validation |141142### Changes from 2019143144- **Removed as separate items**: "Excessive Data Exposure" and "Mass Assignment" — merged into API3 (Broken Object Property Level Authorization)145- **Renamed**: "Lack of Resources and Rate Limiting" → API4 "Unrestricted Resource Consumption"146- **Added**: API7 SSRF and API10 Unsafe Consumption of APIs147148## AI / LLM & Agentic Surface149150When Phase 0 Step 5 flags `ai-llm`, `mcp`, or the code drives LLMs / agents, the web+API catalogs are necessary but not sufficient. Three additional catalogs apply:151152- **OWASP Top 10 for LLM Applications 2025** (`LLM01:2025` Prompt Injection … `LLM10:2025` Unbounded Consumption) — for any LLM-integrated app.153- **OWASP Top 10 for Agentic Applications 2026** (`ASI01:2026` Agent Goal Hijack … `ASI10:2026` Rogue Agents) — for code that acts via tools, runs multi-step, or talks to other agents.154- **OWASP GenAI MCP guides** (Secure MCP Server Development; Securely Using Third-Party MCP Servers) — for projects wiring Model Context Protocol servers.155156Full tables, controls, AI-generated-code review checklist, and testing payloads in `references/AI_SECURITY.md`. Static + gated active probes in `scripts/11-ai-llm-probes.sh`.157158## OWASP → Phase Map159160| OWASP Item | Design (`DESIGN_CONTROLS.md`) | Testing (`TESTING_PHASES.md`) |161| --- | --- | --- |162| API1 BOLA | Authorization patterns | Phase 2.2 Cross-User Access |163| API2 Broken Auth | JWT/OAuth 2.1/DPoP | Phase 1 Authentication Testing |164| API3 BOPLA | DTOs, mass assignment guards | Phase 2.3 Over-Fetching, Phase 2.4 Mass Assignment |165| API4 Unrestricted Consumption | Rate limit algorithms | Phase 4 Rate Limiting Testing |166| API5 BFLA | RBAC enforcement | Phase 2.5 Admin Endpoints |167| API6 Sensitive Flows | Anti-abuse + MFA | Phase 4.5 Brute Force |168| API7 SSRF | URL allowlist | Phase 3.4 SSRF Payloads |169| API8 Misconfiguration | Headers, CORS, debug-off | Phase 5 Info Disclosure, Phase 7 CORS |170| API9 Inventory | Versioning, doc gating | Pre-Testing Checklist |171| API10 Unsafe Consumption | Response validation | Phase 3 Input Injection (mirrored) |172| A03:2025 Supply Chain | `SUPPLY_CHAIN_CICD.md` — pinning, SBOM | Phase 6/8 (`scripts/07`, `09`) |173| Secrets (CWE-798) | `SUPPLY_CHAIN_CICD.md` — secrets hygiene | Phase 9 (`scripts/10`) |174| LLM01:2025 / ASI (AI surface) | `AI_SECURITY.md` — prompt isolation, tool authz | Phase 10 (`scripts/11`) |175176## Quick Audit Cheat Sheet177178Run these checks before deploying any API:179180- [ ] **Auth required**: every non-public endpoint returns `401` without a valid token181- [ ] **Authorization checked**: resource ownership verified before returning or modifying data (BOLA)182- [ ] **CORS explicit**: no `allow_origins=["*"]` + `allow_credentials=True` combination183- [ ] **Input validated**: all request bodies/params validated against a schema with strict types184- [ ] **Parameterized queries**: no string concatenation in SQL/database calls185- [ ] **Rate limiting active**: auth endpoints ≤ 5 req/15 min; general API ≤ 100 req/min186- [ ] **Error messages generic**: no stack traces or internal details in `4xx`/`5xx` responses187- [ ] **Security headers present**: `HSTS`, `X-Content-Type-Options`, `X-Frame-Options`, `CSP`188- [ ] **Dependencies audited**: `pip-audit` / `govulncheck` / `bun audit` / `osv-scanner` passing in CI; lockfiles committed (A03:2025)189- [ ] **No debug mode in production**: FastAPI `app = FastAPI(docs_url=None)`, Gin `gin.SetMode(gin.ReleaseMode)`, Fiber `app := fiber.New()`190- [ ] **CI/CD hardened**: GitHub Actions pinned by 40-hex SHA (not tags); no `pull_request_target` + PR-head checkout; `zizmor` clean191- [ ] **No committed secrets**: `gitleaks` / `trufflehog` clean over tree + history192- [ ] **AI/LLM surface safe**: system prompt isolated from user input; LLM output encoded before any sink; MCP servers version-pinned193194## Framework-Specific Production Flags195196| Framework | Production Risk | Check |197| --- | --- | --- |198| FastAPI | `/docs`, `/redoc`, `/openapi.json` exposed | `curl https://target/docs` → should return 404 |199| Django | `DEBUG=True`, `ALLOWED_HOSTS=["*"]` | `curl https://target/<nonexistent>` → must not render Django traceback; `python manage.py check --deploy` clean |200| Flask | `app.debug=True`, missing `Flask-Talisman` / `CSRFProtect` | Inspect `app.config`; `curl -I https://target/` must include HSTS + CSP |201| Gin | Debug mode active | `GIN_MODE` env var should be `release` |202| Fiber | Prefork mode or Helmet missing | Review middleware stack |203| Elysia | Bun runtime exposes raw errors | Verify global error handler is in place |204205For detailed implementation patterns per framework, see `references/DESIGN_CONTROLS.md`. For active probes that exercise these flags, see `references/TESTING_PHASES.md`.206207## Workflow Recommendations208209### Greenfield API2102111. Read `references/DESIGN_CONTROLS.md` end-to-end before writing the first endpoint.2122. Pick framework section; copy auth/validation/rate-limit/CORS scaffolds.2133. After MVP is functional, run `references/TESTING_PHASES.md` Phase 1–7 against staging.2144. File findings using `references/REPORT_TEMPLATE.md`.215216### Existing API (audit / pre-release)2172181. Run `references/TESTING_PHASES.md` Phase 1–7 against the target.2192. For each finding, cross-reference the corresponding section in `references/DESIGN_CONTROLS.md` to identify the missing or misconfigured control.2203. Apply fix → re-run the specific phase to validate.2214. File using `references/REPORT_TEMPLATE.md`.222223### Bug Bounty / Pentest2242251. Pre-Testing Checklist in `references/TESTING_PHASES.md` — confirm scope and authorization.2262. Run all 7 phases; document each finding with `references/REPORT_TEMPLATE.md`.2273. Severity rubric (CVSS bands) in the same file.228229### Automated Probes (CI / Pre-Release)230231Use `scripts/` for hands-off execution:232233```bash234cd skills/code-security-review/scripts/235export TARGET="https://api.staging.example.com"236export TOKEN_USER_A="..." TOKEN_USER_B="..." USER_A_RESOURCE_ID="42"237export ORIGIN_ALLOWED="https://app.example.com"238export I_HAVE_AUTHORIZATION=1239./run-all.sh # active phases 00–08 + static 09–11240241# Static-only — no live target, no authorization needed (deps, CI, secrets, AI):242STATIC_ONLY=1 PROJECT_ROOT=. ./run-all.sh243```244245Each phase from `TESTING_PHASES.md` has a script counterpart that emits findings as JSON-Lines (`out/findings.jsonl`) plus an aggregated Markdown report (`out/report.md`). Active phases (00–08) need an authorized `TARGET`; static phases (`07` supply chain, `09` CI/CD, `10` secrets, `11` AI/LLM) read repository files and run without a target. The active prompt-injection battery in `11` stays gated by `LLM_ENDPOINT` + `I_HAVE_AUTHORIZATION=1`. Designed to gate CI on critical/high findings. See `scripts/README.md` for env vars and CI integration example.246247## Related Skills248249- `@code-review` — broader code-quality review that pairs with this skill for security-specific concerns. For Next.js performance audits, see `@code-review` `references/NEXTJS.md`.250251For a formal verification standard, deep audits can map findings to **OWASP ASVS 5.0** (17 chapters, levels 1–3); use it to set a coverage bar beyond the Top 10.