Security Guide
API Backends

Security for Vibe-Coded API Backends

API backends are the most common attack surface for web applications. Every endpoint is a potential vulnerability if it lacks proper authentication, authorization, and input validation.

Get security coverage specific to your use case.

Why Security Matters for API Backends

APIs are the primary target for automated attacks. Attackers enumerate endpoints, test for broken authentication, and look for authorization bypasses. The OWASP API Security Top 10 lists the most common API vulnerabilities, and AI-generated APIs typically have several of them. Vibe-coded APIs are particularly risky because AI tools generate functional endpoints without defensive coding practices. Input validation, rate limiting, and proper error handling are almost always missing from generated code.

Security Risks

Broken Object Level Authorization

critical

Users accessing other users' resources by changing IDs in API requests.

Mitigation

Verify resource ownership on every request. Check that the authenticated user has permission to access the specific resource identified by the URL or request body.

Broken Authentication

critical

Weak token validation, missing token expiry, or improper session management.

Mitigation

Use established auth libraries (next-auth, passport). Validate tokens on every request. Implement token refresh and expiry.

Excessive Data Exposure

high

API responses returning more data than the client needs, including sensitive fields.

Mitigation

Explicitly select fields in database queries. Never return full database rows. Create response DTOs that only include necessary fields.

Lack of rate limiting

high

No limits on API call frequency enabling brute force, scraping, and DoS attacks.

Mitigation

Implement rate limiting per user and per IP. Use stricter limits on auth endpoints and expensive operations.

Security Checklist

Authentication on all endpointsMust Have

Every API route (except public resources) requires a valid authentication token.

Authorization checks per resourceMust Have

Verify the authenticated user has permission to access the specific requested resource.

Input validationMust Have

Validate all request parameters, body fields, and headers against expected schemas.

Rate limitingShould Have

Per-user and per-IP rate limits on all endpoints, with stricter limits on auth routes.

Response filteringShould Have

Only return necessary fields in API responses. Never expose internal IDs, timestamps, or metadata unnecessarily.

Error handlingShould Have

Return generic error messages to clients. Log detailed errors server-side only.

API versioningNice to Have

Version your API to allow security updates without breaking existing clients.

Real-World Scenario

A developer uses Cursor to build a REST API for a todo app. The endpoint GET /api/todos/:id returns a todo by ID. The AI-generated code fetches the todo from the database but doesn't check if it belongs to the authenticated user. An attacker iterates through IDs, downloading every user's private todos. Because the API returns full database rows, the response includes internal metadata, user emails, and creation timestamps.

Frequently Asked Questions

What's the most common API vulnerability?

Broken Object Level Authorization (BOLA) — also known as IDOR. It means users can access other users' data by changing the resource ID in the API request. It's the #1 item on the OWASP API Security Top 10.

Should I validate input on the server even if the frontend validates?

Always. Frontend validation is for UX, not security. Attackers bypass the frontend entirely and send requests directly to your API. Server-side validation is your actual security boundary.

How do I implement rate limiting?

Use middleware like express-rate-limit (Express), or built-in rate limiting in your framework. Apply per-IP and per-user limits. Use stricter limits (5 req/min) on auth endpoints and looser limits (100 req/min) on data endpoints.

Secure Your API Backends

VAS automatically scans for the security risks specific to api backends. Get actionable results with step-by-step fixes tailored to your stack.

Scans from $5, results in minutes.