VDB
Sign up
MEDIUM5.9

GHSA-3wwx-pv8p-q78v

undici vulnerable to Denial of Service via unhandled error in WebSocket permessage-deflate decompression

Quick fix

GHSA-3wwx-pv8p-q78v — undici: upgrade to the fixed version with the command below.

npm install undici@6.28.1

Details

## Impact

undici's WebSocket client (including Node.js's bundled `globalThis.WebSocket`) crashes the entire Node.js process when a remote WebSocket peer sends a permessage-deflate compressed message that crosses the decompressed-payload size limit and then contains a malformed DEFLATE block. In `lib/web/websocket/permessage-deflate.js`, the size-limit cleanup calls `removeAllListeners()` on the internal zlib `InflateRaw`, removing its `error` listener, but leaves the stream running. The inflater then emits a `Z_DATA_ERROR` with no listener attached, which Node.js treats as a fatal unhandled `error` event and terminates the process. Application `error`/`close` handlers on the public WebSocket cannot observe or prevent this, because the failing object is the internal `InflateRaw`.

A malicious or compromised WebSocket server can crash a client with a single connection, unauthenticated and without any application mistake. The attack is asymmetric (about 130 KB on the wire expands past the limit) and can be repeated on reconnect (crash loop).

Affected applications are those using the undici WebSocket client (`new WebSocket(...)`) or Node.js's bundled `globalThis.WebSocket` that can be induced to connect to an attacker-controlled or compromised WebSocket endpoint.

## Patches

Upgrade to undici v6.28.1, v7.29.1 or v8.10.2.

## Workarounds

No workaround is available.

Are you affected?

Enter the version of the package you're using.

Affected packages

npm/undici
Introduced in: 6.25.0Fixed in: 6.28.1
Fixnpm install undici@6.28.1
npm/undici
Introduced in: 7.28.0Fixed in: 7.29.1
Fixnpm install undici@7.29.1
npm/undici
Introduced in: 8.1.0Fixed in: 8.10.2
Fixnpm install undici@8.10.2

References