Internet Bug Bounty · Report #1664019
CVE-2022-35948: CRLF Injection in Nodejs ‘undici’ via Content-Type
Summary
CRLF Injection in Nodejs ‘undici’ via Content-Type
Package: undici (npm) Affected versions: =< 5.8.1 Patched versions: 5.8.2
Impact =< undici @ 5.8.0 users are vulnerable to CRLF Injection on headers when using unsanitized input as request headers, more specifically, inside the content-type header.
Patches This issue was patched in Undici v5.8.1
Workarounds Sanitize input when sending content-type headers using user input.
Full GHSA Link: https://github.com/nodejs/undici/security/advisories/GHSA-f772-66g8-q5h3
How it was found
undici library should be protects HTTP headers from CRLF injection vulnerabilities. However, CRLF injection exists in the ‘content-type’ header of undici.request api.
Impact
=< [email protected] users are vulnerable to CRLF Injection on headers when using unsanitized input as request headers, more specifically, inside the content-type header.
Example:
const unsanitizedContentTypeInput = 'application/json\r\n\r\nGET /foo2 HTTP/1.1'
await request('http://localhost:3000, {
method: 'GET',
headers: {
'content-type': unsanitizedContentTypeInput
},
})
The above snippet will perform two requests in a single request API call:
http://localhost:3000/ http://localhost:3000/foo2
I have submitted the report: https://hackerone.com/reports/1638888 Advisories: https://github.com/nodejs/undici/security/advisories/GHSA-f772-66g8-q5h3 Resolved as of https://github.com/nodejs/undici/releases/tag/v5.8.2