Repository navigation
fix: warn when globalDecompression is left at its implicit default - #449
Open
Cdineshreddy12 wants to merge 1 commit into
Open
Cdineshreddy12 wants to merge 1 commit into
Cdineshreddy12 wants to merge 1 commit into
Conversation
2 tasks done
@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
force-pushed
the
fix/warn-implicit-global-decompression
branch
from
November 23, 2026 03:09
da5e332 to
d741a57
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
@fastify/compressdecompresses 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-timeFST_CP_WARN_IMPLICIT_GLOBAL_DECOMPRESSIONprocess warning when neitherglobalDecompressionnorglobalis 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
globalDecompressionorglobalto 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.jsis a new, dedicated test file (kept separate fromtest/global-decompress.test.jsdeliberately: the warning is emitted at most once per process, andglobal-decompress.test.jsregisters the plugin without options in many of its existing tests, which would trip the dedupe guard before my assertions ran).globalDecompressionorglobalis set explicitly (both booleans).npm run test:unit: 281 passing, 0 failing (same asmain; 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 ofmainbefore this change — it'szlib.createZstdCompressbeing 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
Types of changes
Checklist
npm run test && npm run benchmark --if-present