Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Hardened API Defense Playbook

    1

    Lock down every API request with five enforcement gates: identity, authorization, input contracts, quotas, and safe non-leaking failures.

    Free

    1 useSecurity scanned
    Hardened API Defense Playbook

    Hardened API Defense Playbook

    Example session with this skill installed

    Our team ships a Node/Express B2B payments API with 14 endpoints, a React dashboard, and a partner-facing GraphQL gateway. The pen test is in three weeks and we already know invoices/:id lets a caller pass any ID. Review the routes under src/routes and src/middleware, then produce a hardening plan using the five-gate model: fix auth and refresh-token rotation, add object-level authorization middleware, strict payload schemas, and rate plus cost limits for login and exports. Show me the exact middleware code to drop in and a prioritized checklist my juniors can execute this sprint.

    • Read your context and instructions
    • Compiled the hardened api defense

    Summary

    Applied the five-gate model to the payments API (14 endpoints). Fixed an IDOR on /api/invoices/:id, replaced the 30-day JWT with 10-minute access tokens plus rotating refresh tokens, and added per-actor cost quotas on exports.

    GateBeforeAfter
    Identity30-day JWT, alg not pinned10-min HS256, issuer+audience validated, hashed refresh families
    AuthorizationClient userId trustedOwnership/tenant middleware, deny by default
    InputUnbounded JSON, no schemaZod .strict() schemas, 100 kb body cap
    AbuseSingle global limiter8/min login, 120/min API, 500 cost-units/min export guard
    FailureStack traces in 500sRequest-ID logs, generic code payloads, allowlisted CORS

    Next steps

    • Deploy the refresh-token revocation job before the audit
    • Add WAF rules for /api/auth/* floods
    • Re-run the gate checklist on webhook callbacks in two weeks

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Exposed APIs are the primary vector for data breaches and resource abuse. This skill provides a systematic framework for securing REST, GraphQL, and WebSocket interfaces by implementing a five-gate defense strategy. It moves beyond basic authentication to enforce strict object-level authorization, input validation, and cost-based rate limiting.

    What it does

    • Identity Enforcement implements short-lived access tokens and revocable refresh token families to minimize session hijacking risks.
    • Granular Authorization ensures every request is checked for ownership, tenant isolation, and functional permissions at the object level.
    • Contract Validation enforces strict request schemas using tools like Zod to reject malformed payloads, unknown fields, and oversized inputs.
    • Abuse Prevention applies multi-layered rate limiting based on request count and computational cost to protect against DoS and resource exhaustion.
    • Secure Failure Handling standardizes error responses to prevent information leakage of stack traces or internal system architecture.

    How it works

    1. Gate Sequencing routes every incoming request through five sequential checks: Identity, Authorization, Input Contract, Abuse Control, and Transport.
    2. Resource Loading uses specialized middleware to resolve resource ownership before any business logic executes.
    3. Cost Guarding tracks the computational weight of requests (like PDF exports or heavy searches) to apply tighter quotas on expensive operations.
    4. Realtime Hardening applies origin validation and message-size limits to long-lived WebSocket connections.

    Frameworks & tools

    The implementation logic uses Node.js, Express, and Redis. It relies on jsonwebtoken for identity, zod for schema enforcement, helmet for security headers, and rate-limit-redis for distributed abuse control.

    Why this beats prompting it yourself

    Generic prompts often overlook the "broken object-level authorization" (BOLA) risks that plague modern APIs. This skill provides production-ready middleware patterns that handle edge cases like refresh token rotation and GraphQL query depth that standard LLM outputs typically miss.

    Use cases

    • Hardening a public-facing SaaS API against automated scraping and credential stuffing.
    • Implementing multi-tenant isolation for enterprise B2B applications.
    • Protecting expensive AI or data-processing endpoints from budget-draining abuse.
    • Preparing an API surface for professional penetration testing or SOC2 compliance.

    Known limitations

    This skill focuses on application-layer defenses. It does not cover infrastructure-level WAF configuration, OS-level hardening, or specific database encryption-at-rest implementations.

    Code samples are Node/Express-flavored and need porting for other runtimes. It guides design and remediation; it does not scan or penetration-test a live server.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    1 use

    Times used to date

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    • Free with an Agensi account

    Permissions

    Environment Variables
    Read Files
    Write Files

    File Scopes

    src/**
    middleware/**
    routes/**

    The skill only reads your API source and writes hardened middleware or plan files locally; it needs no network access or credentials.

    Listed1 month ago

    What's inside

    Frequently Asked Questions

    This playbook secures REST, GraphQL, and WebSocket APIs using a five-gate framework that addresses critical vulnerabilities like Broken Object Level Authorization (BOLA) and resource exhaustion that standard authentication often misses.

    The skill provides production-ready Node.js middleware logic, schema templates using Zod, and Redis-backed rate limiting configurations designed to be integrated into your existing Express-based backend.

    Yes, the 'Cost Guarding' feature is specifically designed to assign weights to resource-heavy operations like PDF generation or AI inference, allowing you to set stricter limits on expensive requests compared to standard data fetches.

    While the core logic is optimized for Node.js and Express environments, the five-gate architectural principles and schema validation strategies can be adapted to other frameworks by an experienced developer.

    This skill focuses on the application layer; it does not manage infrastructure-level tools like Web Application Firewalls (WAF), database-level encryption, or VPC configurations.

    No. It is a defense playbook your agent applies to your codebase: it reviews endpoints gate by gate and produces fixes, middleware code, and a prioritized remediation checklist.

    The five-gate model is stack-agnostic, and the ready-to-adapt middleware samples target Node.js/Express using Zod, jsonwebtoken, helmet, and Redis-backed rate limiting.

    No. The skill operates entirely on local files, nothing leaves your machine, and it installs into any SKILL.md-compatible agent.

    New in APIs & Backend

    Free