Skip to content

GHSA-4992-7rv2-5pvq CVE-2026-1527

Undici has CRLF Injection in undici via `upgrade` option

Medium npm
Severity
4.6 / 10
Medium · CVSS 3.1
Exploit chance (EPSS)
0.29%
Chance of exploitation in the next 30 days. Higher than 21.32% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-93 Improper Neutralization of CRLF Sequences ('CRLF Injection')
Fix
6.24.0
Upgrade undici to this version or later

Description

Impact

When an application passes user-controlled input to the upgrade option of client.request(), an attacker can inject CRLF sequences (\r\n) to:

  1. Inject arbitrary HTTP headers
  2. Terminate the HTTP request prematurely and smuggle raw data to non-HTTP services (Redis, Memcached, Elasticsearch)

The vulnerability exists because undici writes the upgrade value directly to the socket without validating for invalid header characters:

// lib/dispatcher/client-h1.js:1121
if (upgrade) {
  header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n`
}

Patches

Patched in the undici version v7.24.0 and v6.24.0. Users should upgrade to this version or later.

Workarounds

Sanitize the upgrade option string before passing to undici:

function sanitizeUpgrade(value) {
  if (/[\r\n]/.test(value)) {
    throw new Error('Invalid upgrade value')
  }
  return value
}

client.request({
  upgrade: sanitizeUpgrade(userInput)
})

Affected versions

npm

PackageVulnerableFixed in
undici
< 6.24.0
6.24.0
undici
>= 7.0.0, < 7.24.0
7.24.0
undici
< 6.24.0
6.24.0
undici
>= 7.0.0, < 7.24.0
7.24.0

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

undici npm → 6.24.0

npm
npm install undici@6.24.0
yarn
yarn add undici@6.24.0
pnpm
pnpm add undici@6.24.0

Severity breakdown

CVSS 3.1 4.6

CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
None

Weakness

CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')

The product uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.

How to prevent it
  • Implementation: Avoid using CRLF as a special sequence.
  • Implementation: Appropriately filter or quote CRLF sequences in user-controlled input.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-55wc-3pg8-jfw6
undici vulnerable to Denial of Service via unhandled exception in the decompress interceptor
High Also affects undici
GHSA-qrxm-fqhp-jwvm
undici vulnerable to Denial of Service via TLS 1.2 certificate-changing renegotiation
High Also affects undici
GHSA-9fm3-97px-rjf6
undici WebSocket client vulnerable to Denial of Service via unbounded automatic PONG buffering
High Also affects undici
GHSA-4qv8-2p9j-2685
undici vulnerable to Denial of Service via unbounded memory in the EventSource parser
High Also affects undici
GHSA-xjj6-f33q-929c
undici vulnerable to Denial of Service via unhandled error on excessive content-encodings
High Also affects undici
GHSA-f72v-6w45-q472
undici vulnerable to Subresource Integrity bypass via non-lowercase algorithm tokens
High Also affects undici
GHSA-4w7w-5xrc-9h26
undici vulnerable to cache poisoning and cross-user disclosure via cross-origin redirects
Critical Also affects undici
GHSA-2m5v-pch6-74hx
undici vulnerable to TLS certificate validation bypass via dropped tls options in Agent
Critical Also affects undici

Credits: UlisesGascon, mcollina

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor