Asia/Kolkata
Posts

Understanding Web Security: Tokens, Rate Limiting, and Mitigation

February 15, 2026
This article is for educational and research purposes only. The techniques discussed here help developers, security engineers, and administrators understand common vulnerabilities so they can build stronger defenses. Under international cyber law, anyone conducting a penetration test must report discovered vulnerabilities to the relevant authorities immediately.
A Denial-of-Service (DoS) or Distributed Denial-of-Service (DDoS) attack tries to exhaust system resources or network bandwidth, making an application unavailable to legitimate users. These attacks fall into three categories. These consume available internet bandwidth:
  • UDP Floods: High volumes of UDP packets flood random ports. The target server inspects each packet for listening services and sends back ICMP destination unreachable responses, draining resources.
  • ICMP Floods: Rapid ping requests without waiting for responses saturate network throughput.
  • DNS Amplification: The attacker spoofs the target's IP and sends small queries to public DNS resolvers. The resolvers respond with much larger packets directed at the victim, amplifying the traffic.
These target resource tables on firewalls, load balancers, or server connection queues:
  • SYN Floods: The attacker sends a flood of SYN packets but never returns the ACK. The server holds these connections half-open, exhausting its connection state table.
  • Smurf Attacks: The attacker spoofs the victim's IP and broadcasts ICMP packets. Every device on the broadcast domain replies to the victim, flooding it with traffic.
These target specific application features, such as database queries or login operations:
  • HTTP Floods: The server gets flooded with standard-looking HTTP GET/POST requests that force CPU-heavy operations like PDF generation or search queries.
  • Slowloris: The attacker opens many connections and keeps them open by sending partial HTTP headers very slowly, eventually filling the server's maximum connection pool.
  • Traffic Throttling: Deploy rate limiters at the load balancer or application gateway.
  • CDN Integration: Use CDNs with Anycast routing to distribute and absorb traffic spikes.
  • SYN Cookies: Enable SYN cookies on Linux hosts so memory is only allocated after the handshake completes.

JSON Web Tokens (JWT) are widely used for stateless session management. Knowing how they work is essential for implementing them safely. A JWT consists of three base64-encoded segments separated by periods: header.payload.signature
  1. Header: Specifies the token type and the hashing algorithm used (e.g., HMAC SHA-256).
  2. Payload: Contains claims, such as user IDs, permissions, and expiry timestamps.
  3. Signature: Generated by signing the encoded header and payload with a secret key.
If a JWT verification library is poorly configured, it may trust the algorithm field inside the token. An attacker can set the algorithm to "none" or sign an asymmetric RS256 token using the public key as an HMAC symmetric secret.
  • Remediation: Explicitly reject "none" algorithms in production. Hardcode the expected signature verification algorithm in your verification functions.
HMAC-based tokens like HS256 rely on a shared secret key. If the key is short or simple, an attacker can brute-force it offline using GPU tools.
  • Remediation: Use cryptographically secure keys with at least 256 bits of entropy.
Storing tokens in localStorage makes them accessible to JavaScript, exposing them to theft through Cross-Site Scripting (XSS) attacks.
  • Remediation: Store tokens in secure, httpOnly cookies with SameSite=Strict and the Secure flag enabled. This prevents both XSS reading and CSRF abuse.

Rate limiters protect servers from credential stuffing, brute-forcing, and scraping. Standard implementations, however, often contain logic errors that defeat their purpose. Many applications run behind a reverse proxy like Cloudflare, Nginx, or AWS ALB. The proxy forwards the client's real IP using headers like X-Forwarded-For or X-Real-IP. If the backend rate limiter trusts these headers without validating the source:
  • Vulnerability: An attacker appends arbitrary IP strings to the header:
  • Remediation: Configure your backend to trust these headers only when the request comes from a designated local proxy subnet. Don't parse the header otherwise.
IPv4 addresses are limited, but IPv6 gives large subnets, typically a /64 or /48 allocation for a single household. Attackers can rotate through millions of individual IPv6 addresses.
  • Remediation: When applying rate limits to IPv6 traffic, aggregate requests and block at the /64 subnet level rather than matching individual IP addresses.
Rate limiting by IP alone is vulnerable to distributed botnets.
  • Remediation: Implement multi-factor rate limiting. Track request frequency against user session keys, API tokens, and client TLS/JA3 fingerprints. Introduce CAPTCHA challenges when request behavior deviates from normal usage profiles.
Securing web applications requires multiple layers of defense. Strong input sanitization, secure signature validation, and multi-factor rate limiting work together to protect backend services from both volumetric and application-level abuse.