Modern digital transformation has shifted software architecture from monolithic server-rendered web pages to decoupled single-page applications (React, Angular, Vue), mobile apps, and microservices communicating via REST, GraphQL, and gRPC APIs. However, APIs expose direct program logic and underlying database structures, making them the #1 attack target for modern threat actors. The OWASP API Security Top 10 standardizes the most critical vulnerabilities threatening modern APIs.
| Vulnerability | Anatomy & Exploitation Flow | Defensive Architecture |
|---|---|---|
| API1: Broken Object Level Authorization (BOLA) | API endpoints accept an object ID (e.g. /api/orders/{id}) without verifying if the requesting user owns that order. Formerly known as IDOR. |
Enforce fine-grained user tenancy checks on every database access: WHERE id = :id AND user_id = :currentUser. |
| API2: Broken Authentication | Weak JWT validation, missing rate limits on login/OTP endpoints, credential stuffing, or accepting expired tokens. | Deploy FIDO2/MFA, short-lived tokens with refresh rotation, and aggressive rate limiting on authentication routes. |
| API3: Broken Object Property Level Authorization | Combines Mass Assignment and Excessive Data Exposure. API returns full user objects (including password hashes and SSNs) expecting the frontend to filter them out! | Use strict Data Transfer Objects (DTOs) with explicit allowlists. Never bind raw request bodies directly to database models! |
| API4: Unrestricted Resource Consumption | Missing rate limits, unlimited pagination (GET /api/users?limit=10000000), or unconstrained file upload sizes, leading to DoS. |
Set hard upper bounds on pagination limits, request payload byte caps, and token-bucket rate limiting. |
| API5: Broken Function Level Authorization (BFLA) | A standard user discovers and invokes administrative API routes (e.g. changing GET /api/users/me to DELETE /api/users/12). |
Centralized Role-Based Access Control (RBAC) middleware verifying user roles before controller execution. |
| API9: Improper Inventory Management (Shadow APIs) | Deprecated, unpatched API versions (e.g. /api/v1/) left running online without authentication while the company uses /api/v3/. |
Maintain a centralized API catalog (Swagger/OpenAPI), decommission legacy endpoints, and enforce API gateway routing. |
Mass assignment occurs when a framework automatically binds incoming JSON fields directly to internal database model properties without an explicit schema whitelist:
// VULNERABLE CODE (Express / Mongoose)
app.post('/api/user/profile', async (req, res) => {
// Attacker sends: { "bio": "Hello", "isAdmin": true, "accountBalance": 99999 }
const user = await User.findByIdAndUpdate(req.user.id, req.body); // BLIND UPDATE!
res.json(user);
});
// SECURE CODE: Explicitly pick only permitted fields
app.post('/api/user/profile', async (req, res) => {
const allowedUpdates = {
bio: req.body.bio,
displayName: req.body.displayName
};
const user = await User.findByIdAndUpdate(req.user.id, allowedUpdates, { new: true });
res.json(user);
});
Broaden your defensive and offensive security knowledge across our curriculum:
Securing stateless bearer authentication tokens used across modern API endpoints.
Implementing modern federated delegated authorization for API ecosystems.
Defending APIs from automated mass scrapers and brute-force credential attacks.
Remediating API1:2023 BOLA through rigorous tenancy validation logic.