Skip to content

fix: limit decompressed webhook payloads to 10 MiB, configurable with webhookConfig.maxPayloadBytes - #394

Merged
mogita merged 1 commit into
mainfrom
fix/webhook-gzip-limit
Nov 13, 2026
Merged

mogita merged 1 commit into
mainfrom
fix/webhook-gzip-limit

Conversation

@mogita

@mogita mogita commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Problem

gunzipPayload inflated a gzip body with no size limit before the signature check, so an unsigned request of a few hundred KB could expand to hundreds of MB and exhaust memory on a webhook endpoint.

Solution

Decompression now stops at 10 MiB via zlib.gunzipSync's maxOutputLength and throws InvalidWebhookError ("gzip decompression failed: payload exceeds 10485760 bytes"). The same helper backs verifyAndParseWebhook, parseSqs and parseSns. Raise the cap if your events are larger:

import { webhookConfig } from '@stream-io/node-sdk';

webhookConfig.maxPayloadBytes = 50 * 1024 * 1024;

Uncompressed bodies are not limited. This matches the default and error message of the other server SDKs.

How to verify

  1. yarn vitest run __tests__/integration/webhook-compression.test.ts (passes locally on Node 26 and with bun run vitest).
  2. The new size limit tests inflate a body of exactly 10 MiB, reject 10 MiB + 1 byte through verifyAndParseWebhook and parseSqs, and honour a custom limit.

@mogita
mogita merged commit 3de82bd into main Nov 13, 2026
12 of 15 checks passed
@mogita
mogita deleted the fix/webhook-gzip-limit branch November 13, 2026 13:48
mogita pushed a commit that referenced this pull request Nov 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.3](v0.9.2...v0.9.3)
(2026-11-13)


### Bug Fixes

* limit decompressed webhook payloads to 10 MiB, configurable with
webhookConfig.maxPayloadBytes
([#394](#394))
([3de82bd](3de82bd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants