Skip to content

Fix decompression of empty messages with a ratio limit #2246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Jun 2, 2025

Motivation:

The decompressor has a decompression limit to protect against zip bombs. This can either be absolute or ratio based. It's also possible in gRPC for a zero length message to be marked as compressed. gRPC attempts to decompress the zero length message and fails (because zlib wants a non-zero sized buffer and gRPC won't give it one as the limit is the buffer size is limited by the ratio * msg_size which in this case is zero).

Modifications:

  • If the input to decompress has no length, skip decompression altogether

Result:

Motivation:

The decompressor has a decompression limit to protect against zip bombs.
This can either be absolute or ratio based. It's also possible in gRPC
for a zero length message to be marked as compressed. gRPC attempts
to decompress the zero length message and fails (because zlib wants a
non-zero sized buffer and gRPC won't give it one as the limit is the
buffer size is limited by the `ratio * msg_size` which in this case is
zero).

Modifications:

- If the input to decompress has no length, skip decompression
  altogether

Result:

- Can decompress zero length payloads with the ratio limit
- Resolves grpc#2245
@glbrntt glbrntt added 🔨 semver/patch No public API change. version/v1 Relates to v1 labels Jun 2, 2025
@glbrntt glbrntt merged commit a56a157 into grpc:release/1.x Jun 3, 2025
11 checks passed
@glbrntt glbrntt deleted the v1/decompression branch June 3, 2025 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change. version/v1 Relates to v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants