FLOFIDISFLOFIDIS LTD home
Back to Articles
Development2026-05-30·10 min read

Securing REST & GraphQL APIs Against Modern Cyber Threats

A deep dive into API security — handling CORS, rate limiting, JWT token management, BOLA (Broken Object Level Authorization), and schema validation.

FLOFIDIS Engineering & Security

FLOFIDIS LTD

The Growing Criticality of API Security

APIs are the engine of modern web and mobile applications. As web applications shift towards decoupled client-side rendering and mobile frontends, securing API endpoints becomes synonymous with securing the entire platform.


1. Authentication & JWT Token Best Practices

JSON Web Tokens (JWT) are widely used for stateless authentication, but implementation flaws can lead to severe security breaches.

  • Short-Lived Access Tokens: Keep access token lifespans short (15 to 30 minutes). Use secure, HTTP-only refresh cookies to issue new access tokens seamlessly.
  • Never Store Tokens in LocalStorage: LocalStorage is vulnerable to XSS attacks. Store sensitive tokens in SameSite=Strict, HttpOnly, Secure cookies.
  • Validate Token Algorithms: Reject tokens using the "alg": "none" signature algorithm exploit by strictly enforcing asymmetric signing algorithms like RS256 or ES256.

2. Granular Rate Limiting & DoS Protection

Unprotected APIs can be overwhelmed by bot traffic or abused for price scraping and credential stuffing.

  • IP-Based & User-Based Rate Limits: Rate limit requests based on authenticated user IDs as well as client IP addresses to prevent distributed bot evasion.
  • Tiered Endpoints: Apply strict rate limits to sensitive routes (login, password reset, payment processing) while allowing higher limits for read-heavy public APIs.

3. Defensive Schema Validation

Never trust data incoming from client payloads. Unvalidated inputs lead to SQL injection, NoSQL injection, and application crashes.

  • Schema Validation: Define strict validation schemas using libraries like Zod or Joi. Reject unexpected fields automatically.
  • Sanitize Data Output: Ensure internal database fields (such as hashed passwords, reset tokens, or internal flags) are stripped from API responses prior to returning them to clients.

Need engineering or security help?

FLOFIDIS LTD partners with businesses to ship reliable software, conduct security audits, and upskill engineering teams.

Work with us