Back to glossary

Denial of Service (DoS)

Denial of service (DoS) is an attack that makes a system unavailable by exhausting a finite resource such as bandwidth, CPU, memory, or an event loop.

Also known as DoS attack, Denial-of-service attack, DDoS, Distributed denial of service, ReDoS

Denial of service (DoS) is an attack that makes a system unavailable to legitimate users by exhausting a finite resource: network bandwidth, connection state, CPU time, memory, or a single-threaded event loop. Distributed denial of service (DDoS) floods a target from many machines. Application-layer DoS needs one crafted input, such as a regular expression that backtracks for seconds.

Every DoS attack is an exercise in asymmetry. The attacker finds an operation that costs them almost nothing to trigger and costs the target far more to perform, then triggers it until something runs out. At the network layer that asymmetry is now a capacity problem: you rent enough anycast bandwidth and scrubbing to absorb it. Our position is that the DoS most teams actually own is algorithmic. It lives in code you wrote and, more often, in code you installed, where a single request can pin a CPU core for seconds. In the test below, a 17-byte glob pattern kept a vulnerable minimatch release busy for 7 seconds, and a 16-byte one froze an entire Node.js server for 2.7 seconds.

How does a denial of service attack work?

#

A denial of service attack works by forcing the target to spend a scarce resource faster than it can be replenished. Which resource gets exhausted defines the attack class.

LayerResource exhaustedExampleAsymmetry
VolumetricLink bandwidthmemcached UDP reflectionA 15-byte request produced a 750 kB response, 51,200x amplification
Protocol and stateConnection tables, per-stream stateHTTP/2 Rapid Reset (CVE-2023-44487)201 million requests per second from about 20,000 machines
Application and algorithmicCPU, memory, the event loopReDoS in minimatch (CVE-2026-26996)One 17-byte pattern, 7.0 seconds of CPU in our test

Volumetric attacks saturate the pipe. Reflection makes them cheap: the attacker spoofs the victim's IP address as the source of small UDP queries to open servers, and the servers send large answers to the victim. When memcached servers were abused this way in 2018, Cloudflare measured a 15-byte request producing a 750 kB response.

Protocol attacks exhaust state rather than bandwidth. HTTP/2 Rapid Reset opened streams and cancelled each one immediately with RST_STREAM, so the server parsed, dispatched, and tore down work the client never waited for. Cloudflare's breakdown reports a peak just above 201 million requests per second from "a botnet of merely 20,000 machines."

Application-layer attacks exhaust whatever the code spends per request. They are the most asymmetric class, because the attacker can often find inputs where the cost per request grows exponentially with input length.

What is the difference between DoS and DDoS?

#

DDoS is a denial of service attack sent from many sources at once, usually a botnet of compromised devices. Distribution matters because a single source can be blocked by address, while traffic from tens of thousands of residential IPs looks like a crowd.

The scale is no longer theoretical. Cloudflare's 2025 Q4 DDoS threat report, published in February 2026, counted 47.1 million DDoS attacks in 2025, up 121% year over year, and a record-setting 31.4 Tbps attack that lasted 35 seconds.

Network-layer DDoS defense is an infrastructure purchase: anycast networks spread the flood across hundreds of data centers, and scrubbing drops it before it reaches the origin. That approach works, and it does nothing for application-layer DoS. An algorithmic DoS needs no botnet. One client sending one request every few seconds can keep a server saturated, and no volumetric filter will flag it.

One request can stop a Node.js server

#

A single request can stop a Node.js server because all JavaScript in a Node.js process runs on one thread, the event loop. A callback that runs for five seconds blocks every other callback for five seconds. The Node.js project's guide to not blocking the event loop puts it plainly: "While a thread is blocked working on behalf of one client, it cannot handle requests from any other clients."

Thread-per-request servers degrade more gracefully, but the arithmetic is the same: a pool of N worker threads falls to N concurrent expensive requests. Async runtimes in other languages, such as Python's asyncio, share Node's failure mode for CPU-bound work.

Node.js also shows how resource exhaustion can turn into a crash instead of a stall. In the Node.js AsyncLocalStorage crash bug patched on January 13, 2026, a stack overflow from deeply nested input exited the process with code 7 whenever async_hooks was active, bypassing try/catch and uncaughtException handlers. React Server Components, Next.js, and common APM agents enable that path.

What is a ReDoS attack?

#

A ReDoS attack (regular expression denial of service) sends input that makes a backtracking regex engine explore an exponential or high-degree polynomial number of paths before it fails. The weakness is catalogued as CWE-1333, "Inefficient Regular Expression Complexity."

Most regex engines in mainstream runtimes backtrack, including V8's Irregexp, PCRE, Python's re, and java.util.regex. Go's regexp package and Rust's regex crate are the notable exceptions: both guarantee linear-time matching by giving up backreferences. A backtracking engine tries one way to match, and on failure, rewinds and tries the next. When a pattern lets the same characters be consumed in many different ways, typically through nested or adjacent unbounded quantifiers, a non-matching input forces the engine to try every way before it can answer "no."

The Node.js guide's own example is /(\/.+)+$/. Each / can start a new outer repetition or be eaten by the inner .+, so a string of 100 slashes followed by a newline has an astronomical number of splits to reject.

minimatch, the glob matcher behind a large share of JavaScript build tooling, hit the same bug class in February 2026. Glob patterns compile to regexes, and in versions before the fix every * became its own lazy group. This is the regex minimatch 10.2.0 builds for the pattern ***X***:

JavaScript
/^(?!\.)[^/]*?[^/]*?[^/]*?X[^/]*?[^/]*?[^/]*?$/

Against a path with no X in it, the engine must try every way of distributing the input characters across the groups before the leading groups give up. Each extra * multiplies the work.

Reproducing ReDoS in minimatch, step by step

#

We reproduced CVE-2026-26996, one of the three minimatch ReDoS vulnerabilities published that month, on Node.js 22.23.4 (V8 12.4) on a 2-vCPU Xeon at 2.1 GHz. The vulnerable build is minimatch 10.2.0. The patched build is 10.2.4.

Bash
npm install --ignore-scripts minimatch-old@npm:minimatch@10.2.0 minimatch-new@npm:minimatch@10.2.4
JavaScript
// time minimatch('aaaaaaaaaaaaaaaaaaaa', '*'.repeat(n) + 'X***')
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const input = 'a'.repeat(20);
for (const pkg of ['minimatch-old', 'minimatch-new']) {
  const { minimatch } = require(pkg);
  for (let n = 4; n <= 13; n++) {
    const pattern = '*'.repeat(n) + 'X***';
    const t = performance.now();
    minimatch(input, pattern);
    console.log(pkg, n, pattern.length, (performance.now() - t).toFixed(1));
  }
}
Leading * countPattern lengthminimatch 10.2.0minimatch 10.2.4
610 bytes2.3 ms0.1 ms
711 bytes8.6 ms0.1 ms
812 bytes28.4 ms0.1 ms
913 bytes96.3 ms0.1 ms
1014 bytes308.0 ms0.1 ms
1115 bytes951.0 ms0.2 ms
1216 bytes2,659.5 ms0.3 ms
1317 bytes7,009.0 ms0.1 ms

Each additional * roughly triples the runtime of minimatch 10.2.0. A rerun produced the same curve within 5%, ending at 6,754.9 ms for the 17-byte pattern. The patched release stays under a millisecond at every size. At 17 bytes, the vulnerable build spends about 70,000 times longer than the patched one.

Timing a function in isolation undersells the impact. To measure what other users experience, we wrapped minimatch in an eight-line HTTP server and polled a /health endpoint every 100 ms while one client sent a single malicious request.

JavaScript
import http from 'node:http';
import { createRequire } from 'node:module';
const { minimatch } = createRequire(import.meta.url)(process.env.MM || 'minimatch-old');
http.createServer((req, res) => {
  const u = new URL(req.url, 'http://x');
  if (u.pathname === '/match') return res.end(String(minimatch(u.searchParams.get('path') ?? '', u.searchParams.get('glob') ?? '')));
  res.end('ok');
}).listen(3000);
Bash
curl 'http://127.0.0.1:3000/match?path=aaaaaaaaaaaaaaaaaaaa&glob=************X***'

With minimatch 10.2.0, the attack request arrived 532 ms into the run and took 2,767 ms to answer. The health check sent 33 ms later, at 565 ms, took 2,735.5 ms. Apart from the first probe, which spent 51 ms on connection setup, every other health check answered in 1.5 to 3.7 ms, and none was served until the regex finished. With minimatch 10.2.4, the same attack request answered in 5 ms and no health check after the first exceeded 6.4 ms. One unauthenticated request carrying a 16-byte glob froze the whole process for the length of the regex match.

Where application-layer DoS hides in your dependencies

#

Most application-layer DoS bugs in a typical service are not in first-party code. They sit in parsers, validators, matchers, and serializers several levels down the tree, in a transitive dependency nobody on the team chose directly. minimatch alone receives about 472 million downloads a week, according to our minimatch write-up.

ReDoS is endemic. An ESEC/FSE 2018 study by Davis, Coghlan, Servant, and Lee scanned 448,402 npm and PyPI modules and found thousands of super-linear regexes affecting over 10,000 modules.

ReDoS is also a production outage class, not a lab curiosity. On July 2, 2019, a single WAF rule took Cloudflare's HTTP proxies to nearly 100% CPU for 27 minutes. Cloudflare's postmortem traced it to a pattern containing .*(?:.*=.*), and John Graham-Cumming summarized the root cause in one line: "An engineer wrote a regular expression that could easily backtrack enormously."

Regexes are one input-shaped cost among several:

  • Infinite loops in deserializers. The React Server Components DoS vulnerabilities (CVE-2025-55184 and its follow-up CVE-2025-67779) let one crafted request to an RSC endpoint spin the server in a loop during deserialization. The first fix was incomplete.
  • Unbounded recursion. Deeply nested JSON or query strings exhaust the stack, which the Node.js crash above turned from a catchable RangeError into process exit.
  • Unbounded allocation. Running npm audit against Zod 3.22.2 for this article also surfaced GHSA-mrhx-c7xc-m3w5, a CWE-770 memory exhaustion bug in validating oversized collections, fixed in Zod 4.6.6.

Dependencies can also deny service on purpose. In the colors and faker sabotage of 2022, their maintainer shipped protestware that entered an infinite loop, breaking every application that resolved the new versions. colors was getting more than 20 million weekly downloads at the time. The left-pad unpublish of 2016 broke builds across the ecosystem without shipping any code at all. In January 2024, the everything package depended on every public npm package and exhausted disk and system resources on install. Even the registry is a target: researchers showed the npm registry was vulnerable to cache-poisoned DoS, storing a "Not Found" response for a real package using one machine.

Why most ReDoS CVEs are noise, and some are not

#

Most ReDoS CVEs are noise because an attacker cannot reach the vulnerable argument. A CVSS score cannot see that. This is what npm audit reported on November 7, 2026 for a project pinning minimatch 10.2.0 and Zod 3.22.2:

Plain text
$ npm audit
minimatch  7.0.0 - 11.0.0
Severity: high
minimatch has a ReDoS via repeated wildcards with non-matching literal in pattern - https://github.com/advisories/GHSA-3ppc-4f35-3m26
minimatch has ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments - https://github.com/advisories/GHSA-7r86-cg39-jmmj
minimatch ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions - https://github.com/advisories/GHSA-23c5-xmqv-rm74
minimatch has potential denial of service via globparts amplification - https://github.com/advisories/GHSA-g3hv-75wg-m249

zod  <=4.6.5
Severity: high
Zod denial of service vulnerability - https://github.com/advisories/GHSA-m95q-7qp3-xv42
Zod can exhaust memory while validating oversized constrained collections - https://github.com/advisories/GHSA-mrhx-c7xc-m3w5

The minimatch advisories are rated high, with an availability-only CVSS 3.1 score of 7.5 on two of them. All three high-severity advisories require the attacker to control the glob pattern, the second argument. In nearly every application, patterns come from config files and source code, not from HTTP requests. Our minimatch write-up lists the real exceptions: build services that accept user globs, multi-tenant rule engines, and CI systems evaluating user-submitted config.

The Zod advisory, CVE-2023-4316 (GHSA-m95q-7qp3-xv42), is rated moderate, 5.3. Its vulnerable path is z.string().email(), which by design receives untrusted input from signup and contact forms. We sent a 31-byte string, 30 underscores and an @, to Zod 3.22.2's email validator. It took 2.7 seconds to reject.

The lower-scored bug is the one an anonymous user can trigger. Maintainers have been saying this for years. Responding to ReDoS reports filed against micromatch in 2024, maintainer Jon Schlinkert said he gets "these issues all the time for things that can't even be a vulnerability unless you do it to yourself."

Reachability analysis removes the first layer of noise: if no code path calls the vulnerable function, the CVE does not matter. Socket's full application reachability builds a call graph across application and dependency code, and typically marks about 80% of CVEs unreachable, per the Tier 1 Reachability announcement. For DoS bugs, a reachable call still leaves one question: which argument carries attacker-controlled bytes? Reachable does not always mean exploitable. Triage DoS CVEs by input provenance, not by severity score.

How do you prevent a denial of service attack?

#

You prevent a denial of service attack by bounding what each request can cost, at every layer, and accepting that each control covers only its own layer.

Absorb volume at the edge. Anycast networks and scrubbing services absorb volumetric and protocol floods, and SYN cookies let a TCP stack survive a SYN flood without allocating state. These controls cost money and add a dependency on a provider. They do nothing about a 17-byte request that costs seven seconds.

Rate limit by cost, not just count. A token bucket keyed by IP or API key caps how often a client can call you, and it is the right first control for login, search, and other expensive endpoints. A per-IP limit of 10 requests per minute does not stop the minimatch request above, because one request per minute still freezes the process for seven seconds of it. Concurrency caps on expensive routes, and per-request CPU budgets, track cost directly.

Use bot management for floods, not crafted inputs. Bot management fingerprints clients, challenges suspicious ones, and drops automated floods that per-IP limits miss. It does not help when the expensive request comes from a real, logged-in user.

Bound input before the expensive step runs. Length limits are the cheapest ReDoS mitigation, but only if they short-circuit. In Zod 3.22.2, chained checks all run, so a length cap does not protect the regex behind it:

JavaScript
import { z } from 'zod'; // 3.22.2
const input = '_'.repeat(30) + '@';
// one cold call per process
z.string().email().safeParse(input);                         // 2,767 ms  [invalid_string]
z.string().max(20).email().safeParse(input);                 // 2,809 ms  [too_big, invalid_string]
z.string().max(20).pipe(z.string().email()).safeParse(input); //    0.8 ms [too_big]

Choose a regex engine with a worst-case guarantee where input is untrusted.

EngineWorst-case match timeBackreferences and lookaroundCost
V8 Irregexp (default)ExponentialSupportedNone
V8 fallback, --enable-experimental-regexp-engine-on-excessive-backtracksLinear, for eligible regexes onlyIneligible; such regexes keep backtrackingExperimental, process-wide flag
RE2, via the re2 npm bindingLinear in input lengthNot supportedNative addon, different edge-case semantics

V8's non-backtracking engine shipped experimentally in V8 8.8. With the fallback flag set, V8 switches a regex to it after 50,000 backtracks by default, but only if the regex has no backreferences, no lookarounds, and neither the i nor the u flag. We tested it against both real bugs in this article, and it rescued neither:

RegexDefaultWith fallback flagWhy
minimatch 10.2.0, 12 leading *2,677 ms2,556 msLeading (?!\.) lookahead makes it ineligible
Same regex, lookahead removed2,496 ms2.0 msEligible
Zod 3.22.2 email, 32 underscores11,016 ms11,035 msi flag makes it ineligible
Same regex, i replaced by a-zA-Z10,871 ms2.2 msEligible

The verdict: keep Irregexp for patterns and inputs you control. Use RE2 wherever an attacker controls either the pattern or the subject string, and accept that you lose lookaround and backreferences. Treat the V8 flag as defense in depth only after you check that your hot regexes are eligible, because two features that are routine in validation code, case-insensitive matching and lookaheads, disqualify a regex.

Move untrusted parsing off the event loop. Running a risky call in a worker thread with a deadline turns a stall into an error:

JavaScript
import { Worker } from 'node:worker_threads';
export function matchWithDeadline(path, glob, ms = 50) {
  return new Promise((resolve, reject) => {
    const w = new Worker(new URL('./match-worker.mjs', import.meta.url), {
      workerData: { path, glob },
      resourceLimits: { maxOldGenerationSizeMb: 32 },
    });
    const timer = setTimeout(() => { w.terminate(); reject(new Error('glob timeout')); }, ms);
    w.once('message', (ok) => { clearTimeout(timer); w.terminate(); resolve(ok); });
    w.once('error', (e) => { clearTimeout(timer); reject(e); });
  });
}
JavaScript
import { parentPort, workerData } from 'node:worker_threads';
import { minimatch } from 'minimatch';
parentPort.postMessage(minimatch(workerData.path, workerData.glob));

Against minimatch 10.2.0, the malicious pattern failed with glob timeout after 50.4 ms, and the event loop stayed free. The cost is real: spawning a worker took about 44 ms on our machine, most of the 50 ms budget, so production code needs a pre-warmed worker pool, and each worker carries its own heap.

Patch the dependency, and control when new versions arrive. Upgrading minimatch to 10.2.3 or later fixes all three February advisories; the fourth, moderate advisory in the audit output above needs 11.0.1. Socket also published free Certified Patches for the three high-severity minimatch bugs, which apply a targeted fix to the installed version without a major-version upgrade. For sabotage, a lockfile keeps you on a known version until someone updates it, but it says nothing about code fetched by npx or a global install. A dependency cooldown, 24 hours by default as of pnpm 11, keeps a freshly published sabotaged release out of new installs during its riskiest window. A cooldown does nothing if the sabotage goes unnoticed for longer than the window.

Availability is a dependency property

#

The uncomfortable conclusion is that your service's availability is set by the worst-case complexity of every function your requests pass through, and almost none of those functions document it. No package manifest declares that a validator is linear in its input or that a matcher is exponential in its pattern. CVSS scored the glob bug that needs a hostile pattern higher than the email bug any anonymous visitor can trigger, and it leaves you to work out which argument the attacker controls.

V8 built a safety net, and both real-world regexes we tested fall straight through it. Until runtimes ship linear-time matching by default, or packages publish their complexity bounds, the cheapest DoS against a modern web service is not a botnet. It is a short string sent to the right dependency.