CCyberwiki

Denial-of-service attack

Denial-of-service attack
ClassAvailability and abuse
Also known asDoS; DDoS when the traffic comes from many machines
CWECWE-400: Uncontrolled Resource Consumption; CWE-770: Allocation of Resources Without Limits or Throttling
MITRE ATT&CKT1498 Network Denial of Service; T1499 Endpoint Denial of Service
Typical severityHigh
AffectsServers, networks and applications reachable from the internet, in particular routes that do expensive work per request

A denial-of-service attack (DoS) takes a website or other service away from its users by exhausting something it depends on: the bandwidth of its network link, the connections a server can hold open, or the processor time and memory of the machine that runs it.123 Traffic sent from many systems at once makes it a distributed denial-of-service attack (DDoS).1 Many of these attacks work because a program hands out a resource with no upper bound on how much one caller can take.4

Description

A classification from CERT-EU sorts attacks by the surface they hit.3 Volumetric attacks fill the network link with traffic. Protocol attacks, also called session attacks, use up connection state in the server or in equipment in front of it, such as firewalls and load balancers. Application attacks make the software stop answering, often with little traffic, and are the hardest of the three to detect.3

Large DDoS attacks come from a botnet that the attacker built or rented. With enough machines, each one sends so little that its traffic is hard to tell from that of real visitors.2

Mechanism

Volumetric floods and reflection

A network flood succeeds when more traffic arrives than the link can carry, for example 10 Gbps sent to a server whose network connects to the internet at 1 Gbps.1 Combined with IP spoofing, the flood is hard to trace and cannot be blocked by sender address.

In a reflection attack, the attacker sends requests to third-party servers, called reflectors, with the victim's address written in as the sender. The reflectors send their replies to the victim. When the protocol's reply is much larger than the request, the attack is amplified; DNS and NTP servers have been used this way, and the memcached caching protocol produced replies up to 51,200 times the size of the request.5

Application exhaustion

An application attack picks a feature that costs the server far more than it costs the caller, and calls it until the application or the server runs out of resources.6 Uploads handed on to image resizing or PDF creation are one such feature.3

Slow HTTP attacks cost the attacker little. They open many connections and send each request a few bytes at a time. The server holds every connection open while it waits for the rest, and stops accepting new ones when its connection pool is full.3

Nested quantifiers in a regular expression, such as ^(a+)+$, can take exponential time on some inputs in a backtracking engine. One short string sent to a form field that is checked with such a pattern can keep a processor core busy; this is called ReDoS.3

Account lockout after failed sign-ins can also be turned against users: wrong passwords sent for a victim's username lock the victim out.3

CVE-2023-44487, known as HTTP/2 Rapid Reset, was a flaw in the protocol itself. A client could open and cancel many request streams in quick succession and exhaust the server; it was exploited between August and October 2023.7

Impact

The victim loses availability.1 Most attacks count on one overloaded component bringing down the rest, so finding single points of failure is part of the defence.3 A related attack, Denial of wallet, aims at the hosting bill.

Notable incidents

On 28 February 2018, GitHub.com was unavailable from 17:21 to 17:26 UTC and intermittently unavailable until 17:30 UTC. The attack was a memcached reflection flood that peaked at 1.35 Tbps and 126.9 million packets per second, sent from tens of thousands of addresses in more than a thousand networks. GitHub moved its routes to Akamai, whose larger network filtered the traffic at its edge, and stated that user data was never at risk.8 The reflectors were memcached servers left reachable from the internet with UDP enabled.9

Detection

In a cloud-hosted application, application exhaustion shows up as a rise in 5xx error responses, exhausted compute and frequent autoscaling.6 GitHub detected the 2018 flood from a change in the ratio of incoming to outgoing traffic on its links.8

Prevention

Filtering upstream

A volumetric flood larger than the server's own link cannot be filtered on that server. It has to be filtered upstream: at the hosting provider, a CDN or a provider that specialises in DoS mitigation.1 SYN cookies protect a self-managed server against SYN floods.2 Serving more content from a cache also reduces what reaches the origin.3

Rate limits and timeouts

A rate limit caps the requests one address or account may send. In nginx, the limit_req module applies a leaky-bucket limit per key. The following configuration allows one request per second per IP address to /search/ with bursts of up to five; requests beyond the burst receive status 503 by default.10

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server {
  location /search/ {
    limit_req zone=one burst=5;
  }
}

A server holds out against slow HTTP attacks with a minimum incoming data rate, request-read timeouts and an absolute connection timeout.3

Bounding work per request

Inside the application, run cheap checks before expensive ones, cap upload and request size, and never let input decide how much memory a request gets.3 In Express, the body-parser limit option sets the largest accepted body. It defaults to '100kb'; the documentation warns that 5 MB or more raises memory use and response times.11

const bodyParser = require('body-parser');
app.use(bodyParser.json({ limit: '100kb' }));

For regular expressions that run on user input, use an engine whose matching time grows linearly with input length, such as RE2 or Go's regexp. With a backtracking engine, set a match timeout and check the length before matching.3

Prompt for a coding agent

Set an explicit body size limit on every route that accepts a request body. Add a per-IP or per-account rate limit to routes that do expensive work per request (search, export, file or image processing, AI calls, email). Rewrite regular expressions with nested quantifiers that run on user input, or limit the input length first. Cap loops and allocations whose size comes from a request. List each file and line you changed.

In SecFlash

On the Security page, SecFlash reports a site with no web application firewall as SF-SEC-301 and a regular expression that can hang under SF-SEC-711. On the Cloud page, SF-CLD-304 and SF-CLD-306 flag DNS records that expose the server behind Cloudflare, SF-CLD-307 a Cloudflare zone with no rate limiting rule, and SF-CLD-407 a Vercel project with its firewall switched off. A site that slows or fails under the load test shows SF-SPD-502 on the Speed page, and one that stops answering shows SF-UPT-101 on the Uptime page.

See also

References

  1. a b c d e "Network Denial of Service, T1498". MITRE ATT&CK. Version 1.2.
  2. a b c "Endpoint Denial of Service, T1499". MITRE ATT&CK. Version 1.2.
  3. a b c d e f g h i j k l "Denial of Service Cheat Sheet". OWASP Cheat Sheet Series. OWASP Foundation.
  4. back "CWE-400: Uncontrolled Resource Consumption". Common Weakness Enumeration 5.0. MITRE.
  5. back "Network Denial of Service: Reflection Amplification, T1498.002". MITRE ATT&CK. Version 1.4.
  6. a b "Endpoint Denial of Service: Application Exhaustion Flood, T1499.003". MITRE ATT&CK. Version 1.3.
  7. back CVE Program (10 October 2023). "CVE-2023-44487". CVE. MITRE.
  8. a b Kottler, Sam (1 March 2018). "February 28th DDoS Incident Report". The GitHub Blog. GitHub.
  9. back Cloudflare (2018). "Memcrashed: Major amplification attacks from UDP port 11211". The Cloudflare Blog.
  10. back "Module ngx_http_limit_req_module". nginx documentation.
  11. back "body-parser". Express documentation. OpenJS Foundation.