API Security: The OWASP API Security Top 10 & Hardening Strategies

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.

The OWASP API Security Top 10 Vulnerability Matrix

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.

Deep Dive: Mass Assignment Vulnerability in Node.js

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);
});

The Fix: Strict DTO Whitelisting

// 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);
});

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. What is an API Gateway and how does it improve API security?

An API Gateway (such as Kong, Apigee, or AWS API Gateway) sits between clients and microservices. It centralizes authentication (validating JWTs), SSL termination, rate limiting, logging, and CORS policies in a single hardened perimeter.

Q2. Why is Excessive Data Exposure dangerous in REST APIs?

Even if your mobile application only displays a user's name on screen, if the API endpoint returns the entire database row containing email, phone number, and password hashes, an attacker simply intercepts the JSON payload with a proxy like Burp Suite.

Explore Related Cybersecurity Tutorials & Next Steps

Broaden your defensive and offensive security knowledge across our curriculum:

JWT Security & Vulnerabilities

Securing stateless bearer authentication tokens used across modern API endpoints.

OAuth 2.0 & OpenID Connect

Implementing modern federated delegated authorization for API ecosystems.

API Rate Limiting & Throttling

Defending APIs from automated mass scrapers and brute-force credential attacks.

Broken Object Level Authorization

Remediating API1:2023 BOLA through rigorous tenancy validation logic.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!