Backport(v1.19) buffer, in_http: enforce size limits on decompressed payloads#5393
Merged
Conversation
…payloads **Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: This PR introduces a strict upper bound for decompressed payloads. ### Changes 1. Introduced `Fluent::Plugin::Extractor` * Extracted the decompression logic (gzip, zstd, deflate) into a dedicated module that processes and decompresses data in manageable 64KB chunks, ensuring steady memory usage. 2. Added `decompression_size_limit` parameter (default: `256MiB`) * Specifies the upper limit of decompression in `buffer` (`buf_file`, `buf_file_single` and `buf_memory`) and `in_http` plugins. * If the limit is exceeded, it safely raises `Fluent::Plugin::Extractor::SizeLimitError` (or returns a `400 Bad Request` in `in_http`). ### Notice for 3rd-party Plugin Developers Plugins utilizing the `buffer` / `in_http` mechanisms or the newly introduced `Fluent::Plugin::Extractor` are automatically protected by this limit. However, if your custom plugin implements its own decompression logic independently, you must take care to implement similar boundary checks to guard against unexpected memory spikes. **Docs Changes**: **Release Note**: * buffer, in_http: enforce size limits on decompressed payloads Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
kenhys
approved these changes
Jun 25, 2026
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.
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
This PR introduces a strict upper bound for decompressed payloads.
Changes
Fluent::Plugin::Extractordecompression_size_limitparameter (default:256MiB)buffer(buf_file,buf_file_singleandbuf_memory) andin_httpplugins.Fluent::Plugin::Extractor::SizeLimitError(or returns a400 Bad Requestinin_http).Notice for 3rd-party Plugin Developers
Plugins utilizing the
buffer/in_httpmechanisms or the newly introducedFluent::Plugin::Extractorare automatically protected by this limit.However, if your custom plugin implements its own decompression logic independently, you must take care to implement similar boundary checks to guard against unexpected memory spikes.
Docs Changes:
Release Note: