本文へ移動
cccskills
無料GitHub で公開

api-security-checklist

Use when you add or change an endpoint, an auth check, a query by id, an outbound call to a user-supplied URL, file handling, or anything touching credentials — the OWASP API Top 10 (2023) as concrete Go and Java checks

インストール方法を見る

含まれるファイル(1)

  • SKILL.md6.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

API Security Checklist

Overview

The OWASP API Security Top 10 (2023 edition, still current) orders API risk by how often it actually bites in production. This skill maps each category to a concrete Go/Java check instead of a paragraph of theory — see https://owasp.org/API-Security/editions/2023/en/0x11-t10/ for the source list.

Core principle: the most common API vulnerability is a lookup by id with no ownership check. Assume every id in a URL or body is adversarial.

API1: Broken Object-Level Authorization (BOLA)

The #1 API risk. A lookup that trusts the id alone instead of scoping it to the caller.

// ❌ anyone who guesses/enumerates an id can read or modify it
task, err := repo.Get(ctx, taskID)

// ✅ scoped to the caller/tenant exactly like its neighbours
task, err := repo.GetForOwner(ctx, taskID, ownerIDFromAuth(ctx))

Answer "not yours" the same way the endpoint's neighbours do — usually 404 (don't reveal existence to a non-owner) unless the repo already standardizes on 403. Test it: a second, different authenticated user requesting the first user's object must get the not-yours response, not the object.

API2: Broken Authentication

  • New routes go in the SAME middleware group as their neighbours (Fiber: api := app.Group("/api", authMW), never a bare app.Post outside it; Spring: match the route in the existing SecurityFilterChain; Quarkus: @RolesAllowed/@Authenticated).
  • Compare secrets/tokens with crypto/subtle.ConstantTimeCompare, never == (timing attack on string comparison).
  • Generate tokens with crypto/rand, never math/rand.

API3: Broken Object Property-Level Authorization (BOPLA — mass assignment / excessive data exposure)

  • The request DTO lists only the fields a client may set — never bind a request body directly onto a domain/entity struct that also has role, owner_id, is_admin, etc. If the DTO doesn't have the field, the client can't set it.
  • The response DTO lists only the fields a client may read — no password_hash, no internal ids, no other users' data riding along in a list response. Go: unexported fields or explicit response structs, never json:"-" as the only defense on a type that's also bound from requests. Java: a dedicated response record, never the JPA entity.

API4: Unrestricted Resource Consumption

  • Body size limit: fiber.Config{BodyLimit: ...} (default 4 MB) or http.MaxBytesReader — don't rely on the framework default alone for upload endpoints.
  • List endpoints have a maximum page size, not just a default (api-design-conventions).
  • Server read/write timeouts and outbound client timeouts are set explicitly (resilient-io-and-jobs) — an unbounded request or unbounded upstream call is a resource-consumption hole.
  • File uploads stream with a size cap rather than buffering the whole body in memory.

API5: Broken Function-Level Authorization

Admin/privileged routes are behind an explicit role check, not just "authenticated" — verify the route's authorization matches its actual privilege level, not just that some auth middleware ran.

API6: Unrestricted Access to Sensitive Business Flows

Rate-limit a sensitive flow (password reset, bulk export, payment) the same way its neighbours already do; don't ship a new sensitive endpoint with no rate limit when similar ones have one.

API7: Server-Side Request Forgery (SSRF)

Any endpoint that fetches a user-supplied URL (webhooks, image-by-URL, link previews):

  • Allowlist the scheme (https only, usually) and, where feasible, the host.
  • Resolve the host and reject private/loopback/link-local ranges (127.0.0.0/8, 10.0.0.0/8, 169.254.0.0/16, ::1, etc.) before connecting.
  • Disable automatic redirect following, or re-validate the target after each redirect: Go http.Client{CheckRedirect: func(...) error { return http.ErrUseLastResponse }}.

API8: Security Misconfiguration

  • No Access-Control-Allow-Origin: * combined with Access-Control-Allow-Credentials: true.
  • No stack traces, SQL errors, or internal paths in an error response (api-design-conventions — the error mapper owns this).
  • Debug/profiling endpoints (pprof, actuator internals) are not exposed the same way in a deployed environment as in dev.

API9: Improper Inventory Management

Keep the OpenAPI document in sync (api-contract-openapi) — an undocumented or "quietly removed" endpoint is still reachable until it's actually gone.

API10: Unsafe Consumption of APIs

Validate and size-limit third-party API responses before trusting them; apply the same timeout/retry discipline to outbound calls as to your own endpoints (resilient-io-and-jobs).

Beyond the Top 10

  • SQL/command injection: parameterized queries always; exec.Command(name, arg1, arg2) with separate arguments, never a shell string built from user input.
  • Path traversal: os.Root (Go ≥1.24) when serving files from a directory by user-supplied name.
  • Secrets: only from env or a secret manager, never hardcoded, never on argv, never in logs (also a monorepo-wide rule).
  • Passwords: bcrypt or argon2id, never a fast general-purpose hash.

Commands

  • go vet ./...
  • go run golang.org/x/vuln/cmd/govulncheck@latest ./... — does not modify go.mod, safe to run anytime.
  • go test -race ./...
  • Java: run whatever dependency-vulnerability check the repo already wires into its build; don't add a new one.

Common Mistakes

  • A lookup-by-id endpoint with no ownership/tenant filter.
  • Binding a request body straight onto an entity with privileged fields.
  • A new sensitive endpoint shipped with no rate limit when its neighbours have one.
  • An image/webhook-by-URL feature with no private-IP block.
  • A stack trace or SQL error string reaching the client.

Red Flags

  • WHERE id = $1 with no second predicate on an endpoint scoped to a caller.
  • A DTO that's reused for both request binding and response serialization on a type with sensitive fields.
  • http.Get(userSuppliedURL) with no scheme/host check beforehand.
  • A new route registered outside the app's auth middleware group.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Use when writing acceptance criteria for a task - express each as an observable Given/When/Then that QA can execute, including negative cases

日本語の概要は準備中です。原文の説明を表示しています。

makifbaysal/tasktrooper1122026年10月10日 更新

Use when the diff adds or changes an endpoint, resolver, RPC, job or query that takes an object id, a role check, a request binding or a tenant filter - BOLA/IDOR, function-level authorization, mass assignment and tenant scoping

日本語の概要は準備中です。原文の説明を表示しています。

makifbaysal/tasktrooper1122026年10月10日 更新

Use on every UI change - semantic HTML, labels for controls, keyboard-navigable dialogs/menus, visible focus, and never color as the only signal

日本語の概要は準備中です。原文の説明を表示しています。

makifbaysal/tasktrooper1122026年10月10日 更新

Use when a task changes any screen, form, dialog, menu or control - Lighthouse/axe scan of the changed screens, a keyboard walk, and the thresholds that fail a task

日本語の概要は準備中です。原文の説明を表示しています。

makifbaysal/tasktrooper1122026年10月10日 更新

How to work a task returned with review, QA or UAT findings. Use when a task is in need_revision or PR review comments are in your context.

日本語の概要は準備中です。原文の説明を表示しています。

makifbaysal/tasktrooper1122026年10月10日 更新

Use when deciding whether a request needs an analiz task before implementation - the conditions that require the architect's analysis versus going straight to implementation

日本語の概要は準備中です。原文の説明を表示しています。

makifbaysal/tasktrooper1122026年10月10日 更新

makifbaysal のスキルをすべて見る

このスキルの問題を報告する