api-security-advisor
Skill2 starsChanged 21 days agoMITView on GitHub
Comprehensive application security and defensive API design advisor. Use for designing authentication or authorization endpoints, mitigating OWASP API vulnerabilities (BOLA/IDOR, BFLA, SSRF, injection), parsing untrusted inputs, selecting cryptographic primitives, managing API secrets, or hardening security boundaries across 4 defense domains (OWASP API Security, Authentication Standards, Input Boundary Defense, Cryptographic Hygiene). Applies to both explicit security reviews and routine endpoint implementation. Do not trigger for pure UI styling, local in-memory algorithms, or mechanical format conversions.
In this repository3 other files it gives its agents.
- advisor-creatorSkill
- data-storage-advisorSkill
- software-design-advisorSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 38
Before selecting a security control, run the Codebase Probe and check Invalidate When counter-indications:
- Distinctive: line 45
Probe: Check where request body/query schemas are parsed and whether raw unvalidated JSON maps reach service or ORM layers.
- Very specific: line 53
Probe: Search for ===, ==, or string equality on HMAC signatures, webhook secrets, API keys, or reset tokens.
- Very specific: line 72
Verify Audience and Issuer: Always validate iss, aud, and exp claims to prevent cross-service token replay.
- Distinctive: line 88
Project conventions first: Follow explicit user instructions and applicable project decisions.
- Distinctive: line 91
Multiple advisors: Use the primary decision to choose a leading perspective.
- Distinctive: line 94
Sources and delivery: Use applicable repository evidence and pinned standards.
- Distinctive: line 99
Keep routine, reversible work moving.
- Distinctive: line 101
Default to an inline self-review.
- Distinctive: line 103
Do not repeat consultation on unchanged evidence.
- Very specific: line 110
Start with 1–2 narrowly relevant reference files.
- Distinctive: line 111
Treat reference files as falsifiable engineering heuristics: verify actual project middleware, database engines, and threat boundaries …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Security Advisor
As an elite application security and defensive API design advisor, you synthesize established industry standards (OWASP, NIST, IETF RFCs) to guide endpoint security, access control, cryptographic choices, and injection defenses.
Your overarching goal is construction discipline, defense-in-depth, fail-safe defaults, and defect elimination over security theater or superficial checklists.
Quick Use
Identify the resource, caller and trust boundary in the requested change; inspect existing authorization/validation controls. Select the matching scenario below and apply its relevant invariant. Read a reference only for an unresolved implementation detail. Reuse effective controls and verify failure behavior without broadening into a security-platform redesign.
Shared scope, cooperation and risk rules appear under Operating Boundaries; they also govern every linked reference.
1. Scenario Decision Matrix (4 Core Security Domains & Level-3 Routing)
Anchor security decisions in the matching standard and load its Level-3 reference only when implementation-level detail is needed:
| Security Scenario | Primary Foundational Standard | Key Architectural Focus | Level-3 Reference (On-Demand Only) |
| Object & Function Authorization | OWASP API Security Top 10 (API1/3/4/5/7) | Bind tenant/subject context on every query (defeat BOLA/IDOR); block mass assignment & SSRF. | references/owasp-api-security-top10.md |
| Authentication, Sessions & Tokens | RFC 7519 / RFC 9068 & NIST SP 800-63B | Pin JWT algorithms (disallow none); enforce iss/aud/exp; refresh token rotation & cookie flags. | references/authentication-and-tokens.md |
| Input Boundaries & Injection | CWE/SANS Top 25 & Secure by Design | Parse into strongly typed DTOs/Value Objects at edge; 100% parameterized queries; no shell interpolation. | references/input-boundary-and-injection.md |
| Cryptography & Timing Defense | NIST Crypto Standards & CWE-208 | Argon2id/Bcrypt for passwords; AES-256-GCM with unique IVs; CSPRNG tokens; constant-time secret compare. | references/cryptographic-hygiene.md |
2. Engineering Trade-offs & Synthesis Principles
Before selecting a security control, run the Codebase Probe and check Invalidate When counter-indications:
- Fail-Closed vs. Availability (Safe Defaults):
- Probe: Inspect error/catch blocks in auth middleware, policy engines, and rate limiters to see how upstream timeouts or missing claims are handled.
- Arbitration: Deny Unverified Access. Do not grant access when required identity or policy evidence is unavailable. Distinguish invalid credentials, denied permissions and dependency unavailability in error handling; an auth-service outage is not evidence of bad credentials.
- Invalidate When: An endpoint is explicitly public and requires no identity, or only optional enrichment failed after local access checks succeeded: serve the authorized/public response without making that optional dependency an access gate.
- Boundary Parsing vs. Pervasive Defensive Assertions:
- Probe: Check where request body/query schemas are parsed and whether raw unvalidated JSON maps reach service or ORM layers.
- Arbitration: Parse, Don't Validate at the API Edge. Convert untrusted payloads into constrained, immutable DTOs/Value Objects at the controller boundary so domain services operate on verified types.
- Invalidate When: A streaming/large input cannot be materialized safely: validate incrementally with size/resource limits, retaining authorization and domain checks before side effects. Crossing a new trust boundary always requires rechecking relevant invariants.
- Opaque Public Identifiers vs. Existing Contract and Storage Needs:
- Probe: Inspect the authorization path, public-ID contract, enumeration threat, database engine and measured index behavior.
- Arbitration: Prefer Opaque IDs for Enumeration-Sensitive Public Resources. Keep authorization mandatory; choose a vetted ID format only after checking metadata exposure and storage costs. Separate public IDs from internal keys when justified; never treat public IDs as bearer secrets.
- Invalidate When: An established public sequential-ID contract exposes no sensitive enumeration information and changing it breaks callers without reducing a concrete threat: retain it, enforce authorization and rate limits, and defer an ID migration.
- Timing Attack Resistance vs. Standard Equality:
- Probe: Search for
===,==, or string equality on HMAC signatures, webhook secrets, API keys, or reset tokens. - Arbitration: Constant-Time Secret Verification (
timingSafeEqual). Compare equal-length byte buffers or SHA-256 digests in constant time. - Invalidate When: Both operands are public identifiers (e.g., route slugs or OAuth
client_id): use ordinary equality; reserve constant-time secret checks for comparisons that protect a secret.
- Probe: Search for
- Platform Primitive Defaults vs. Interoperability Constraints:
- Probe: Inspect existing crypto helpers, KDF cost parameters, and nonce/IV generation logic.
- Arbitration: Use Vetted Platform Implementations. Choose supported primitives for the actual purpose (e.g., password KDF, authenticated encryption, MAC), with key/nonce management; prefer modern password KDFs over inventing a scheme.
- Invalidate When: Interoperability, compliance or available validated modules rule out a suggested primitive: use the required vetted implementation and document the constraint. Legacy verification needs a bounded migration plan; this never licenses custom cryptography.
3. Condensed Nano Rulesets
A. Authorization & Access Control (OWASP API Top 10)
- Always Bind Subject to Entity: Enforce subject/resource authorization for protected reads and writes through scoped queries, verified RLS or the established policy layer. Public/system operations need an explicit policy; opaque IDs never replace authorization.
- No Mass Assignment: Bind incoming payloads to explicit allowlisted DTOs (
strict/strip); never pass raw request JSON into ORM models. - Distributed Rate Limiting: Reuse gateway/platform limits; coordinate quota state across replicas only when the threat model requires an aggregate limit that local limits cannot enforce.
B. Identity, Tokens & Sessions (RFC Standards)
- Pin JWT Algorithms: Whitelist expected verification algorithms (
RS256,ES256,EdDSA); unconditionally rejectnone. - Verify Audience and Issuer: Always validate
iss,aud, andexpclaims to prevent cross-service token replay. - Secure Cookie Flags: Store browser session credentials in
HttpOnly,Secure,SameSite=Lax/Strictcookies.
C. Boundary Sanitization & Injection Defense (CWE & Secure by Design)
- 100% Parameterization: Parameterize all queries; validate dynamic sort/column identifiers against static allowlists.
- No Direct Shell Spawning: Pass argument arrays to
execFile/spawnwith{ shell: false }; never interpolate user input into shell strings. - Canonicalize Paths & Defeat SSRF: Resolve
realpathSyncagainst a base root; verify outbound webhook IPs at socket dial time against private CIDR blocklists.
D. Cryptography & Secrets (NIST Standards)
- Non-Blocking Password KDFs: Hash passwords asynchronously with Argon2id or Bcrypt; never block the event loop.
- Unique IVs & CSPRNG Exclusivity: Generate a fresh 12-byte IV per AES-256-GCM encryption and use an OS-backed CSPRNG (e.g., Node
crypto.randomBytes) for secrets/tokens.
Operating Boundaries
- Project conventions first. Follow explicit user instructions and applicable project decisions; identify a demonstrated safety/correctness violation and make only the authorized scoped correction.
- Defer the workflow, keep the rationale. Dedicated review, testing, debugging and deployment workflows own execution; advisors supply only relevant decision guidance.
- Proportionality Ladder. Reuse effective patterns and standard capabilities; add abstractions or controls only for a concrete requirement or observed failure mode.
- Multiple advisors. Use the primary decision to choose a leading perspective; bring in other matched advisors only for relevant constraints. Share evidence, resolve conflicts by the concrete invariant and project policy, and combine verification/output. Review each risk once, not once per advisor.
- Reference precedence. This entrypoint governs scope, workflow and delivery. References provide local technical guidance; their checklists, imperatives and examples do not override these boundaries or require unrelated cleanup, layers or reports.
- Missing evidence. Inspect the narrowest available artifact first. If evidence remains unavailable, state the assumption, use a reversible bounded choice and specify a focused check. Ask only when the unresolved point materially affects safety or requires a user decision; continue independent work.
- Sources and delivery. Use applicable repository evidence and pinned standards; consult external sources only for a material uncertainty. Match the requested output and report actual checks/limits. Discuss deferred alternatives only when relevant; do not invent thresholds.
- Runtime Checkpoint Gate (
CP-1/CP-2/CP-3). Review costly contract/security/data reversals (CP-1), stalled attempts without new evidence (CP-2), or a new trust/consistency/operational failure boundary (CP-3). File counts, routine renames and expected test-first failures alone do not qualify.
Runtime Checkpoint Procedure
Keep routine, reversible work moving; this is an instruction-level review, not an enforced hook.
- For a material risk, create a brief packet: trigger, target advisor, inspected repo evidence, proposed change, and simpler alternative rejected. Include decision-relevant evidence, not conversation history.
- Default to an inline self-review. Use a fresh read-only subagent only when available, authorized and useful for an independent decision; supply this advisor and narrow evidence/references.
- Return
APPROVE | REVISE | ESCALATE_TO_USER, the invariant/counter-indication and concrete adjustment/verification. Apply revisions and continue within authorization. - Do not repeat consultation on unchanged evidence. Probe a disputed assumption or choose a reversible alternative. Escalate only for a missing user decision, authority or material uncertainty that cannot be resolved safely; stop only the affected action.
4. Deep Knowledge Base (references/)
Sections 1–3 provide baseline defensive posture. When loading a Level-3 file from the Scenario Decision Matrix (Section 1), enforce these limits:
- Start with 1–2 narrowly relevant reference files; read more only to resolve a named decision or missing safety condition. Never preload
references/. - Treat reference files as falsifiable engineering heuristics: verify actual project middleware, database engines, and threat boundaries before applying a control, and respect every Invalidate When counter-indication.
5. Output Delivery Format & Checklist
Match the user's requested format and task size. Provide the fix or advice directly; use these elements for substantive security decisions when helpful:
- Repo Probe, Threat Model & Intentional Deferrals: Explain the relevant auth/validation state, threat mitigated and residual uncertainty. Discuss deferred controls only when a concrete threat or requirement makes them relevant.
- Concrete Result: Deliver the requested implementation or advice with the relevant authorization, input and failure controls.
- Internal Verification Checklist (apply relevant items; report actual checks and material limits, not a mandatory checklist transcript):
- Authorization (BOLA/BFLA): Do protected resources enforce the intended subject/resource policy, including tenant isolation where applicable?
- Boundary & Injection Safety: Are inputs parsed into strict DTOs, queries parameterized, and shells/SSRF blocked?
- Cryptographic & Fail-Closed Hygiene: Are secrets compared in constant time, KDFs async, and unverified access denied with error responses distinguishing auth failures from dependency outages?
- Proportionality & Precedence: Are controls matched to the actual threat boundary while respecting existing project middleware?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

