VYPR
Moderate severityNVD Advisory· Published Aug 13, 2022· Updated Apr 22, 2025

CRLF Injection in Nodejs ‘undici’ via Content-Type

CVE-2022-35948

Description

undici is an HTTP/1.1 client, written from scratch for Node.js.=< 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` This issue was patched in Undici v5.8.1. Sanitize input when sending content-type headers using user input as a workaround.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
undicinpm
< 5.8.25.8.2

Affected products

1

Patches

1
66165d604fd0

Merge pull request from GHSA-f772-66g8-q5h3

https://github.com/nodejs/undiciRafael GonzagaAug 9, 2022via ghsa
2 files changed · +34 1
  • lib/core/request.js+2 1 modified
    @@ -297,7 +297,8 @@ function processHeader (request, key, val) {
       } else if (
         request.contentType === null &&
         key.length === 12 &&
    -    key.toLowerCase() === 'content-type'
    +    key.toLowerCase() === 'content-type' &&
    +    headerCharRegex.exec(val) === null
       ) {
         request.contentType = val
         request.headers += `${key}: ${val}\r\n`
    
  • test/request-crlf.js+32 0 added
    @@ -0,0 +1,32 @@
    +'use strict'
    +
    +const { createServer } = require('http')
    +const { test } = require('tap')
    +const { request, errors } = require('..')
    +
    +test('should validate content-type CRLF Injection', (t) => {
    +  t.plan(2)
    +
    +  const server = createServer((req, res) => {
    +    t.fail('should not receive any request')
    +    res.statusCode = 200
    +    res.end('hello')
    +  })
    +
    +  t.teardown(server.close.bind(server))
    +
    +  server.listen(0, async () => {
    +    try {
    +      await request(`http://localhost:${server.address().port}`, {
    +        method: 'GET',
    +        headers: {
    +          'content-type': 'application/json\r\n\r\nGET /foo2 HTTP/1.1'
    +        },
    +      })
    +      t.fail('request should fail')
    +    } catch (e) {
    +      t.type(e, errors.InvalidArgumentError)
    +      t.equal(e.message, 'invalid content-type header')
    +    }
    +  })
    +})
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.