Skip to main content
Back to Blog
CybersecurityAPISecurityRateLimitingCybersecurityDevSecOpsInfoSecCyberSecurityAwarenessITConsultingDataSecurity

How Rate Limiting Protects APIs From Abuse, Credential Stuffing, and DoS Attacks

Eldar Aydayev· CEO, Aydahwa Enterprise December 1, 2026 11 min read
How Rate Limiting Protects APIs From Abuse, Credential Stuffing, and DoS Attacks

Rate limiting is where API security quietly succeeds or fails

Most teams treat rate limiting as a scaling knob. Traffic climbs, latency creeps up, someone caps requests per second, and the incident closes. That framing is what gets organizations breached. A rate limit is a security control before it is a performance control, and on the endpoints that matter most, the authentication paths, the password-reset flows, the export and search APIs, it is often the only control standing between an attacker and a resource they can exhaust for free.

The numbers make the point better than any argument. The 2025 Verizon Data Breach Investigations Report found that compromised credentials were an initial access vector in 22% of breaches it reviewed. Looking at single sign-on authentication logs, the same research put credential stuffing at a median of 19% of all daily authentication attempts, rising to 25% for enterprises, with one organization seeing 44% of its login traffic in a single day come from stuffing tools. Every one of those attempts is a request. An API that will answer an unlimited number of login attempts is an API that has already agreed to be brute-forced.

We build and assess these controls for banking, telecom, and critical-infrastructure clients, and the pattern repeats. The rate limiter usually exists. It is usually tuned for capacity, not for abuse. This article walks through what an unbounded API actually exposes, how the three common algorithms behave under attack, why the storage decision matters more than the algorithm, and where rate limiting has to sit inside a layered defense.

What an unrated API actually exposes

The OWASP API Security Top 10 promoted this risk to its own category, API4:2023 Unrestricted Resource Consumption, precisely because the failure is so common and so quiet. The definition is broad: an API that places no limit on the resources a client can consume, whether that is CPU, memory, bandwidth, upload size, batch operation count, or spend on a metered downstream service. OWASP's own worked examples are worth keeping in mind because they are the exact scenarios we see in assessments.

In the first, an attacker scripts a password-reset flow that sends an SMS on every attempt. At roughly five cents per message, a few thousand scripted requests turn a security feature into a billing attack against the business. In the second, a GraphQL endpoint enforces a per-file size limit but happily accepts 999 upload operations batched into a single request, and the server exhausts its memory generating thumbnails. In the third, a raised file-size ceiling combined with no cloud spending cap turns a $13 monthly bill into an $8,000 one. None of these are exotic. All of them are absent rate limits.

Beyond resource exhaustion, three abuse patterns dominate real traffic:

  • Credential stuffing and brute force. Attackers replay leaked username-password pairs against login and token endpoints. Because password reuse is rampant, only about half of a typical user's passwords across services are distinct, a small volume of well-aimed requests yields real account takeovers. This is where a per-identity limit earns its place.
  • Scraping and enumeration. Product catalogs, pricing, user directories, and object-ID sequences get harvested by clients that look almost legitimate. The damage is competitive and privacy-related rather than a crash, so it rarely triggers an alert unless a limit forces the traffic into the open.
  • Application-layer denial of service. Not the volumetric flood a CDN absorbs, but a modest number of expensive requests, a heavy report, an unindexed search, a recursive GraphQL query, aimed at the most costly operation in the system.

What ties these together is that the request volume often looks unremarkable at the network layer. The defense has to understand the application: who is calling, which operation, and how expensive that operation is.

The three algorithms, and where each one leaks

Almost every rate limiter in production is built on one of a small set of algorithms. Choosing among them is a security decision, because they behave differently at exactly the moment an attacker is probing, the boundary of a time window.

Fixed window

The simplest approach counts requests inside a clock-aligned interval, say 100 requests per minute, and resets the counter when the minute rolls over. It is cheap and easy to reason about. It also has a well-known weakness: an attacker can send the full quota at the very end of one window and the full quota at the start of the next, pushing double the intended rate across the boundary while technically never breaking the policy. For a capacity limit that is a rounding error. For a login endpoint, that burst is 200 password guesses in a two-second span instead of 100 in a minute.

Sliding window

A sliding-window counter smooths the boundary problem by weighting the previous window's count as the current one advances, so the effective rate stays close to the policy no matter where the clock sits. It costs more to compute and store than a fixed window but removes the burst gap. For most security-relevant limits, it is the sane default when a token bucket is not available.

Token bucket and leaky bucket

A token bucket fills at a steady rate up to a maximum, and each request spends a token. When the bucket is empty, requests are rejected until it refills. Its useful property is memory: send too much and the bucket goes empty and stays empty until the refill catches up, so a client cannot game the interval boundary the way it can with a fixed window. Configured without spare burst capacity, it approximates a sliding window while allowing a controlled, deliberate burst when you actually want one. A leaky bucket is the mirror image, draining a queue at a fixed rate, and is a good fit when you need to smooth bursty input into a steady downstream flow. The token bucket's one real cost is that it needs a compare-and-set operation on every request, which, as we will see, constrains where you can store its state.

AlgorithmBoundary burst riskCostBest fit for
Fixed windowHigh, allows ~2x at the window edgeVery lowCoarse capacity caps where precision does not matter
Sliding windowLowModerateSecurity limits when a token bucket is impractical
Token bucketVery low, empties and stays emptyModerate, needs compare-and-setAuth, payment, and abuse-sensitive endpoints
Leaky bucketVery lowModerateSmoothing bursty traffic into a fixed downstream rate

Where the counter lives decides whether the limit holds

The algorithm gets the attention, but in distributed systems the harder question is where the counter is stored and how the fleet agrees on it. Databricks published a detailed account of rebuilding their rate limiter under exactly this pressure, and the engineering tradeoffs it describes generalize well beyond their scale.

There are three broad choices for state. A shared external store such as Redis gives every node one consistent view, but it puts a network round trip on the critical path of every request and becomes a single point of failure and a latency bottleneck under load. A local in-memory counter on each node is fast but fragments the count, so a client spread across ten nodes can send ten times the intended rate. A sharded in-memory design, where a routing layer assigns each rate-limit key to an authoritative node that holds its counter in memory, keeps the speed of local state while preserving a single source of truth per key. That last design is what lets a token bucket run at all at high request rates, because the compare-and-set the token bucket needs is nearly free in memory and painfully slow across a network hop to Redis.

The second decision is the synchronization model, and this is where a security architect has to push back on a pure scaling mindset. To shed load, systems like the Databricks one move to optimistic, asynchronous checks: the client allows requests by default and reports its counts to the server every hundred milliseconds or so, and the server tells it which keys to start rejecting. It is elegant and it cuts tail latency dramatically. It also accepts overshoot, some requests over the limit slip through between reports, on the order of a few percent by design.

A few percent overshoot on a capacity limit is invisible. A few percent overshoot on a login endpoint under a credential-stuffing run is thousands of extra guesses. The lesson we carry into designs is that the sync model has to be chosen per endpoint, not per platform. Asynchronous, eventually-consistent limiting is fine for read-heavy product APIs. Authentication, password reset, payment authorization, and anything that spends money or grants access should sit behind a synchronous, strict limit, ideally backed by a client-side local limiter as defense in depth so an obvious spike is rejected immediately rather than a round trip later. Strict accuracy is expensive, and the right question is not whether to pay for it but which endpoints are worth it.

Diagram of a layered API request path showing rate limiting applied at four tiers: the edge or CDN absorbing volumetric layer 3 and 4 floods, a web application firewall filtering layer 7 bot and abuse signatures, an API gateway enforcing a per-identity token bucket, and the backend service applying per-operation quotas and spending caps, with a token-bucket detail showing tokens refilling at a fixed rate

Rate limiting alone is not a bot-defense strategy

A limit is one layer. Attackers rotate IP addresses, spread requests across residential proxies, and pace themselves under any static threshold. The controls have to work together, and each tier answers a different question.

At the edge, a CDN or scrubbing service handles volumetric layer 3 and 4 floods, the traffic that is about raw bandwidth. In front of the application, a web application firewall and next-generation firewall inspect layer 7, matching known bot signatures, malformed requests, and abuse patterns that a simple counter would miss. At the API gateway, the rate limiter enforces quotas, and the single most important design choice here is the key: limiting per authenticated identity or API key, not only per source IP, because IPs are cheap to rotate and identities are not. Inside the service, per-operation quotas and, critically, spending caps on metered downstream providers close the resource-exhaustion gap that OWASP flags directly, its own guidance is to "configure spending limits for all service providers/API integrations."

On sensitive endpoints, static limits give way to adaptive ones. Behavioral scoring, progressive challenges such as step-up multi-factor authentication or a CAPTCHA after a threshold, and account-level lockouts with sane back-off catch the low-and-slow attacks that stay under any fixed line. None of this works blind. Every rejected request, every triggered limit, every lockout should feed a SIEM or SOAR platform so that a distributed campaign, invisible on any single node, becomes visible in aggregate and can trigger an automated response. A rate limiter that silently drops traffic without telling anyone is discarding your best early-warning signal.

This layering is also where compliance and engineering meet. Frameworks Aydahwa works to every day, the NIST Cybersecurity Framework, ISO/IEC 27001, PCI-DSS, and the CIS Benchmarks, all expect controls against resource exhaustion and automated abuse. Mapping your rate-limiting and bot-defense posture to those controls is what turns a scattered set of gateway settings into an auditable, defensible design.

A practical checklist before you call an API rate-limited

  1. Enumerate every internet-facing endpoint and rank them by blast radius: authentication, password reset, payment, data export, and search come first.
  2. Key limits on authenticated identity or API key, not IP alone, and apply a separate, stricter IP or ASN limit only as a coarse backstop.
  3. Use a token bucket or sliding window on abuse-sensitive endpoints; reserve fixed windows for coarse capacity caps where boundary bursts do not matter.
  4. Decide the sync model per endpoint. Strict and synchronous for auth, payment, and anything that spends money; optimistic and asynchronous only where overshoot is harmless.
  5. Set per-operation resource limits, batch and query-depth caps, and hard spending limits on every metered third-party integration.
  6. Add adaptive controls, step-up MFA, progressive challenges, and lockout with back-off, on the highest-risk flows.
  7. Feed every rejection and lockout into your SIEM, and alert on distributed patterns rather than single-source spikes.
  8. Test the limits the way an attacker would: distributed, boundary-timed, and identity-rotating, then map each control to your NIST CSF, ISO 27001, or PCI-DSS obligations.

How Aydahwa Enterprise Can Help

Rate limiting fails quietly, which is why it rewards a review by people who have watched it fail. In our engagements across banking, telecom, and critical national infrastructure, including internet-banking estates operating under central-bank and PCI-DSS oversight and telecom APIs at national scale, we have designed and hardened exactly these controls: gateway and WAF policy, next-generation firewall placement, identity-keyed limits, adaptive bot defense, and the SIEM and SOAR integration that turns a dropped request into an actionable signal.

Aydahwa Enterprise brings Microsoft-certified cybersecurity architecture and more than two decades of hands-on infrastructure and security work to API and application defense, grounded in the NIST CSF, ISO/IEC 27001, PCI-DSS, and CIS Benchmarks. If you want to know where your own APIs stand, start with our free cyber security self-assessment or work through the cybersecurity readiness checklist. To go deeper, our cybersecurity services cover assessment and hardening end to end, cloud security and migration extends the same controls across AWS, Azure, and GCP, and managed IT support keeps them tuned as your traffic changes. When you are ready to review your API defenses, get in touch.

Share

Need expert guidance?

Our cybersecurity and IT consultants can help you implement the strategies discussed in this article.

Call UsWhatsAppBook