Skip to content

fix: warn when globalDecompression is left at its implicit default - #449

Open
Cdineshreddy12 wants to merge 1 commit into
fastify:mainfrom
Cdineshreddy12:fix/warn-implicit-global-decompression
Open

Cdineshreddy12 wants to merge 1 commit into
fastify:mainfrom
Cdineshreddy12:fix/warn-implicit-global-decompression

Conversation

@Cdineshreddy12

Copy link
Copy Markdown
Contributor

Description

@fastify/compress decompresses request payloads by default (globalDecompression: true), even when an application only ever registers the plugin to compress its own responses. This PR adds a one-time FST_CP_WARN_IMPLICIT_GLOBAL_DECOMPRESSION process warning when neither globalDecompression nor global is set explicitly, so the behavior becomes a deliberate choice instead of a silent default.

Motivation and Context

Addresses #438.

The issue's underlying ask — flipping the default to false — is semver-major and a judgment call for the maintainers, not something this PR tries to force. What's missing today is a non-breaking first step: nothing currently tells an application that it's decompressing request bodies unless it explicitly says it doesn't want to. #439 documents the existing opt-out well, but documentation only reaches people who read it; a runtime warning reaches everyone who registers the plugin without an opinion on this option, which is the more common case in the wild.

This is the same staged pattern Node.js and the Fastify ecosystem itself use before a breaking default change — a soft warning now, the new default later — and it doesn't touch behavior for any application that already sets globalDecompression or global to anything.

Referenced in the issue: CVE-2026-111497, an out-of-bounds write in the Node.js Brotli decoder, is one concrete example of the risk class this default creates.

Testing Details

  • test/implicit-global-decompression-warning.test.js is a new, dedicated test file (kept separate from test/global-decompress.test.js deliberately: the warning is emitted at most once per process, and global-decompress.test.js registers the plugin without options in many of its existing tests, which would trip the dedupe guard before my assertions ran).
  • Covers: the warning fires when neither option is set, and does not fire when either globalDecompression or global is set explicitly (both booleans).
  • npm run test:unit: 281 passing, 0 failing (same as main; the 8 skips are the existing zstd-version gates, unrelated to this change).
  • npm run lint: clean.
  • npm run test:typescript: clean (no public type surface changed).
  • npm run test:coverage: this sandbox (Node 20) reports 99.05% against the repo's 100% threshold, but that gap is identical on a clean checkout of main before this change — it's zlib.createZstdCompress being unavailable on Node 20 (the repo's zstd support starts at 22.15+/23.8+), not something this PR introduces. None of the newly added lines appear in the uncovered set.

Example Output

$ node -e "require('fastify')().register(require('@fastify/compress')).ready()"
(node:12345) [FST_CP_WARN_IMPLICIT_GLOBAL_DECOMPRESSION] DeprecationWarning: Registering @fastify/compress without an explicit `globalDecompression` (or `global`) option decompresses every request payload by default. This exposes the server to attacker-controlled decompression input (see https://app.opencve.io/cve/CVE-2026-111497 for one example of the risk class). Set `{ globalDecompression: false }` if this server only needs response compression, or `{ globalDecompression: true }` to keep the current behavior and silence this warning. The implicit default is expected to change to `false` in a future major version.

Types of changes

  • Documentation
  • Version change (Update, remove or add more Node.js versions)
  • Variant change (Update, remove or add more variants, or versions of variants)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (none of the above)

Checklist

@fastify/compress decompresses request payloads by default, even when
an application only registers the plugin to compress its own
responses. This exposes attacker-controlled decompression input to
the server, as highlighted by CVE-2026-111497, an out-of-bounds write
in the Node.js Brotli decoder.

Emit a one-time FST_CP_WARN_IMPLICIT_GLOBAL_DECOMPRESSION warning when
neither globalDecompression nor global is set explicitly, so this
behavior is a deliberate choice rather than a silent default. No
behavior changes for anyone who already sets either option.

Addresses fastify#438 as a non-breaking first step; the issue's underlying
ask (flipping the default to false) is semver-major and left for a
separate discussion.
@Cdineshreddy12
Cdineshreddy12 force-pushed the fix/warn-implicit-global-decompression branch from da5e332 to d741a57 Compare November 23, 2026 03:09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant