Securing REST & GraphQL APIs: OWASP Best Practices for Modern Backends
Defending against BOLA, broken authentication, rate-limiting strategies, depth limiting in GraphQL, and automated vulnerability scanning.
APIs are the primary attack surface of modern cloud software. In 2026, the vast majority of data breaches stem not from exotic zero-day exploits, but from fundamental API authorization flaws and missing input sanitization across REST and GraphQL endpoints.
1. Mitigating BOLA (Broken Object Level Authorization)
BOLA remains the #1 vulnerability on the OWASP API Security Top 10. It occurs when an endpoint verifies that a user is logged in, but fails to verify that the logged-in user actually owns the requested resource ID. Always enforce tenant ID checks at the database query layer.
2. Token-Bucket Rate Limiting with Redis
Exposing unthrottled API endpoints invites credential-stuffing attacks and denial-of-service vulnerabilities. Deploying token-bucket rate limiting at the API gateway layer (Cloudflare or Redis sliding windows) protects backend resources from abuse.
"Authentication proves who the user is; authorization verifies what they are allowed to touch. Never trust a frontend client to enforce resource permissions."
3. GraphQL Query Depth & Complexity Limiting
GraphQL allows clients to request arbitrary nested data. Malicious actors can construct deeply recursive queries that overwhelm database connection pools. Enforcing query depth analyzers and complexity limits prevents denial-of-service attacks.
- Always scope database queries with WHERE tenant_id = ctx.session.tenantId.
- Enforce sliding-window rate limits (e.g. 60 requests/minute for standard users).
- Set GraphQL max depth to 5 levels to block recursive cyclic queries.
- Implement automated OWASP ZAP security scans in continuous integration (CI) pipelines.
Never pass user-supplied IDs directly into raw database queries without validating ownership in session context. BOLA accounted for over 40% of all SaaS data breaches last year.
Mithun Biswas
Founder and Creative Director at XeeWeb. Passionate about high-precision UI/UX architecture, Framer development, and crafting disruptive digital experiences for global brands.
Discuss a project with XeeWeb