| name | api-security-auditor |
| description | API Security auditing mastery. Rate limiting architecture, API key management, payload validation, IDOR (Insecure Direct Object Reference) prevention, mass assignment flaws, GraphQL security, and server-side mitigations. Use when building external APIs, B2B services, or reviewing endpoint security. |
| allowed-tools | Read, Write, Edit, Glob, Grep |
| version | 2.0.0 |
| last-updated | "2026-04-02T00:00:00.000Z" |
| applies-to-model | gemini-2.5-pro, claude-3-7-sonnet |
| routing | {"domain":"general","tier":"basic"} |
API Security Auditor — Endpoint Hardening Mastery
Insecure Direct Object Reference (IDOR)
IDOR occurs when an application provides direct access to objects based on user-supplied input without authorization checks.
app.get("/api/receipts/:id", async (req, res) => {
const receipt = await db.receipts.findById(req.params.id);
res.json(receipt);
});
app.get("/api/receipts/:id", async (req, res) => {
const receipt = await db.receipts.findById(req.params.id);
if (!receipt) return res.status(404).send();
if (receipt.userId !== req.user.id && req.user.role !== "admin") {
return res.status(403).json({ error: "Access denied" });
}
res.json(receipt);
});
Mass Assignment (Overposting)
Occurs when web frameworks automatically bind HTTP request parameters to application models without filtering.
app.put("/api/users/:id", async (req, res) => {
await db.users.update({ id: req.params.id }, req.body);
res.send("Updated");
});
app.put("/api/users/:id", async (req, res) => {
const { name, email, bio } = req.body;
const safeData = { name, email, bio };
await db.users.update({ id: req.params.id }, safeData);
res.send("Updated");
});
const UpdateUserSchema = z
.object({
name: z.string().min(2),
email: z.string().email(),
})
.strict();
Rate Limiting Architecture
import rateLimit from "express-rate-limit";
import RedisStore from "rate-limit-redis";
export const globalLimiter = rateLimit({
store: new RedisStore({ client: redisClient }),
windowMs: 15 * 60 * 1000,
max: 100,
standardHeaders: true,
});
export const authLimiter = rateLimit({
store: new RedisStore({ client: redisClient }),
windowMs: 60 * 60 * 1000,
max: 5,
message: "Too many login attempts, please try again later",
});
API Key Management
Best Practices for issuance and storage:
1. Format: Prefix keys to identify them and allow secret scanners to find them easily.
- Example: `pk_live_8a9b...` (Stripe pattern).
2. Storage: NEVER store plaintext API keys in the DB.
- Hash them using SHA-256 (not bcrypt, because API keys are high entropy/long).
- Only show the user the plaintext key ONCE upon creation.
3. Transport: API keys must only be accepted via Headers, never in Query Params.
- `Authorization: Bearer pk_live_123`
- Query params are logged in server access logs and browser histories.
GraphQL Security Vectors
import depthLimit from "graphql-depth-limit";
app.use("/graphql", graphqlHTTP({ validationRules: [depthLimit(5)] }));
const server = new ApolloServer({
schema,
introspection: process.env.NODE_ENV !== "production",
});
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
- Over-engineering: Proposing complex abstractions or distributed systems when a simpler approach suffices.
- Hallucinated Libraries/Methods: Using non-existent methods or packages. Always
// VERIFY or check package.json / requirements.txt.
- Skipping Edge Cases: Writing the "happy path" and ignoring error handling, timeouts, or data validation.
- Context Amnesia: Forgetting the user's constraints and offering generic advice instead of tailored solutions.
- Silent Degradation: Catching and suppressing errors without logging or re-raising.
Slash command: /review or /tribunal-full
Active reviewers: logic-reviewer · security-auditor
❌ Forbidden AI Tropes
- Blind Assumptions: Never make an assumption without documenting it clearly with
// VERIFY: [reason].
- Silent Degradation: Catching and suppressing errors without logging or handling.
- Context Amnesia: Forgetting the user's constraints and offering generic advice instead of tailored solutions.
Review these questions before confirming output:
✅ Did I rely ONLY on real, verified tools and methods?
✅ Is this solution appropriately scoped to the user's constraints?
✅ Did I handle potential failure modes and edge cases?
✅ Have I avoided generic boilerplate that doesn't add value?
🛑 Verification-Before-Completion (VBC) Protocol
CRITICAL: You must follow a strict "evidence-based closeout" state machine.
- ❌ Forbidden: Declaring a task complete because the output "looks correct."
- ✅ Required: You are explicitly forbidden from finalizing any task without providing concrete evidence (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
Pre-Flight Checklist
VBC Protocol (Verification-Before-Completion)
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
🤖 LLM-Specific Traps
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
- Over-engineering: Proposing complex abstractions or distributed systems when a simpler approach suffices.
- Hallucinated Libraries/Methods: Using non-existent methods or packages. Always
// VERIFY or check package.json / requirements.txt.
- Skipping Edge Cases: Writing the "happy path" and ignoring error handling, timeouts, or data validation.
- Context Amnesia: Forgetting the user's constraints and offering generic advice instead of tailored solutions.
- Silent Degradation: Catching and suppressing errors without logging or re-raising.
🏛️ Tribunal Integration (Anti-Hallucination)
Slash command: /review or /tribunal-full
Active reviewers: logic-reviewer · security-auditor
❌ Forbidden AI Tropes
- Blind Assumptions: Never make an assumption without documenting it clearly with
// VERIFY: [reason].
- Silent Degradation: Catching and suppressing errors without logging or handling.
- Context Amnesia: Forgetting the user's constraints and offering generic advice instead of tailored solutions.
✅ Pre-Flight Self-Audit
Review these questions before confirming output:
✅ Did I rely ONLY on real, verified tools and methods?
✅ Is this solution appropriately scoped to the user's constraints?
✅ Did I handle potential failure modes and edge cases?
✅ Have I avoided generic boilerplate that doesn't add value?
🛑 Verification-Before-Completion (VBC) Protocol
CRITICAL: You must follow a strict "evidence-based closeout" state machine.
- ❌ Forbidden: Declaring a task complete because the output "looks correct."
- ✅ Required: You are explicitly forbidden from finalizing any task without providing concrete evidence (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.