OWASP API Security Top 10 and API Security
The OWASP API Security Top 10 (2023) with examples and mitigations, plus a layered API security architecture with gateways, authorization, schema validation and monitoring.
OWASP API Security Top 10 (2023)
| # | Risk | Example | Mitigation |
|---|---|---|---|
| API1 | Broken Object Level Authorization (BOLA) | GET /orders/1002 returns another customer's order |
Check ownership/permission on every object access; non-guessable IDs help but are not a control |
| API2 | Broken Authentication | Weak token validation, no rate limit on login | Standard IdP, strict JWT validation, MFA, lockouts |
| API3 | Broken Object Property Level Authorization | Mass assignment (isAdmin: true) or excessive data exposure |
Explicit DTOs; allowlist writable fields; response filtering by role |
| API4 | Unrestricted Resource Consumption | Huge page sizes, expensive queries, no limits | Rate limits, quotas, max page size, timeouts, cost limits |
| API5 | Broken Function Level Authorization | Regular user calls /admin/users |
Role checks per endpoint; deny by default |
| API6 | Unrestricted Access to Sensitive Business Flows | Bots buying all limited sneakers | Bot detection, CAPTCHA/step-up, per-flow limits |
| API7 | Server Side Request Forgery (SSRF) | API fetches user-supplied URL to internal metadata service | URL allowlists, block internal ranges, IMDSv2, egress controls |
| API8 | Security Misconfiguration | Verbose errors, open CORS, missing TLS | Hardened configs, CORS allowlists, security headers |
| API9 | Improper Inventory Management | Old /v1 still exposed without controls; shadow APIs |
API catalog, gateway-only exposure, retirement process |
| API10 | Unsafe Consumption of APIs | Trusting third-party API responses blindly | Validate and sanitize upstream data, timeouts, TLS |
Layered API security architecture
flowchart LR C[Client] --> WAF[WAF + bot protection<br/>+ DDoS] WAF --> GW[API gateway<br/>authN, schema validation,<br/>rate limits, quotas] GW --> SVC[Service<br/>object & property authorization,<br/>business limits] SVC --> DATA[(Data)] GW & SVC --> SIEM[Logs → SIEM<br/>anomaly detection] CAT[API catalog + specs] -.governs.-> GW
Mass assignment protection in Spring
// Bad: binding the entity directly lets clients set any field
// @PutMapping("/users/{id}") User update(@RequestBody User user)
record UpdateProfileRequest(@Size(max = 80) String displayName, @Email String email) {} // allowlisted fields only
@PutMapping("/users/me")
ProfileView update(@Valid @RequestBody UpdateProfileRequest req, @AuthenticationPrincipal Jwt jwt) {
return profiles.update(jwt.getSubject(), req);
}Interview questions and answers
How do you test for BOLA systematically?
Automated tests with two users: every endpoint that takes an object ID is called by user B with user A's IDs and must return 403/404. Include in CI; complement with DAST and API security testing tools.
What does an API gateway not protect you from?
Business-logic flaws, BOLA and property-level authorization, because the gateway does not know data ownership. Those must be enforced in services.