Nodejs ‘undici’ vulnerable to CRLF Injection via Content-Type
Published 18 Aug 2022 · Updated 8 Nov 2023
Affected package
- Affected
- <5.8.2
- Fixed in
- 5.8.2
npm install undici@5.8.2Details
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.
Example:
import { request } from 'undici'
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:
1) http://localhost:3000/
2) http://localhost:3000/foo2
Patches
This issue was patched in Undici v5.8.1
Workarounds
Sanitize input when sending content-type headers using user input.
For more information
If you have any questions or comments about this advisory:
- Open an issue in undici repository
- To make a report, follow the SECURITY document
Is GHSA-f772-66g8-q5h3 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected undici, and gives you the command that fixes it.
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.