Skip to content

fix(inputs.http_listener_v2): Limit the body size for every content encoding - #19915

Merged
skartikey merged 1 commit into
influxdata:masterfrom
skartikey:fix/http-listener-v2-bound-body
Oct 29, 2026
Merged

skartikey merged 1 commit into
influxdata:masterfrom
skartikey:fix/http-listener-v2-bound-body

Conversation

@skartikey

@skartikey skartikey commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The max_body_size limit was only enforced through the content-length header and, for gzip bodies, through a reader limit on the decompressed stream. A client that sends the body chunked has no content length, so the plain and the snappy path read the whole body into memory regardless of the configured limit. The snappy path has a second problem: the block format announces the decoded length in its header and snappy.Decode allocates that length up front, so a five byte body can demand up to 4 GiB before the input is found to be corrupt.

The body is now wrapped in a http.MaxBytesReader for every encoding, as inputs.influxdb_listener already does, with the existing second limit on the decompressed gzip stream kept. The snappy path checks the announced decoded length against the limit before decoding. A read that hits the limit answers 413 as the content-length check does, any other read error stays a 400. The new test sends a chunked body above the limit plain, gzipped and snappy-compressed, plus a snappy header announcing an oversized length, and expects 413 with nothing accepted for each.

Checklist

Related issues

resolves #19629

@telegraf-tiger telegraf-tiger Bot added fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Oct 14, 2026
@skartikey
skartikey force-pushed the fix/http-listener-v2-bound-body branch from 771b893 to 418b0cd Compare October 16, 2026 15:05

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @skartikey! Just one comment regarding the switch removal...

@srebhan srebhan self-assigned this Oct 20, 2026
@srebhan srebhan added the waiting for response waiting for response from contributor label Oct 28, 2026
@skartikey
skartikey force-pushed the fix/http-listener-v2-bound-body branch from 418b0cd to a047c36 Compare October 29, 2026 14:55
@skartikey
skartikey requested a review from srebhan October 29, 2026 14:56
@skartikey skartikey removed the waiting for response waiting for response from contributor label Oct 29, 2026
@telegraf-tiger

Copy link
Copy Markdown
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

⚠️ This pull request increases the Telegraf binary size by 6.03 % for linux amd64 (new size: 326.8 MB, nightly size 308.2 MB)

📦 Click here to get additional PR build artifacts

Artifact URLs

. DEB . RPM . TAR . GZ . ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip
armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip
armhf.deb i386.rpm freebsd_armv7.tar.gz
i386.deb ppc64le.rpm freebsd_i386.tar.gz
mips.deb riscv64.rpm linux_amd64.tar.gz
mipsel.deb s390x.rpm linux_arm64.tar.gz
ppc64el.deb x86_64.rpm linux_armel.tar.gz
riscv64.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_riscv64.tar.gz
linux_s390x.tar.gz

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks @skartikey!

@skartikey
skartikey merged commit 2e234b0 into influxdata:master Oct 29, 2026
27 checks passed
@github-actions github-actions Bot added this to the v1.40.3 milestone Oct 29, 2026
srebhan pushed a commit that referenced this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbounded memory allocation in http_listener_v2 collectBody() - snappy and default encoding paths

2 participants